difftreelog
genetate evm stubs & fix abiWriter for struct
in: master
13 files changed
crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth--- 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);
}
}
crates/evm-coder/src/abi/traits.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi/traits.rs
+++ b/crates/evm-coder/src/abi/traits.rs
@@ -49,3 +49,9 @@
Ok(writer.into())
}
}
+
+impl<T: AbiWrite> AbiWrite for &T {
+ fn abi_write(&self, writer: &mut AbiWriter) {
+ T::abi_write(self, writer);
+ }
+}
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- 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,
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -725,7 +725,7 @@
&self,
token_id: uint256,
keys: Vec<string>,
- ) -> Result<Vec<(string, bytes)>> {
+ ) -> Result<Vec<PropertyStruct>> {
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::<Result<Vec<_>>>()
}
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth188 /// @return Vector of properties key/value pairs.188 /// @return Vector of properties key/value pairs.189 /// @dev EVM selector for this function is: 0x285fb8e6,189 /// @dev EVM selector for this function is: 0x285fb8e6,190 /// or in textual repr: collectionProperties(string[])190 /// or in textual repr: collectionProperties(string[])191 function collectionProperties(string[] memory keys) public view returns (Tuple23[] memory) {191 function collectionProperties(string[] memory keys) public view returns (Tuple27[] memory) {192 require(false, stub_error);192 require(false, stub_error);193 keys;193 keys;194 dummy;194 dummy;195 return new Tuple23[](0);195 return new Tuple27[](0);196 }196 }197197198 // /// Set the sponsor of the collection.198 // /// Set the sponsor of the collection.253 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.253 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.254 /// @dev EVM selector for this function is: 0x6ec0a9f1,254 /// @dev EVM selector for this function is: 0x6ec0a9f1,255 /// or in textual repr: collectionSponsor()255 /// or in textual repr: collectionSponsor()256 function collectionSponsor() public view returns (Tuple26 memory) {256 function collectionSponsor() public view returns (Tuple30 memory) {257 require(false, stub_error);257 require(false, stub_error);258 dummy;258 dummy;259 return Tuple26(0x0000000000000000000000000000000000000000, 0);259 return Tuple30(0x0000000000000000000000000000000000000000, 0);260 }260 }261261262 /// Set limits for the collection.262 /// Set limits for the collection.527}527}528528529/// @dev anonymous struct529/// @dev anonymous struct530struct Tuple26 {530struct Tuple30 {531 address field_0;531 address field_0;532 uint256 field_1;532 uint256 field_1;533}533}534534535/// @dev anonymous struct535/// @dev anonymous struct536struct Tuple23 {536struct Tuple27 {537 string field_0;537 string field_0;538 bytes field_1;538 bytes field_1;539}539}682}682}683683684/// @title Unique extensions for ERC721.684/// @title Unique extensions for ERC721.685/// @dev the ERC-165 identifier for this interface is 0x0e9fc611685/// @dev the ERC-165 identifier for this interface is 0xb8f094a0686contract ERC721UniqueExtensions is Dummy, ERC165 {686contract ERC721UniqueExtensions is Dummy, ERC165 {687 /// @notice A descriptive name for a collection of NFTs in this contract687 /// @notice A descriptive name for a collection of NFTs in this contract688 /// @dev EVM selector for this function is: 0x06fdde03,688 /// @dev EVM selector for this function is: 0x06fdde03,730 /// @return Vector of properties key/value pairs.730 /// @return Vector of properties key/value pairs.731 /// @dev EVM selector for this function is: 0xefc26c69,731 /// @dev EVM selector for this function is: 0xefc26c69,732 /// or in textual repr: tokenProperties(uint256,string[])732 /// or in textual repr: tokenProperties(uint256,string[])733 function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Tuple8[] memory) {733 function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Property[] memory) {734 require(false, stub_error);734 require(false, stub_error);735 tokenId;735 tokenId;736 keys;736 keys;737 dummy;737 dummy;738 return new Tuple8[](0);738 return new Property[](0);739 }739 }740740741 /// @notice Set or reaffirm the approved address for an NFT741 /// @notice Set or reaffirm the approved address for an NFT861 // /// @param tokens array of pairs of token ID and token URI for minted tokens861 // /// @param tokens array of pairs of token ID and token URI for minted tokens862 // /// @dev EVM selector for this function is: 0x36543006,862 // /// @dev EVM selector for this function is: 0x36543006,863 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])863 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])864 // function mintBulkWithTokenURI(address to, Tuple11[] memory tokens) public returns (bool) {864 // function mintBulkWithTokenURI(address to, Tuple15[] memory tokens) public returns (bool) {865 // require(false, stub_error);865 // require(false, stub_error);866 // to;866 // to;867 // tokens;867 // tokens;872}872}873873874/// @dev anonymous struct874/// @dev anonymous struct875struct Tuple11 {875struct Tuple15 {876 uint256 field_0;876 uint256 field_0;877 string field_1;877 string field_1;878}878}879880/// @dev anonymous struct881struct Tuple8 {882 string field_0;883 bytes field_1;884}885879886/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension880/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension887/// @dev See https://eips.ethereum.org/EIPS/eip-721881/// @dev See https://eips.ethereum.org/EIPS/eip-721pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -753,7 +753,7 @@
&self,
token_id: uint256,
keys: Vec<string>,
- ) -> Result<Vec<(string, bytes)>> {
+ ) -> Result<Vec<PropertyStruct>> {
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::<Result<Vec<_>>>()
}
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- 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
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- 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[]"
}
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- 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[]"
}
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- 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,
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- 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
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- 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
tests/src/eth/base.test.tsdiffbeforeafterboth--- 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}) => {