diff --git a/contracts/FeralFileAirdropV1.sol b/contracts/FeralFileAirdropV1.sol index be316e0..34f42d9 100644 --- a/contracts/FeralFileAirdropV1.sol +++ b/contracts/FeralFileAirdropV1.sol @@ -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 diff --git a/test/feralfile_airdrop_v1.js b/test/feralfile_airdrop_v1.js index 73c9065..119d61b 100644 --- a/test/feralfile_airdrop_v1.js +++ b/test/feralfile_airdrop_v1.js @@ -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( @@ -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); + } + }); });