From 83bdaa56b1b41260e8721b5fa5abea3993f5bb5f Mon Sep 17 00:00:00 2001 From: jmank88 Date: Wed, 14 Apr 2021 16:37:37 -0500 Subject: [PATCH] erc721: add setBaseURI; restrict setTokenURI to admin; add both to abi --- assets/erc721.go | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/assets/erc721.go b/assets/erc721.go index 1cb55a6..5503776 100644 --- a/assets/erc721.go +++ b/assets/erc721.go @@ -23,10 +23,16 @@ contract {{.ContractName}} is ERC721PresetMinterPauserAutoId { // This allows the minter to update the tokenURI after it's been minted. // To disable this, delete this function. function setTokenURI(uint256 tokenId, string memory tokenURI) public { - require(hasRole(MINTER_ROLE, _msgSender()), "web3 CLI: must have minter role to update tokenURI"); + require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "web3 CLI: must have admin role to update tokenURI"); _setTokenURI(tokenId, tokenURI); } + + function setBaseURI(string memory baseURI) public { + require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "web3 CLI: must have admin role to update tokenURI"); + + _setBaseURI(baseURI); + } }` const ERC721ABI = `[ @@ -362,5 +368,36 @@ const ERC721ABI = `[ ], "name": "Approval", "type": "event" - } + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "tokenURI", + "type": "string" + } + ], + "name": "setTokenURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "baseURI", + "type": "string" + } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ]`