Skip to content

Commit

Permalink
Append eip155:chainId in tokenURI
Browse files Browse the repository at this point in the history
  • Loading branch information
matejos committed Mar 27, 2024
1 parent a1a2e2a commit f2185dc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ contract InverseAppProjectedNft is IInverseAppProjectedNft, ERC721, Ownable {
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,13 @@ contract InverseBaseProjectedNft is IInverseBaseProjectedNft, ERC721, Ownable {
) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory URI = bytes(customBaseUri).length > 0
? string.concat(customBaseUri, tokenId.toString())
? string.concat(
customBaseUri,
"eip155:",
block.chainid.toString(),
"/",
tokenId.toString()
)
: "";
return string(abi.encodePacked(URI, baseExtension));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contract InverseAppProjectedNftTest is CTest {
assertEq(
result,
string.concat(
"192.168.0.1/",
"192.168.0.1/eip155:31337/",
Strings.toHexString(uint160(address(this)), 20),
"/",
"1.json"
Expand All @@ -57,7 +57,7 @@ contract InverseAppProjectedNftTest is CTest {
assertEq(
result,
string.concat(
"1.1.0.0/",
"1.1.0.0/eip155:31337/",
Strings.toHexString(uint160(address(this)), 20),
"/",
"1.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ contract InverseBaseProjectedNftTest is CTest {

function test_TokenUriUsesBaseUriByDefault() public {
string memory result = nft.tokenURI(ownedTokenId);
assertEq(result, "192.168.0.1/1.json");
assertEq(result, "192.168.0.1/eip155:31337/1.json");
}

function test_TokenUriUsingCustomBaseUri() public {
string memory result = nft.tokenURI(ownedTokenId, "1.1.0.0/");
assertEq(result, "1.1.0.0/1.json");
assertEq(result, "1.1.0.0/eip155:31337/1.json");
}

function test_SupportsInterface() public {
Expand Down

0 comments on commit f2185dc

Please sign in to comment.