difftreelog
added `collectionNestingPermissions` funtion in `Collection` interface
in: master
13 files changed
pallets/common/src/erc.rsdiffbeforeafterboth26 weight,26 weight,27};27};28use pallet_evm_coder_substrate::dispatch_to_evm;28use pallet_evm_coder_substrate::dispatch_to_evm;29use sp_std::vec::Vec;29use sp_std::{vec, vec::Vec};30use up_data_structs::{30use up_data_structs::{31 AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,31 AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,32 SponsoringRateLimit, SponsorshipState,32 SponsoringRateLimit, SponsorshipState,36use crate::{36use crate::{37 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,37 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,38 eth::{EthCrossAccount, convert_cross_account_to_uint256},38 eth::{39 EthCrossAccount, convert_cross_account_to_uint256, CollectionPermissions as EvmPermissions,40 },39 weights::WeightInfo,41 weights::WeightInfo,40};42};508 ))510 ))509 }511 }510512513 /// Returns permissions for a collection514 fn collection_nesting_permissions(&self) -> Result<Vec<(EvmPermissions, bool)>> {515 let nesting = self.collection.permissions.nesting();516 Ok(vec![517 (EvmPermissions::CollectionAdmin, nesting.collection_admin),518 (EvmPermissions::TokenOwner, nesting.token_owner),519 ])520 }511 /// Set the collection access method.521 /// Set the collection access method.512 /// @param mode Access mode522 /// @param mode Access mode513 /// 0 for Normal523 /// 0 for Normalpallets/common/src/eth.rsdiffbeforeafterboth155 }155 }156 }156 }157}157}158#[derive(Default, Debug, Clone, Copy, AbiCoder)]159#[repr(u8)]160pub enum CollectionPermissions {161 #[default]162 CollectionAdmin,163 TokenOwner,164}158165pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth18}18}191920/// @title A contract that allows you to work with collections.20/// @title A contract that allows you to work with collections.21/// @dev the ERC-165 identifier for this interface is 0xeecfdb3421/// @dev the ERC-165 identifier for this interface is 0xb5e1747f22contract Collection is Dummy, ERC165 {22contract Collection is Dummy, ERC165 {23 // /// Set collection property.23 // /// Set collection property.24 // ///24 // ///263 return Tuple21(false, new uint256[](0));263 return Tuple21(false, new uint256[](0));264 }264 }265266 /// Returns permissions for a collection267 /// @dev EVM selector for this function is: 0x5b2eaf4b,268 /// or in textual repr: collectionNestingPermissions()269 function collectionNestingPermissions() public view returns (Tuple24[] memory) {270 require(false, stub_error);271 dummy;272 return new Tuple24[](0);273 }265274266 /// Set the collection access method.275 /// Set the collection access method.267 /// @param mode Access mode276 /// @param mode Access mode434 uint256 sub;443 uint256 sub;435}444}445446enum CollectionPermissions {447 CollectionAdmin,448 TokenOwner449}450451/// @dev anonymous struct452struct Tuple24 {453 CollectionPermissions field_0;454 bool field_1;455}436456437/// @dev anonymous struct457/// @dev anonymous struct438struct Tuple21 {458struct Tuple21 {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 0xeecfdb34122/// @dev the ERC-165 identifier for this interface is 0xb5e1747f123contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {124 // /// Set collection property.124 // /// Set collection property.125 // ///125 // ///364 return Tuple34(false, new uint256[](0));364 return Tuple34(false, new uint256[](0));365 }365 }366367 /// Returns permissions for a collection368 /// @dev EVM selector for this function is: 0x5b2eaf4b,369 /// or in textual repr: collectionNestingPermissions()370 function collectionNestingPermissions() public view returns (Tuple37[] memory) {371 require(false, stub_error);372 dummy;373 return new Tuple37[](0);374 }366375367 /// Set the collection access method.376 /// Set the collection access method.368 /// @param mode Access mode377 /// @param mode Access mode535 uint256 sub;544 uint256 sub;536}545}546547enum CollectionPermissions {548 CollectionAdmin,549 TokenOwner550}551552/// @dev anonymous struct553struct Tuple37 {554 CollectionPermissions field_0;555 bool field_1;556}537557538/// @dev anonymous struct558/// @dev anonymous struct539struct Tuple34 {559struct Tuple34 {pallets/refungible/src/stubs/UniqueRefungible.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 0xeecfdb34122/// @dev the ERC-165 identifier for this interface is 0xb5e1747f123contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {124 // /// Set collection property.124 // /// Set collection property.125 // ///125 // ///364 return Tuple33(false, new uint256[](0));364 return Tuple33(false, new uint256[](0));365 }365 }366367 /// Returns permissions for a collection368 /// @dev EVM selector for this function is: 0x5b2eaf4b,369 /// or in textual repr: collectionNestingPermissions()370 function collectionNestingPermissions() public view returns (Tuple36[] memory) {371 require(false, stub_error);372 dummy;373 return new Tuple36[](0);374 }366375367 /// Set the collection access method.376 /// Set the collection access method.368 /// @param mode Access mode377 /// @param mode Access mode535 uint256 sub;544 uint256 sub;536}545}546547enum CollectionPermissions {548 CollectionAdmin,549 TokenOwner550}551552/// @dev anonymous struct553struct Tuple36 {554 CollectionPermissions field_0;555 bool field_1;556}537557538/// @dev anonymous struct558/// @dev anonymous struct539struct Tuple33 {559struct Tuple33 {tests/src/eth/abi/fungible.jsondiffbeforeafterboth206 "stateMutability": "view",206 "stateMutability": "view",207 "type": "function"207 "type": "function"208 },208 },209 {210 "inputs": [],211 "name": "collectionNestingPermissions",212 "outputs": [213 {214 "components": [215 {216 "internalType": "enum CollectionPermissions",217 "name": "field_0",218 "type": "uint8"219 },220 { "internalType": "bool", "name": "field_1", "type": "bool" }221 ],222 "internalType": "struct Tuple24[]",223 "name": "",224 "type": "tuple[]"225 }226 ],227 "stateMutability": "view",228 "type": "function"229 },209 {230 {210 "inputs": [],231 "inputs": [],211 "name": "collectionNestingRestrictedCollectionIds",232 "name": "collectionNestingRestrictedCollectionIds",tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth236 "stateMutability": "view",236 "stateMutability": "view",237 "type": "function"237 "type": "function"238 },238 },239 {240 "inputs": [],241 "name": "collectionNestingPermissions",242 "outputs": [243 {244 "components": [245 {246 "internalType": "enum CollectionPermissions",247 "name": "field_0",248 "type": "uint8"249 },250 { "internalType": "bool", "name": "field_1", "type": "bool" }251 ],252 "internalType": "struct Tuple37[]",253 "name": "",254 "type": "tuple[]"255 }256 ],257 "stateMutability": "view",258 "type": "function"259 },239 {260 {240 "inputs": [],261 "inputs": [],241 "name": "collectionNestingRestrictedCollectionIds",262 "name": "collectionNestingRestrictedCollectionIds",tests/src/eth/abi/reFungible.jsondiffbeforeafterboth218 "stateMutability": "view",218 "stateMutability": "view",219 "type": "function"219 "type": "function"220 },220 },221 {222 "inputs": [],223 "name": "collectionNestingPermissions",224 "outputs": [225 {226 "components": [227 {228 "internalType": "enum CollectionPermissions",229 "name": "field_0",230 "type": "uint8"231 },232 { "internalType": "bool", "name": "field_1", "type": "bool" }233 ],234 "internalType": "struct Tuple36[]",235 "name": "",236 "type": "tuple[]"237 }238 ],239 "stateMutability": "view",240 "type": "function"241 },221 {242 {222 "inputs": [],243 "inputs": [],223 "name": "collectionNestingRestrictedCollectionIds",244 "name": "collectionNestingRestrictedCollectionIds",tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth13}13}141415/// @title A contract that allows you to work with collections.15/// @title A contract that allows you to work with collections.16/// @dev the ERC-165 identifier for this interface is 0xeecfdb3416/// @dev the ERC-165 identifier for this interface is 0xb5e1747f17interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {18 // /// Set collection property.18 // /// Set collection property.19 // ///19 // ///171 /// or in textual repr: collectionNestingRestrictedCollectionIds()171 /// or in textual repr: collectionNestingRestrictedCollectionIds()172 function collectionNestingRestrictedCollectionIds() external view returns (Tuple20 memory);172 function collectionNestingRestrictedCollectionIds() external view returns (Tuple20 memory);173174 /// Returns permissions for a collection175 /// @dev EVM selector for this function is: 0x5b2eaf4b,176 /// or in textual repr: collectionNestingPermissions()177 function collectionNestingPermissions() external view returns (Tuple23[] memory);173178174 /// Set the collection access method.179 /// Set the collection access method.175 /// @param mode Access mode180 /// @param mode Access mode283 uint256 sub;288 uint256 sub;284}289}290291/// @dev anonymous struct292struct Tuple23 {293 CollectionPermissions field_0;294 bool field_1;295}296297enum CollectionPermissions {298 CollectionAdmin,299 TokenOwner300}285301286/// @dev anonymous struct302/// @dev anonymous struct287struct Tuple20 {303struct Tuple20 {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.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 (Tuple30 memory);239 function collectionNestingRestrictedCollectionIds() external view returns (Tuple30 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 (Tuple33[] 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 Tuple33 {360 CollectionPermissions field_0;361 bool field_1;362}363364enum CollectionPermissions {365 CollectionAdmin,366 TokenOwner367}352368353/// @dev anonymous struct369/// @dev anonymous struct354struct Tuple30 {370struct Tuple30 {tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth52 expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(owner);52 expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(owner);53 });53 });54 54 55 itEth('NFT: collectionNestingRestrictedCollectionIds()', async ({helper}) => {55 itEth('NFT: collectionNestingRestrictedCollectionIds() & collectionNestingPermissions', async ({helper}) => {56 const owner = await helper.eth.createAccountWithBalance(donor);56 const owner = await helper.eth.createAccountWithBalance(donor);57 const {collectionId: unnestedCollsectionId, collectionAddress: unnsetedCollectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');57 const {collectionId: unnestedCollsectionId, collectionAddress: unnsetedCollectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');58 const unnestedContract = helper.ethNativeContract.collection(unnsetedCollectionAddress, 'nft', owner);58 const unnestedContract = helper.ethNativeContract.collection(unnsetedCollectionAddress, 'nft', owner);62 expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, []]);62 expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, []]);63 await contract.methods.setCollectionNesting(true, [unnsetedCollectionAddress]).send({from: owner});63 await contract.methods.setCollectionNesting(true, [unnsetedCollectionAddress]).send({from: owner});64 expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, [unnestedCollsectionId.toString()]]);64 expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, [unnestedCollsectionId.toString()]]);65 65 expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['0', false], ['1', true]]);66 await contract.methods.setCollectionNesting(false).send({from: owner});67 expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['0', false], ['1', false]]);66 });68 });67 69 68 itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {70 itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {