Skip to content

Commit

Permalink
Merge pull request #114 from open-format/fix/ERC721Base-batch-mint-to…
Browse files Browse the repository at this point in the history
…ken-uri

Fix: Only return batchUri when calling tokenURI function
  • Loading branch information
tinypell3ts authored Dec 4, 2023
2 parents b36f218 + ec929a8 commit c9c5456
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-berries-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openformat/contracts": patch
---

Fix: Only return batchUri when calling tokenURI function on ERC721Base
2 changes: 1 addition & 1 deletion src/tokens/ERC721/ERC721Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ contract ERC721Base is

// tokenURI was stored using batchMintTo
string memory batchUri = _getBaseURI(_tokenId);
return string.concat(batchUri, UintUtils.toString(_tokenId));
return batchUri;
}

/*//////////////////////////////////////////////////////////////
Expand Down
12 changes: 6 additions & 6 deletions test/tokens/ERC721/ERC721Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ contract ERC721Base__batchMintTo is Setup {
assertEq(other, erc721Base.ownerOf(2));
}

function test_appends_token_id_to_baseURI() public {
function test_returns_baseURI() public {
vm.prank(creator);
erc721Base.batchMintTo(other, 3, baseURI);

assertEq(erc721Base.tokenURI(0), string.concat(baseURI, "0"));
assertEq(erc721Base.tokenURI(1), string.concat(baseURI, "1"));
assertEq(erc721Base.tokenURI(2), string.concat(baseURI, "2"));
assertEq(erc721Base.tokenURI(0), baseURI);
assertEq(erc721Base.tokenURI(1), baseURI);
assertEq(erc721Base.tokenURI(2), baseURI);
}

function test_can_be_mixed_with_mintTo() public {
Expand All @@ -162,8 +162,8 @@ contract ERC721Base__batchMintTo is Setup {
erc721Base.batchMintTo(other, 2, baseURI);

assertEq(erc721Base.tokenURI(0), tokenURI);
assertEq(erc721Base.tokenURI(1), string.concat(baseURI, "1"));
assertEq(erc721Base.tokenURI(2), string.concat(baseURI, "2"));
assertEq(erc721Base.tokenURI(1), baseURI);
assertEq(erc721Base.tokenURI(2), baseURI);
}

function test_reverts_if_not_authorised() public {
Expand Down

0 comments on commit c9c5456

Please sign in to comment.