--- a/crates/evm-coder/src/abi/impls.rs +++ b/crates/evm-coder/src/abi/impls.rs @@ -184,8 +184,7 @@ impl AbiWrite for Property { fn abi_write(&self, writer: &mut AbiWriter) { - self.key.abi_write(writer); - self.value.abi_write(writer); + (&self.key, &self.value).abi_write(writer); } } --- a/crates/evm-coder/src/abi/traits.rs +++ b/crates/evm-coder/src/abi/traits.rs @@ -49,3 +49,9 @@ Ok(writer.into()) } } + +impl AbiWrite for &T { + fn abi_write(&self, writer: &mut AbiWriter) { + T::abi_write(self, writer); + } +} --- a/pallets/fungible/src/stubs/UniqueFungible.sol +++ b/pallets/fungible/src/stubs/UniqueFungible.sol @@ -437,7 +437,7 @@ bytes value; } -/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9 +/// @dev the ERC-165 identifier for this interface is 0x5b7038cf contract ERC20UniqueExtensions is Dummy, ERC165 { /// @notice A description for the collection. /// @dev EVM selector for this function is: 0x7284e416, --- a/pallets/nonfungible/src/erc.rs +++ b/pallets/nonfungible/src/erc.rs @@ -725,7 +725,7 @@ &self, token_id: uint256, keys: Vec, - ) -> Result> { + ) -> Result> { let keys = keys .into_iter() .map(|key| { @@ -745,7 +745,7 @@ let key = string::from_utf8(p.key.to_vec()) .map_err(|e| Error::Revert(alloc::format!("{}", e)))?; let value = bytes(p.value.to_vec()); - Ok((key, value)) + Ok(PropertyStruct { key, value }) }) .collect::>>() } --- a/pallets/nonfungible/src/stubs/UniqueNFT.sol +++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol @@ -188,11 +188,11 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0x285fb8e6, /// or in textual repr: collectionProperties(string[]) - function collectionProperties(string[] memory keys) public view returns (Tuple23[] memory) { + function collectionProperties(string[] memory keys) public view returns (Tuple27[] memory) { require(false, stub_error); keys; dummy; - return new Tuple23[](0); + return new Tuple27[](0); } // /// Set the sponsor of the collection. @@ -253,10 +253,10 @@ /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. /// @dev EVM selector for this function is: 0x6ec0a9f1, /// or in textual repr: collectionSponsor() - function collectionSponsor() public view returns (Tuple26 memory) { + function collectionSponsor() public view returns (Tuple30 memory) { require(false, stub_error); dummy; - return Tuple26(0x0000000000000000000000000000000000000000, 0); + return Tuple30(0x0000000000000000000000000000000000000000, 0); } /// Set limits for the collection. @@ -527,13 +527,13 @@ } /// @dev anonymous struct -struct Tuple26 { +struct Tuple30 { address field_0; uint256 field_1; } /// @dev anonymous struct -struct Tuple23 { +struct Tuple27 { string field_0; bytes field_1; } @@ -682,7 +682,7 @@ } /// @title Unique extensions for ERC721. -/// @dev the ERC-165 identifier for this interface is 0x0e9fc611 +/// @dev the ERC-165 identifier for this interface is 0xb8f094a0 contract ERC721UniqueExtensions is Dummy, ERC165 { /// @notice A descriptive name for a collection of NFTs in this contract /// @dev EVM selector for this function is: 0x06fdde03, @@ -730,12 +730,12 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0xefc26c69, /// or in textual repr: tokenProperties(uint256,string[]) - function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Tuple8[] memory) { + function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Property[] memory) { require(false, stub_error); tokenId; keys; dummy; - return new Tuple8[](0); + return new Property[](0); } /// @notice Set or reaffirm the approved address for an NFT @@ -861,7 +861,7 @@ // /// @param tokens array of pairs of token ID and token URI for minted tokens // /// @dev EVM selector for this function is: 0x36543006, // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) - // function mintBulkWithTokenURI(address to, Tuple11[] memory tokens) public returns (bool) { + // function mintBulkWithTokenURI(address to, Tuple15[] memory tokens) public returns (bool) { // require(false, stub_error); // to; // tokens; @@ -872,15 +872,9 @@ } /// @dev anonymous struct -struct Tuple11 { +struct Tuple15 { uint256 field_0; string field_1; -} - -/// @dev anonymous struct -struct Tuple8 { - string field_0; - bytes field_1; } /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension --- a/pallets/refungible/src/erc.rs +++ b/pallets/refungible/src/erc.rs @@ -753,7 +753,7 @@ &self, token_id: uint256, keys: Vec, - ) -> Result> { + ) -> Result> { let keys = keys .into_iter() .map(|key| { @@ -773,7 +773,7 @@ let key = string::from_utf8(p.key.to_vec()) .map_err(|e| Error::Revert(alloc::format!("{}", e)))?; let value = bytes(p.value.to_vec()); - Ok((key, value)) + Ok(PropertyStruct { key, value }) }) .collect::>>() } --- a/pallets/refungible/src/stubs/UniqueRefungible.sol +++ b/pallets/refungible/src/stubs/UniqueRefungible.sol @@ -188,11 +188,11 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0x285fb8e6, /// or in textual repr: collectionProperties(string[]) - function collectionProperties(string[] memory keys) public view returns (Tuple22[] memory) { + function collectionProperties(string[] memory keys) public view returns (Tuple26[] memory) { require(false, stub_error); keys; dummy; - return new Tuple22[](0); + return new Tuple26[](0); } // /// Set the sponsor of the collection. @@ -253,10 +253,10 @@ /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. /// @dev EVM selector for this function is: 0x6ec0a9f1, /// or in textual repr: collectionSponsor() - function collectionSponsor() public view returns (Tuple25 memory) { + function collectionSponsor() public view returns (Tuple29 memory) { require(false, stub_error); dummy; - return Tuple25(0x0000000000000000000000000000000000000000, 0); + return Tuple29(0x0000000000000000000000000000000000000000, 0); } /// Set limits for the collection. @@ -527,13 +527,13 @@ } /// @dev anonymous struct -struct Tuple25 { +struct Tuple29 { address field_0; uint256 field_1; } /// @dev anonymous struct -struct Tuple22 { +struct Tuple26 { string field_0; bytes field_1; } @@ -680,7 +680,7 @@ } /// @title Unique extensions for ERC721. -/// @dev the ERC-165 identifier for this interface is 0xab243667 +/// @dev the ERC-165 identifier for this interface is 0x1d4b64d6 contract ERC721UniqueExtensions is Dummy, ERC165 { /// @notice A descriptive name for a collection of NFTs in this contract /// @dev EVM selector for this function is: 0x06fdde03, @@ -728,12 +728,12 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0xefc26c69, /// or in textual repr: tokenProperties(uint256,string[]) - function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Tuple8[] memory) { + function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Property[] memory) { require(false, stub_error); tokenId; keys; dummy; - return new Tuple8[](0); + return new Property[](0); } /// @notice Transfer ownership of an RFT @@ -849,7 +849,7 @@ // /// @param tokens array of pairs of token ID and token URI for minted tokens // /// @dev EVM selector for this function is: 0x36543006, // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) - // function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) public returns (bool) { + // function mintBulkWithTokenURI(address to, Tuple14[] memory tokens) public returns (bool) { // require(false, stub_error); // to; // tokens; @@ -871,15 +871,9 @@ } /// @dev anonymous struct -struct Tuple10 { +struct Tuple14 { uint256 field_0; string field_1; -} - -/// @dev anonymous struct -struct Tuple8 { - string field_0; - bytes field_1; } /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension --- a/tests/src/eth/abi/nonFungible.json +++ b/tests/src/eth/abi/nonFungible.json @@ -249,7 +249,7 @@ { "internalType": "string", "name": "field_0", "type": "string" }, { "internalType": "bytes", "name": "field_1", "type": "bytes" } ], - "internalType": "struct Tuple23[]", + "internalType": "struct Tuple27[]", "name": "", "type": "tuple[]" } @@ -273,7 +273,7 @@ { "internalType": "address", "name": "field_0", "type": "address" }, { "internalType": "uint256", "name": "field_1", "type": "uint256" } ], - "internalType": "struct Tuple26", + "internalType": "struct Tuple30", "name": "", "type": "tuple" } @@ -674,10 +674,10 @@ "outputs": [ { "components": [ - { "internalType": "string", "name": "field_0", "type": "string" }, - { "internalType": "bytes", "name": "field_1", "type": "bytes" } + { "internalType": "string", "name": "key", "type": "string" }, + { "internalType": "bytes", "name": "value", "type": "bytes" } ], - "internalType": "struct Tuple8[]", + "internalType": "struct Property[]", "name": "", "type": "tuple[]" } --- a/tests/src/eth/abi/reFungible.json +++ b/tests/src/eth/abi/reFungible.json @@ -231,7 +231,7 @@ { "internalType": "string", "name": "field_0", "type": "string" }, { "internalType": "bytes", "name": "field_1", "type": "bytes" } ], - "internalType": "struct Tuple22[]", + "internalType": "struct Tuple26[]", "name": "", "type": "tuple[]" } @@ -255,7 +255,7 @@ { "internalType": "address", "name": "field_0", "type": "address" }, { "internalType": "uint256", "name": "field_1", "type": "uint256" } ], - "internalType": "struct Tuple25", + "internalType": "struct Tuple29", "name": "", "type": "tuple" } @@ -665,10 +665,10 @@ "outputs": [ { "components": [ - { "internalType": "string", "name": "field_0", "type": "string" }, - { "internalType": "bytes", "name": "field_1", "type": "bytes" } + { "internalType": "string", "name": "key", "type": "string" }, + { "internalType": "bytes", "name": "value", "type": "bytes" } ], - "internalType": "struct Tuple8[]", + "internalType": "struct Property[]", "name": "", "type": "tuple[]" } --- a/tests/src/eth/api/UniqueFungible.sol +++ b/tests/src/eth/api/UniqueFungible.sol @@ -290,7 +290,7 @@ bytes value; } -/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9 +/// @dev the ERC-165 identifier for this interface is 0x5b7038cf interface ERC20UniqueExtensions is Dummy, ERC165 { /// @notice A description for the collection. /// @dev EVM selector for this function is: 0x7284e416, --- a/tests/src/eth/api/UniqueNFT.sol +++ b/tests/src/eth/api/UniqueNFT.sol @@ -45,7 +45,7 @@ /// @param properties settable properties /// @dev EVM selector for this function is: 0x14ed3a6e, /// or in textual repr: setProperties(uint256,(string,bytes)[]) - function setProperties(uint256 tokenId, Tuple21[] memory properties) external; + function setProperties(uint256 tokenId, Property[] memory properties) external; // /// @notice Delete token property value. // /// @dev Throws error if `msg.sender` has no permission to edit the property. @@ -95,7 +95,7 @@ /// @param properties Vector of properties key/value pair. /// @dev EVM selector for this function is: 0x50b26b2a, /// or in textual repr: setCollectionProperties((string,bytes)[]) - function setCollectionProperties(Tuple21[] memory properties) external; + function setCollectionProperties(Property[] memory properties) external; // /// Delete collection property. // /// @@ -127,7 +127,7 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0x285fb8e6, /// or in textual repr: collectionProperties(string[]) - function collectionProperties(string[] memory keys) external view returns (Tuple21[] memory); + function collectionProperties(string[] memory keys) external view returns (Tuple25[] memory); // /// Set the sponsor of the collection. // /// @@ -169,7 +169,7 @@ /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. /// @dev EVM selector for this function is: 0x6ec0a9f1, /// or in textual repr: collectionSponsor() - function collectionSponsor() external view returns (Tuple24 memory); + function collectionSponsor() external view returns (Tuple28 memory); /// Set limits for the collection. /// @dev Throws error if limit not found. @@ -346,13 +346,13 @@ } /// @dev anonymous struct -struct Tuple24 { +struct Tuple28 { address field_0; uint256 field_1; } /// @dev anonymous struct -struct Tuple21 { +struct Tuple25 { string field_0; bytes field_1; } @@ -452,7 +452,7 @@ } /// @title Unique extensions for ERC721. -/// @dev the ERC-165 identifier for this interface is 0x244543ee +/// @dev the ERC-165 identifier for this interface is 0xb8f094a0 interface ERC721UniqueExtensions is Dummy, ERC165 { /// @notice A descriptive name for a collection of NFTs in this contract /// @dev EVM selector for this function is: 0x06fdde03, @@ -483,7 +483,7 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0xefc26c69, /// or in textual repr: tokenProperties(uint256,string[]) - function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Tuple7[] memory); + function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Property[] memory); /// @notice Set or reaffirm the approved address for an NFT /// @dev The zero address indicates there is no approved address. @@ -567,20 +567,14 @@ // /// @param tokens array of pairs of token ID and token URI for minted tokens // /// @dev EVM selector for this function is: 0x36543006, // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) - // function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) external returns (bool); + // function mintBulkWithTokenURI(address to, Tuple13[] memory tokens) external returns (bool); } /// @dev anonymous struct -struct Tuple10 { +struct Tuple13 { uint256 field_0; string field_1; -} - -/// @dev anonymous struct -struct Tuple7 { - string field_0; - bytes field_1; } /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension --- a/tests/src/eth/api/UniqueRefungible.sol +++ b/tests/src/eth/api/UniqueRefungible.sol @@ -127,7 +127,7 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0x285fb8e6, /// or in textual repr: collectionProperties(string[]) - function collectionProperties(string[] memory keys) external view returns (Tuple22[] memory); + function collectionProperties(string[] memory keys) external view returns (Tuple24[] memory); // /// Set the sponsor of the collection. // /// @@ -169,7 +169,7 @@ /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. /// @dev EVM selector for this function is: 0x6ec0a9f1, /// or in textual repr: collectionSponsor() - function collectionSponsor() external view returns (Tuple25 memory); + function collectionSponsor() external view returns (Tuple27 memory); /// Set limits for the collection. /// @dev Throws error if limit not found. @@ -346,13 +346,13 @@ } /// @dev anonymous struct -struct Tuple25 { +struct Tuple27 { address field_0; uint256 field_1; } /// @dev anonymous struct -struct Tuple22 { +struct Tuple24 { string field_0; bytes field_1; } @@ -450,7 +450,7 @@ } /// @title Unique extensions for ERC721. -/// @dev the ERC-165 identifier for this interface is 0xab243667 +/// @dev the ERC-165 identifier for this interface is 0x1d4b64d6 interface ERC721UniqueExtensions is Dummy, ERC165 { /// @notice A descriptive name for a collection of NFTs in this contract /// @dev EVM selector for this function is: 0x06fdde03, @@ -481,7 +481,7 @@ /// @return Vector of properties key/value pairs. /// @dev EVM selector for this function is: 0xefc26c69, /// or in textual repr: tokenProperties(uint256,string[]) - function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Tuple7[] memory); + function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Property[] memory); /// @notice Transfer ownership of an RFT /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` @@ -560,7 +560,7 @@ // /// @param tokens array of pairs of token ID and token URI for minted tokens // /// @dev EVM selector for this function is: 0x36543006, // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) - // function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) external returns (bool); + // function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool); /// Returns EVM address for refungible token /// @@ -571,15 +571,9 @@ } /// @dev anonymous struct -struct Tuple10 { +struct Tuple12 { uint256 field_0; string field_1; -} - -/// @dev anonymous struct -struct Tuple7 { - string field_0; - bytes field_1; } /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension --- a/tests/src/eth/base.test.ts +++ b/tests/src/eth/base.test.ts @@ -117,7 +117,7 @@ }); itEth('ERC721UniqueExtensions support', async ({helper}) => { - await checkInterface(helper, '0x922a115f', true, true); + await checkInterface(helper, '0xb8f094a0', true, true); }); itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {