From 506d9ae2fc05cc9ddbcb7c80a12d1c0a45900062 Mon Sep 17 00:00:00 2001 From: Matej Poklemba Date: Wed, 27 Mar 2024 15:44:25 +0100 Subject: [PATCH] Append eip155:chainId in uri --- .../contracts/token/InverseAppProjected1155.sol | 3 +++ .../contracts/token/InverseBaseProjected1155.sol | 2 +- .../evm-contracts/test/InverseAppProjected1155.t.sol | 6 ++++++ .../evm-contracts/test/InverseBaseProjected1155.t.sol | 10 ++++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/contracts/evm-contracts/contracts/token/InverseAppProjected1155.sol b/packages/contracts/evm-contracts/contracts/token/InverseAppProjected1155.sol index 7bdff63e5..0c0997b66 100644 --- a/packages/contracts/evm-contracts/contracts/token/InverseAppProjected1155.sol +++ b/packages/contracts/evm-contracts/contracts/token/InverseAppProjected1155.sol @@ -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(), diff --git a/packages/contracts/evm-contracts/contracts/token/InverseBaseProjected1155.sol b/packages/contracts/evm-contracts/contracts/token/InverseBaseProjected1155.sol index 0b6e59ad0..1239b7543 100644 --- a/packages/contracts/evm-contracts/contracts/token/InverseBaseProjected1155.sol +++ b/packages/contracts/evm-contracts/contracts/token/InverseBaseProjected1155.sol @@ -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)); } diff --git a/packages/contracts/evm-contracts/test/InverseAppProjected1155.t.sol b/packages/contracts/evm-contracts/test/InverseAppProjected1155.t.sol index 1873bb2b4..20618754f 100644 --- a/packages/contracts/evm-contracts/test/InverseAppProjected1155.t.sol +++ b/packages/contracts/evm-contracts/test/InverseAppProjected1155.t.sol @@ -104,6 +104,9 @@ contract InverseAppProjected1155Test is CTest, ERC1155Holder { result, string.concat( baseURI, + "eip155:", + block.chainid.toString(), + "/", Strings.toHexString(uint160(user), 20), "/", userTokenId.toString(), @@ -124,6 +127,9 @@ contract InverseAppProjected1155Test is CTest, ERC1155Holder { result, string.concat( customUri, + "eip155:", + block.chainid.toString(), + "/", Strings.toHexString(uint160(user), 20), "/", userTokenId.toString(), diff --git a/packages/contracts/evm-contracts/test/InverseBaseProjected1155.t.sol b/packages/contracts/evm-contracts/test/InverseBaseProjected1155.t.sol index 576739b0d..a5adca97c 100644 --- a/packages/contracts/evm-contracts/test/InverseBaseProjected1155.t.sol +++ b/packages/contracts/evm-contracts/test/InverseBaseProjected1155.t.sol @@ -89,7 +89,10 @@ 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 { @@ -97,7 +100,10 @@ contract InverseBaseProjected1155Test is CTest, ERC1155Holder { 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 {