git.delta.rocks / unique-network / refs/commits / ba711a7b1711

difftreelog

added `collectionNestingPermissions` funtion in `Collection` interface

PraetorP2022-12-06parent: #5223dbe.patch.diff
in: master

13 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
26 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 }
510512
513 /// Returns permissions for a collection
514 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 mode
513 /// 0 for Normal523 /// 0 for Normal
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
155 }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}
158165
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
18}18}
1919
20/// @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 0xb5e1747f
22contract 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 }
265
266 /// Returns permissions for a collection
267 /// @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 }
265274
266 /// Set the collection access method.275 /// Set the collection access method.
267 /// @param mode Access mode276 /// @param mode Access mode
434 uint256 sub;443 uint256 sub;
435}444}
445
446enum CollectionPermissions {
447 CollectionAdmin,
448 TokenOwner
449}
450
451/// @dev anonymous struct
452struct Tuple24 {
453 CollectionPermissions field_0;
454 bool field_1;
455}
436456
437/// @dev anonymous struct457/// @dev anonymous struct
438struct Tuple21 {458struct Tuple21 {
modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
119}119}
120120
121/// @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 0xb5e1747f
123contract 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 }
366
367 /// Returns permissions for a collection
368 /// @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 }
366375
367 /// Set the collection access method.376 /// Set the collection access method.
368 /// @param mode Access mode377 /// @param mode Access mode
535 uint256 sub;544 uint256 sub;
536}545}
546
547enum CollectionPermissions {
548 CollectionAdmin,
549 TokenOwner
550}
551
552/// @dev anonymous struct
553struct Tuple37 {
554 CollectionPermissions field_0;
555 bool field_1;
556}
537557
538/// @dev anonymous struct558/// @dev anonymous struct
539struct Tuple34 {559struct Tuple34 {
modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
119}119}
120120
121/// @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 0xb5e1747f
123contract 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 }
366
367 /// Returns permissions for a collection
368 /// @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 }
366375
367 /// Set the collection access method.376 /// Set the collection access method.
368 /// @param mode Access mode377 /// @param mode Access mode
535 uint256 sub;544 uint256 sub;
536}545}
546
547enum CollectionPermissions {
548 CollectionAdmin,
549 TokenOwner
550}
551
552/// @dev anonymous struct
553struct Tuple36 {
554 CollectionPermissions field_0;
555 bool field_1;
556}
537557
538/// @dev anonymous struct558/// @dev anonymous struct
539struct Tuple33 {559struct Tuple33 {
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
206 "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",
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
236 "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",
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
218 "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",
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
13}13}
1414
15/// @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 0xb5e1747f
17interface 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);
173
174 /// Returns permissions for a collection
175 /// @dev EVM selector for this function is: 0x5b2eaf4b,
176 /// or in textual repr: collectionNestingPermissions()
177 function collectionNestingPermissions() external view returns (Tuple23[] memory);
173178
174 /// Set the collection access method.179 /// Set the collection access method.
175 /// @param mode Access mode180 /// @param mode Access mode
283 uint256 sub;288 uint256 sub;
284}289}
290
291/// @dev anonymous struct
292struct Tuple23 {
293 CollectionPermissions field_0;
294 bool field_1;
295}
296
297enum CollectionPermissions {
298 CollectionAdmin,
299 TokenOwner
300}
285301
286/// @dev anonymous struct302/// @dev anonymous struct
287struct Tuple20 {303struct Tuple20 {
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
80}80}
8181
82/// @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 0xb5e1747f
84interface 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);
240
241 /// Returns permissions for a collection
242 /// @dev EVM selector for this function is: 0x5b2eaf4b,
243 /// or in textual repr: collectionNestingPermissions()
244 function collectionNestingPermissions() external view returns (Tuple34[] memory);
240245
241 /// Set the collection access method.246 /// Set the collection access method.
242 /// @param mode Access mode247 /// @param mode Access mode
350 uint256 sub;355 uint256 sub;
351}356}
357
358/// @dev anonymous struct
359struct Tuple34 {
360 CollectionPermissions field_0;
361 bool field_1;
362}
363
364enum CollectionPermissions {
365 CollectionAdmin,
366 TokenOwner
367}
352368
353/// @dev anonymous struct369/// @dev anonymous struct
354struct Tuple31 {370struct Tuple31 {
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
80}80}
8181
82/// @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 0xb5e1747f
84interface 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);
240
241 /// Returns permissions for a collection
242 /// @dev EVM selector for this function is: 0x5b2eaf4b,
243 /// or in textual repr: collectionNestingPermissions()
244 function collectionNestingPermissions() external view returns (Tuple33[] memory);
240245
241 /// Set the collection access method.246 /// Set the collection access method.
242 /// @param mode Access mode247 /// @param mode Access mode
350 uint256 sub;355 uint256 sub;
351}356}
357
358/// @dev anonymous struct
359struct Tuple33 {
360 CollectionPermissions field_0;
361 bool field_1;
362}
363
364enum CollectionPermissions {
365 CollectionAdmin,
366 TokenOwner
367}
352368
353/// @dev anonymous struct369/// @dev anonymous struct
354struct Tuple30 {370struct Tuple30 {
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
52 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}) => {