Skip to content

Commit

Permalink
(Q-3) TokenERC721 can have empty URI
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 committed Sep 20, 2022
1 parent 285009b commit c49c0e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/token/TokenERC721.sol
Expand Up @@ -305,6 +305,7 @@ contract TokenERC721 is
tokenIdToMint = nextTokenIdToMint;
nextTokenIdToMint += 1;

require(bytes(_uri).length > 0, "empty uri.");
uri[tokenIdToMint] = _uri;

_safeMint(_to, tokenIdToMint);
Expand Down
7 changes: 7 additions & 0 deletions src/test/token/TokenERC721.t.sol
Expand Up @@ -307,6 +307,13 @@ contract TokenERC721Test is BaseTest {
tokenContract.mintTo(recipient, _tokenURI);
}

function test_revert_mintTo_emptyURI() public {
// mint
vm.prank(deployerSigner);
vm.expectRevert("empty uri.");
tokenContract.mintTo(recipient, "");
}

function test_event_mintTo() public {
string memory _tokenURI = "tokenURI";

Expand Down

0 comments on commit c49c0e5

Please sign in to comment.