Skip to content

Commit

Permalink
support update token uri
Browse files Browse the repository at this point in the history
  • Loading branch information
jollyjoker992 committed Jan 12, 2024
1 parent 8d99851 commit ce8347e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions contracts/FeralFileAirdropV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ contract FeralFileAirdropV1 is ERC1155, Authorizable {
_ended = true;
}

/// @notice set contract URI
/// @param uri_ contract URI
function setURI(string memory uri_) external onlyOwner {
_setURI(uri_);
}

/// @notice Mint tokens to the contract
/// @param tokenID_ token ID
/// @param amount_ amount of tokens to mint
Expand Down
24 changes: 23 additions & 1 deletion test/feralfile_airdrop_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract("FeralFileAirdropV1", async (accounts) => {
// To isolate the test cases, we create multiple pairs of contracts
// for each token type. The index of the contract pair will be used
// as index of test cases.
for (let i = 0; i < 7; i++) {
for (let i = 0; i < 8; i++) {
let burnable = i == 6 ? false : true;
let bridgeable = true;
let fungibleContract = await FeralFileAirdropV1.new(
Expand Down Expand Up @@ -356,4 +356,26 @@ contract("FeralFileAirdropV1", async (accounts) => {
}
}
});

it("test set uri", async () => {
let contracts = this.contracts[7];
for (let i = 0; i < contracts.length; i++) {
let contract = contracts[i];
let tokenURI =
"https://ipfs.bitmark.com/ipfs/QmNVdQSp1AvZonLwHzTbbZDPLgbpty15RMQrbPEWd4ooTV/{id}";

// test unauthorized call
try {
await contract.setURI(tokenURI, {
from: accounts[2],
});
} catch (e) {
assert.equal(e.reason, "Ownable: caller is not the owner");
}

// test set uri successfully
await contract.setURI(tokenURI, { from: this.owner });
assert.equal(await contract.uri(TOKEN_ID), tokenURI);
}
});
});

0 comments on commit ce8347e

Please sign in to comment.