Skip to content

Commit

Permalink
Append eip155:chainId in uri
Browse files Browse the repository at this point in the history
  • Loading branch information
matejos committed Apr 2, 2024
1 parent fb58da0 commit 506d9ae
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ contract InverseAppProjected1155 is IInverseAppProjected1155, ERC1155Supply, Own
string memory URI = bytes(customBaseUri).length > 0
? string.concat(
customBaseUri,
"eip155:",
block.chainid.toString(),
"/",
Strings.toHexString(uint160(entry.minter), 20),
"/",
entry.userTokenId.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ contract InverseBaseProjected1155 is IInverseBaseProjected1155, ERC1155Supply, O
) public view virtual returns (string memory) {
require(exists(id), "InverseBaseProjected1155: URI query for nonexistent token");
string memory URI = bytes(customBaseUri).length > 0
? string.concat(customBaseUri, id.toString())
? string.concat(customBaseUri, "eip155:", block.chainid.toString(), "/", id.toString())
: "";
return string(abi.encodePacked(URI, baseExtension));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ contract InverseAppProjected1155Test is CTest, ERC1155Holder {
result,
string.concat(
baseURI,
"eip155:",
block.chainid.toString(),
"/",
Strings.toHexString(uint160(user), 20),
"/",
userTokenId.toString(),
Expand All @@ -124,6 +127,9 @@ contract InverseAppProjected1155Test is CTest, ERC1155Holder {
result,
string.concat(
customUri,
"eip155:",
block.chainid.toString(),
"/",
Strings.toHexString(uint160(user), 20),
"/",
userTokenId.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,21 @@ contract InverseBaseProjected1155Test is CTest, ERC1155Holder {
uint256 value = 1000;
uint256 tokenId = token.mint(value, bytes(""), "");
string memory result = token.uri(tokenId);
assertEq(result, string.concat(baseURI, tokenId.toString()));
assertEq(
result,
string.concat(baseURI, "eip155:", block.chainid.toString(), "/", tokenId.toString())
);
}

function test_TokenUriUsingCustomBaseUri() public {
uint256 value = 1000;
uint256 tokenId = token.mint(value, bytes(""), "");
string memory customUri = "1.1.0.0/";
string memory result = token.uri(tokenId, customUri);
assertEq(result, string.concat(customUri, tokenId.toString()));
assertEq(
result,
string.concat(customUri, "eip155:", block.chainid.toString(), "/", tokenId.toString())
);
}

function test_SupportsInterface() public {
Expand Down

0 comments on commit 506d9ae

Please sign in to comment.