difftreelog
added `collectionNestingPermissions` funtion in `Collection` interface
in: master
13 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -26,7 +26,7 @@
weight,
};
use pallet_evm_coder_substrate::dispatch_to_evm;
-use sp_std::vec::Vec;
+use sp_std::{vec, vec::Vec};
use up_data_structs::{
AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,
SponsoringRateLimit, SponsorshipState,
@@ -35,7 +35,9 @@
use crate::{
Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
- eth::{EthCrossAccount, convert_cross_account_to_uint256},
+ eth::{
+ EthCrossAccount, convert_cross_account_to_uint256, CollectionPermissions as EvmPermissions,
+ },
weights::WeightInfo,
};
@@ -508,6 +510,14 @@
))
}
+ /// Returns permissions for a collection
+ fn collection_nesting_permissions(&self) -> Result<Vec<(EvmPermissions, bool)>> {
+ let nesting = self.collection.permissions.nesting();
+ Ok(vec![
+ (EvmPermissions::CollectionAdmin, nesting.collection_admin),
+ (EvmPermissions::TokenOwner, nesting.token_owner),
+ ])
+ }
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -155,3 +155,10 @@
}
}
}
+#[derive(Default, Debug, Clone, Copy, AbiCoder)]
+#[repr(u8)]
+pub enum CollectionPermissions {
+ #[default]
+ CollectionAdmin,
+ TokenOwner,
+}
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 0xeecfdb34
+/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -263,6 +263,15 @@
return Tuple21(false, new uint256[](0));
}
+ /// Returns permissions for a collection
+ /// @dev EVM selector for this function is: 0x5b2eaf4b,
+ /// or in textual repr: collectionNestingPermissions()
+ function collectionNestingPermissions() public view returns (Tuple24[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple24[](0);
+ }
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -434,6 +443,17 @@
uint256 sub;
}
+enum CollectionPermissions {
+ CollectionAdmin,
+ TokenOwner
+}
+
+/// @dev anonymous struct
+struct Tuple24 {
+ CollectionPermissions field_0;
+ bool field_1;
+}
+
/// @dev anonymous struct
struct Tuple21 {
bool field_0;
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -119,7 +119,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
+/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -364,6 +364,15 @@
return Tuple34(false, new uint256[](0));
}
+ /// Returns permissions for a collection
+ /// @dev EVM selector for this function is: 0x5b2eaf4b,
+ /// or in textual repr: collectionNestingPermissions()
+ function collectionNestingPermissions() public view returns (Tuple37[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple37[](0);
+ }
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -535,6 +544,17 @@
uint256 sub;
}
+enum CollectionPermissions {
+ CollectionAdmin,
+ TokenOwner
+}
+
+/// @dev anonymous struct
+struct Tuple37 {
+ CollectionPermissions field_0;
+ bool field_1;
+}
+
/// @dev anonymous struct
struct Tuple34 {
bool field_0;
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 0xeecfdb34
+/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -364,6 +364,15 @@
return Tuple33(false, new uint256[](0));
}
+ /// Returns permissions for a collection
+ /// @dev EVM selector for this function is: 0x5b2eaf4b,
+ /// or in textual repr: collectionNestingPermissions()
+ function collectionNestingPermissions() public view returns (Tuple36[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple36[](0);
+ }
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -535,6 +544,17 @@
uint256 sub;
}
+enum CollectionPermissions {
+ CollectionAdmin,
+ TokenOwner
+}
+
+/// @dev anonymous struct
+struct Tuple36 {
+ CollectionPermissions field_0;
+ bool field_1;
+}
+
/// @dev anonymous struct
struct Tuple33 {
bool field_0;
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": "collectionNestingPermissions",
+ "outputs": [
+ {
+ "components": [
+ {
+ "internalType": "enum CollectionPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple24[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionNestingRestrictedCollectionIds",
"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": "collectionNestingPermissions",
+ "outputs": [
+ {
+ "components": [
+ {
+ "internalType": "enum CollectionPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple37[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionNestingRestrictedCollectionIds",
"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": "collectionNestingPermissions",
+ "outputs": [
+ {
+ "components": [
+ {
+ "internalType": "enum CollectionPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple36[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionNestingRestrictedCollectionIds",
"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 0xeecfdb34
+/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -171,6 +171,11 @@
/// or in textual repr: collectionNestingRestrictedCollectionIds()
function collectionNestingRestrictedCollectionIds() external view returns (Tuple20 memory);
+ /// Returns permissions for a collection
+ /// @dev EVM selector for this function is: 0x5b2eaf4b,
+ /// or in textual repr: collectionNestingPermissions()
+ function collectionNestingPermissions() external view returns (Tuple23[] memory);
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -284,6 +289,17 @@
}
/// @dev anonymous struct
+struct Tuple23 {
+ CollectionPermissions field_0;
+ bool field_1;
+}
+
+enum CollectionPermissions {
+ CollectionAdmin,
+ TokenOwner
+}
+
+/// @dev anonymous struct
struct Tuple20 {
bool field_0;
uint256[] field_1;
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth80}80}818182/// @title A contract that allows you to work with collections.82/// @title A contract that allows you to work with collections.83/// @dev the ERC-165 identifier for this interface is 0xeecfdb3483/// @dev the ERC-165 identifier for this interface is 0xb5e1747f84interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {85 // /// Set collection property.85 // /// Set collection property.86 // ///86 // ///238 /// or in textual repr: collectionNestingRestrictedCollectionIds()238 /// or in textual repr: collectionNestingRestrictedCollectionIds()239 function collectionNestingRestrictedCollectionIds() external view returns (Tuple31 memory);239 function collectionNestingRestrictedCollectionIds() external view returns (Tuple31 memory);240241 /// Returns permissions for a collection242 /// @dev EVM selector for this function is: 0x5b2eaf4b,243 /// or in textual repr: collectionNestingPermissions()244 function collectionNestingPermissions() external view returns (Tuple34[] memory);240245241 /// Set the collection access method.246 /// Set the collection access method.242 /// @param mode Access mode247 /// @param mode Access mode350 uint256 sub;355 uint256 sub;351}356}357358/// @dev anonymous struct359struct Tuple34 {360 CollectionPermissions field_0;361 bool field_1;362}363364enum CollectionPermissions {365 CollectionAdmin,366 TokenOwner367}352368353/// @dev anonymous struct369/// @dev anonymous struct354struct Tuple31 {370struct Tuple31 {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 0xeecfdb34
+/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -238,6 +238,11 @@
/// or in textual repr: collectionNestingRestrictedCollectionIds()
function collectionNestingRestrictedCollectionIds() external view returns (Tuple30 memory);
+ /// Returns permissions for a collection
+ /// @dev EVM selector for this function is: 0x5b2eaf4b,
+ /// or in textual repr: collectionNestingPermissions()
+ function collectionNestingPermissions() external view returns (Tuple33[] memory);
+
/// Set the collection access method.
/// @param mode Access mode
/// 0 for Normal
@@ -351,6 +356,17 @@
}
/// @dev anonymous struct
+struct Tuple33 {
+ CollectionPermissions field_0;
+ bool field_1;
+}
+
+enum CollectionPermissions {
+ CollectionAdmin,
+ TokenOwner
+}
+
+/// @dev anonymous struct
struct Tuple30 {
bool 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
@@ -52,7 +52,7 @@
expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(owner);
});
- itEth('NFT: collectionNestingRestrictedCollectionIds()', async ({helper}) => {
+ itEth('NFT: collectionNestingRestrictedCollectionIds() & collectionNestingPermissions', 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);
@@ -62,7 +62,9 @@
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()]]);
-
+ expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['0', false], ['1', true]]);
+ await contract.methods.setCollectionNesting(false).send({from: owner});
+ expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['0', false], ['1', false]]);
});
itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {