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.soldiffbeforeafterboth--- 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
pallets/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.soldiffbeforeafterboth127 /// @return Vector of properties key/value pairs.127 /// @return Vector of properties key/value pairs.128 /// @dev EVM selector for this function is: 0x285fb8e6,128 /// @dev EVM selector for this function is: 0x285fb8e6,129 /// or in textual repr: collectionProperties(string[])129 /// or in textual repr: collectionProperties(string[])130 function collectionProperties(string[] memory keys) external view returns (Tuple22[] memory);130 function collectionProperties(string[] memory keys) external view returns (Tuple24[] memory);131131132 // /// Set the sponsor of the collection.132 // /// Set the sponsor of the collection.133 // ///133 // ///169 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.169 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.170 /// @dev EVM selector for this function is: 0x6ec0a9f1,170 /// @dev EVM selector for this function is: 0x6ec0a9f1,171 /// or in textual repr: collectionSponsor()171 /// or in textual repr: collectionSponsor()172 function collectionSponsor() external view returns (Tuple25 memory);172 function collectionSponsor() external view returns (Tuple27 memory);173173174 /// Set limits for the collection.174 /// Set limits for the collection.175 /// @dev Throws error if limit not found.175 /// @dev Throws error if limit not found.346}346}347347348/// @dev anonymous struct348/// @dev anonymous struct349struct Tuple25 {349struct Tuple27 {350 address field_0;350 address field_0;351 uint256 field_1;351 uint256 field_1;352}352}353353354/// @dev anonymous struct354/// @dev anonymous struct355struct Tuple22 {355struct Tuple24 {356 string field_0;356 string field_0;357 bytes field_1;357 bytes field_1;358}358}450}450}451451452/// @title Unique extensions for ERC721.452/// @title Unique extensions for ERC721.453/// @dev the ERC-165 identifier for this interface is 0xab243667453/// @dev the ERC-165 identifier for this interface is 0x1d4b64d6454interface ERC721UniqueExtensions is Dummy, ERC165 {454interface ERC721UniqueExtensions is Dummy, ERC165 {455 /// @notice A descriptive name for a collection of NFTs in this contract455 /// @notice A descriptive name for a collection of NFTs in this contract456 /// @dev EVM selector for this function is: 0x06fdde03,456 /// @dev EVM selector for this function is: 0x06fdde03,481 /// @return Vector of properties key/value pairs.481 /// @return Vector of properties key/value pairs.482 /// @dev EVM selector for this function is: 0xefc26c69,482 /// @dev EVM selector for this function is: 0xefc26c69,483 /// or in textual repr: tokenProperties(uint256,string[])483 /// or in textual repr: tokenProperties(uint256,string[])484 function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Tuple7[] memory);484 function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Property[] memory);485485486 /// @notice Transfer ownership of an RFT486 /// @notice Transfer ownership of an RFT487 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`487 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`560 // /// @param tokens array of pairs of token ID and token URI for minted tokens560 // /// @param tokens array of pairs of token ID and token URI for minted tokens561 // /// @dev EVM selector for this function is: 0x36543006,561 // /// @dev EVM selector for this function is: 0x36543006,562 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])562 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])563 // function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) external returns (bool);563 // function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);564564565 /// Returns EVM address for refungible token565 /// Returns EVM address for refungible token566 ///566 ///571}571}572572573/// @dev anonymous struct573/// @dev anonymous struct574struct Tuple10 {574struct Tuple12 {575 uint256 field_0;575 uint256 field_0;576 string field_1;576 string field_1;577}577}578579/// @dev anonymous struct580struct Tuple7 {581 string field_0;582 bytes field_1;583}584578585/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension579/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension586/// @dev See https://eips.ethereum.org/EIPS/eip-721580/// @dev See https://eips.ethereum.org/EIPS/eip-721tests/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}) => {