git.delta.rocks / unique-network / refs/commits / 5223dbed88c4

difftreelog

added `collectionNestingRestrictedCollectionIds()` function in `Collection` interface.

PraetorP2022-12-02parent: #46e50c0.patch.diff
in: master

14 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
493 <Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)493 <Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)
494 }494 }
495
496 /// Returns nesting for a collection
497 #[solidity(rename_selector = "collectionNestingRestrictedCollectionIds")]
498 fn collection_nesting_restricted_ids(&self) -> Result<(bool, Vec<uint256>)> {
499 let nesting = self.collection.permissions.nesting();
500
501 Ok((
502 nesting.token_owner,
503 nesting
504 .restricted
505 .clone()
506 .map(|b| b.0.into_inner().iter().map(|id| id.0.into()).collect())
507 .unwrap_or_default(),
508 ))
509 }
495510
496 /// Set the collection access method.511 /// Set the collection access method.
497 /// @param mode Access mode512 /// @param mode Access mode
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

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 0xcc1d80ca21/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
22contract Collection is Dummy, ERC165 {22contract Collection is Dummy, ERC165 {
23 // /// Set collection property.23 // /// Set collection property.
24 // ///24 // ///
254 dummy = 0;254 dummy = 0;
255 }255 }
256
257 /// Returns nesting for a collection
258 /// @dev EVM selector for this function is: 0x22d25bfe,
259 /// or in textual repr: collectionNestingRestrictedCollectionIds()
260 function collectionNestingRestrictedCollectionIds() public view returns (Tuple21 memory) {
261 require(false, stub_error);
262 dummy;
263 return Tuple21(false, new uint256[](0));
264 }
256265
257 /// Set the collection access method.266 /// Set the collection access method.
258 /// @param mode Access mode267 /// @param mode Access mode
425 uint256 sub;434 uint256 sub;
426}435}
436
437/// @dev anonymous struct
438struct Tuple21 {
439 bool field_0;
440 uint256[] field_1;
441}
427442
428/// @dev Property struct443/// @dev Property struct
429struct Property {444struct Property {
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 0xcc1d80ca122/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
123contract 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 }
357
358 /// Returns nesting for a collection
359 /// @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 }
357366
358 /// Set the collection access method.367 /// Set the collection access method.
359 /// @param mode Access mode368 /// @param mode Access mode
526 uint256 sub;535 uint256 sub;
527}536}
537
538/// @dev anonymous struct
539struct Tuple34 {
540 bool field_0;
541 uint256[] field_1;
542}
528543
529/// @dev anonymous struct544/// @dev anonymous struct
530struct Tuple30 {545struct Tuple30 {
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 0xcc1d80ca122/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
123contract 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 }
357
358 /// Returns nesting for a collection
359 /// @dev EVM selector for this function is: 0x22d25bfe,
360 /// or in textual repr: collectionNestingRestrictedCollectionIds()
361 function collectionNestingRestrictedCollectionIds() public view returns (Tuple33 memory) {
362 require(false, stub_error);
363 dummy;
364 return Tuple33(false, new uint256[](0));
365 }
357366
358 /// Set the collection access method.367 /// Set the collection access method.
359 /// @param mode Access mode368 /// @param mode Access mode
526 uint256 sub;535 uint256 sub;
527}536}
537
538/// @dev anonymous struct
539struct Tuple33 {
540 bool field_0;
541 uint256[] field_1;
542}
528543
529/// @dev anonymous struct544/// @dev anonymous struct
530struct Tuple29 {545struct Tuple29 {
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

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": "collectionNestingRestrictedCollectionIds",
212 "outputs": [
213 {
214 "components": [
215 { "internalType": "bool", "name": "field_0", "type": "bool" },
216 {
217 "internalType": "uint256[]",
218 "name": "field_1",
219 "type": "uint256[]"
220 }
221 ],
222 "internalType": "struct Tuple21",
223 "name": "",
224 "type": "tuple"
225 }
226 ],
227 "stateMutability": "view",
228 "type": "function"
229 },
209 {230 {
210 "inputs": [],231 "inputs": [],
211 "name": "collectionOwner",232 "name": "collectionOwner",
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": "collectionNestingRestrictedCollectionIds",
242 "outputs": [
243 {
244 "components": [
245 { "internalType": "bool", "name": "field_0", "type": "bool" },
246 {
247 "internalType": "uint256[]",
248 "name": "field_1",
249 "type": "uint256[]"
250 }
251 ],
252 "internalType": "struct Tuple34",
253 "name": "",
254 "type": "tuple"
255 }
256 ],
257 "stateMutability": "view",
258 "type": "function"
259 },
239 {260 {
240 "inputs": [],261 "inputs": [],
241 "name": "collectionOwner",262 "name": "collectionOwner",
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": "collectionNestingRestrictedCollectionIds",
224 "outputs": [
225 {
226 "components": [
227 { "internalType": "bool", "name": "field_0", "type": "bool" },
228 {
229 "internalType": "uint256[]",
230 "name": "field_1",
231 "type": "uint256[]"
232 }
233 ],
234 "internalType": "struct Tuple33",
235 "name": "",
236 "type": "tuple"
237 }
238 ],
239 "stateMutability": "view",
240 "type": "function"
241 },
221 {242 {
222 "inputs": [],243 "inputs": [],
223 "name": "collectionOwner",244 "name": "collectionOwner",
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 0xcc1d80ca16/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
17interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {
18 // /// Set collection property.18 // /// Set collection property.
19 // ///19 // ///
166 /// or in textual repr: setCollectionNesting(bool,address[])166 /// or in textual repr: setCollectionNesting(bool,address[])
167 function setCollectionNesting(bool enable, address[] memory collections) external;167 function setCollectionNesting(bool enable, address[] memory collections) external;
168
169 /// Returns nesting for a collection
170 /// @dev EVM selector for this function is: 0x22d25bfe,
171 /// or in textual repr: collectionNestingRestrictedCollectionIds()
172 function collectionNestingRestrictedCollectionIds() external view returns (Tuple20 memory);
168173
169 /// Set the collection access method.174 /// Set the collection access method.
170 /// @param mode Access mode175 /// @param mode Access mode
278 uint256 sub;283 uint256 sub;
279}284}
285
286/// @dev anonymous struct
287struct Tuple20 {
288 bool field_0;
289 uint256[] field_1;
290}
280291
281/// @dev Property struct292/// @dev Property struct
282struct Property {293struct Property {
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 0xcc1d80ca83/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
84interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {
85 // /// Set collection property.85 // /// Set collection property.
86 // ///86 // ///
233 /// or in textual repr: setCollectionNesting(bool,address[])233 /// or in textual repr: setCollectionNesting(bool,address[])
234 function setCollectionNesting(bool enable, address[] memory collections) external;234 function setCollectionNesting(bool enable, address[] memory collections) external;
235
236 /// Returns nesting for a collection
237 /// @dev EVM selector for this function is: 0x22d25bfe,
238 /// or in textual repr: collectionNestingRestrictedCollectionIds()
239 function collectionNestingRestrictedCollectionIds() external view returns (Tuple31 memory);
235240
236 /// Set the collection access method.241 /// Set the collection access method.
237 /// @param mode Access mode242 /// @param mode Access mode
345 uint256 sub;350 uint256 sub;
346}351}
352
353/// @dev anonymous struct
354struct Tuple31 {
355 bool field_0;
356 uint256[] field_1;
357}
347358
348/// @dev anonymous struct359/// @dev anonymous struct
349struct Tuple27 {360struct Tuple27 {
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 0xcc1d80ca83/// @dev the ERC-165 identifier for this interface is 0xeecfdb34
84interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {
85 // /// Set collection property.85 // /// Set collection property.
86 // ///86 // ///
233 /// or in textual repr: setCollectionNesting(bool,address[])233 /// or in textual repr: setCollectionNesting(bool,address[])
234 function setCollectionNesting(bool enable, address[] memory collections) external;234 function setCollectionNesting(bool enable, address[] memory collections) external;
235
236 /// Returns nesting for a collection
237 /// @dev EVM selector for this function is: 0x22d25bfe,
238 /// or in textual repr: collectionNestingRestrictedCollectionIds()
239 function collectionNestingRestrictedCollectionIds() external view returns (Tuple30 memory);
235240
236 /// Set the collection access method.241 /// Set the collection access method.
237 /// @param mode Access mode242 /// @param mode Access mode
345 uint256 sub;350 uint256 sub;
346}351}
352
353/// @dev anonymous struct
354struct Tuple30 {
355 bool field_0;
356 uint256[] field_1;
357}
347358
348/// @dev anonymous struct359/// @dev anonymous struct
349struct Tuple26 {360struct Tuple26 {
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 });
5454
55 itEth('NFT: collectionNestingRestrictedCollectionIds()', async ({helper}) => {
56 const owner = await helper.eth.createAccountWithBalance(donor);
57 const {collectionId: unnestedCollsectionId, collectionAddress: unnsetedCollectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
58 const unnestedContract = helper.ethNativeContract.collection(unnsetedCollectionAddress, 'nft', owner);
59 expect(await unnestedContract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([false, []]);
60
61 const {contract} = await createNestingCollection(helper, owner);
62 expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, []]);
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()]]);
65
66 });
67
55 itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {68 itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
56 const owner = await helper.eth.createAccountWithBalance(donor);69 const owner = await helper.eth.createAccountWithBalance(donor);