From ba1ff1d40dbfb0675237bbd2f8d79803061e2ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anta=CC=83o=20Almada?= Date: Thu, 2 Dec 2021 09:21:38 +0000 Subject: [PATCH] Set base URI on reveal --- contracts/NFT/NFT_REVEAL.sol | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/NFT/NFT_REVEAL.sol b/contracts/NFT/NFT_REVEAL.sol index 39a5f50..516977b 100644 --- a/contracts/NFT/NFT_REVEAL.sol +++ b/contracts/NFT/NFT_REVEAL.sol @@ -34,10 +34,8 @@ contract NFT is ERC721Enumerable, Ownable { constructor( string memory _name, string memory _symbol, - string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { - setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); mint(msg.sender, 20); } @@ -86,15 +84,15 @@ contract NFT is ERC721Enumerable, Ownable { override returns (string memory) { + if(revealed == false) { + return notRevealedUri; + } + require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); - if(revealed == false) { - return notRevealedUri; - } - string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) @@ -102,8 +100,9 @@ contract NFT is ERC721Enumerable, Ownable { } //only owner - function reveal() public onlyOwner { - revealed = true; + function reveal(string memory _baseURIInit) public onlyOwner { + baseURI = _baseURIInit; + revealed = true; } function setCost(uint256 _newCost) public onlyOwner { @@ -119,6 +118,7 @@ contract NFT is ERC721Enumerable, Ownable { } function setBaseURI(string memory _newBaseURI) public onlyOwner { + require(revealed == true); baseURI = _newBaseURI; }