difftreelog
added `collectionNestingRestrictedCollectionIds()` function in `Collection` interface.
in: master
14 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -493,6 +493,21 @@
<Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)
}
+ /// Returns nesting for a collection
+ #[solidity(rename_selector = "collectionNestingRestrictedCollectionIds")]
+ fn collection_nesting_restricted_ids(&self) -> Result<(bool, Vec<uint256>)> {
+ let nesting = self.collection.permissions.nesting();
+
+ Ok((
+ nesting.token_owner,
+ nesting
+ .restricted
+ .clone()
+ .map(|b| b.0.into_inner().iter().map(|id| id.0.into()).collect())
+ .unwrap_or_default(),
+ ))
+ }
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xcc1d80ca
+/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -254,6 +254,15 @@
dummy = 0;
}
+ /// Returns nesting for a collection
+ /// @dev EVM selector for this function is: 0x22d25bfe,
+ /// or in textual repr: collectionNestingRestrictedCollectionIds()
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple21 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple21(false, new uint256[](0));
+ }
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -425,6 +434,12 @@
uint256 sub;
}
+/// @dev anonymous struct
+struct Tuple21 {
+ bool field_0;
+ uint256[] field_1;
+}
+
/// @dev Property struct
struct Property {
string key;
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth119}119}120120121/// @title A contract that allows you to work with collections.121/// @title A contract that allows you to work with collections.122/// @dev the ERC-165 identifier for this interface is 0xcc1d80ca122/// @dev the ERC-165 identifier for this interface is 0xeecfdb34123contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {124 // /// Set collection property.124 // /// Set collection property.125 // ///125 // ///355 dummy = 0;355 dummy = 0;356 }356 }357358 /// Returns nesting for a collection359 /// @dev EVM selector for this function is: 0x22d25bfe,360 /// or in textual repr: collectionNestingRestrictedCollectionIds()361 function collectionNestingRestrictedCollectionIds() public view returns (Tuple34 memory) {362 require(false, stub_error);363 dummy;364 return Tuple34(false, new uint256[](0));365 }357366358 /// Set the collection access method.367 /// Set the collection access method.359 /// @param mode Access mode368 /// @param mode Access mode526 uint256 sub;535 uint256 sub;527}536}537538/// @dev anonymous struct539struct Tuple34 {540 bool field_0;541 uint256[] field_1;542}528543529/// @dev anonymous struct544/// @dev anonymous struct530struct Tuple30 {545struct Tuple30 {pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -119,7 +119,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xcc1d80ca
+/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -355,6 +355,15 @@
dummy = 0;
}
+ /// Returns nesting for a collection
+ /// @dev EVM selector for this function is: 0x22d25bfe,
+ /// or in textual repr: collectionNestingRestrictedCollectionIds()
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple33 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple33(false, new uint256[](0));
+ }
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -527,6 +536,12 @@
}
/// @dev anonymous struct
+struct Tuple33 {
+ bool field_0;
+ uint256[] field_1;
+}
+
+/// @dev anonymous struct
struct Tuple29 {
address field_0;
uint256 field_1;
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
tests/src/eth/abi/fungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -208,6 +208,27 @@
},
{
"inputs": [],
+ "name": "collectionNestingRestrictedCollectionIds",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "bool", "name": "field_0", "type": "bool" },
+ {
+ "internalType": "uint256[]",
+ "name": "field_1",
+ "type": "uint256[]"
+ }
+ ],
+ "internalType": "struct Tuple21",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionOwner",
"outputs": [
{
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -238,6 +238,27 @@
},
{
"inputs": [],
+ "name": "collectionNestingRestrictedCollectionIds",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "bool", "name": "field_0", "type": "bool" },
+ {
+ "internalType": "uint256[]",
+ "name": "field_1",
+ "type": "uint256[]"
+ }
+ ],
+ "internalType": "struct Tuple34",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionOwner",
"outputs": [
{
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -220,6 +220,27 @@
},
{
"inputs": [],
+ "name": "collectionNestingRestrictedCollectionIds",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "bool", "name": "field_0", "type": "bool" },
+ {
+ "internalType": "uint256[]",
+ "name": "field_1",
+ "type": "uint256[]"
+ }
+ ],
+ "internalType": "struct Tuple33",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionOwner",
"outputs": [
{
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xcc1d80ca
+/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -166,6 +166,11 @@
/// or in textual repr: setCollectionNesting(bool,address[])
function setCollectionNesting(bool enable, address[] memory collections) external;
+ /// Returns nesting for a collection
+ /// @dev EVM selector for this function is: 0x22d25bfe,
+ /// or in textual repr: collectionNestingRestrictedCollectionIds()
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple20 memory);
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -278,6 +283,12 @@
uint256 sub;
}
+/// @dev anonymous struct
+struct Tuple20 {
+ bool field_0;
+ uint256[] field_1;
+}
+
/// @dev Property struct
struct Property {
string key;
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -80,7 +80,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xcc1d80ca
+/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -233,6 +233,11 @@
/// or in textual repr: setCollectionNesting(bool,address[])
function setCollectionNesting(bool enable, address[] memory collections) external;
+ /// Returns nesting for a collection
+ /// @dev EVM selector for this function is: 0x22d25bfe,
+ /// or in textual repr: collectionNestingRestrictedCollectionIds()
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple31 memory);
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -346,6 +351,12 @@
}
/// @dev anonymous struct
+struct Tuple31 {
+ bool field_0;
+ uint256[] field_1;
+}
+
+/// @dev anonymous struct
struct Tuple27 {
address field_0;
uint256 field_1;
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -80,7 +80,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xcc1d80ca
+/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -233,6 +233,11 @@
/// or in textual repr: setCollectionNesting(bool,address[])
function setCollectionNesting(bool enable, address[] memory collections) external;
+ /// Returns nesting for a collection
+ /// @dev EVM selector for this function is: 0x22d25bfe,
+ /// or in textual repr: collectionNestingRestrictedCollectionIds()
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple30 memory);
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -346,6 +351,12 @@
}
/// @dev anonymous struct
+struct Tuple30 {
+ bool field_0;
+ uint256[] field_1;
+}
+
+/// @dev anonymous struct
struct Tuple26 {
address field_0;
uint256 field_1;
tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -51,7 +51,20 @@
await contract.methods.transferFrom(targetNftTokenAddress, owner, secondTokenId).send({from: owner});
expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(owner);
});
-
+
+ itEth('NFT: collectionNestingRestrictedCollectionIds()', async ({helper}) => {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionId: unnestedCollsectionId, collectionAddress: unnsetedCollectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
+ const unnestedContract = helper.ethNativeContract.collection(unnsetedCollectionAddress, 'nft', owner);
+ expect(await unnestedContract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([false, []]);
+
+ const {contract} = await createNestingCollection(helper, owner);
+ expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, []]);
+ await contract.methods.setCollectionNesting(true, [unnsetedCollectionAddress]).send({from: owner});
+ expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, [unnestedCollsectionId.toString()]]);
+
+ });
+
itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);