git.delta.rocks / unique-network / refs/commits / 73c74cbad5e3

difftreelog

added `destroyCollection`method to `CollectionHelpers`

PraetorP2022-10-24parent: #afa26fc.patch.diff
in: master

10 files changed

modifiedCargo.lockdiffbeforeafterboth
67996799
6800[[package]]6800[[package]]
6801name = "pallet-unique"6801name = "pallet-unique"
6802version = "0.2.0"6802version = "0.2.1"
6803dependencies = [6803dependencies = [
6804 "ethereum",6804 "ethereum",
6805 "evm-coder",6805 "evm-coder",
modifiedpallets/unique/CHANGELOG.mddiffbeforeafterboth
44
5<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->
66
7## [v0.2.1] 2022-10-10
8
9### Changes
10
11- Addded **CollectionHelpers** method `destroyCollection`.
12
7## [v0.2.0] 2022-09-1313## [v0.2.0] 2022-09-13
814
9### Changes15### Changes
16
10- Change **collectionHelper** method `createRefungibleCollection` to `createRFTCollection`,17- Change **collectionHelper** method `createRefungibleCollection` to `createRFTCollection`,
1118
12## [v0.1.4] 2022-09-0519## [v0.1.4] 2022-09-05
1320
14### Added21### Added
1522
16- Methods `force_set_sponsor` , `force_remove_collection_sponsor` to be able to administer sponsorships with other pallets. Added to implement `AppPromotion` pallet logic.23- Methods `force_set_sponsor` , `force_remove_collection_sponsor` to be able to administer sponsorships with other pallets. Added to implement `AppPromotion` pallet logic.
1724
18## [v0.1.3] 2022-08-1625## [v0.1.3] 2022-08-16
1926
20### Other changes27### Other changes
2128
22- build: Upgrade polkadot to v0.9.27 2c498572636f2b34d53b1c51b7283a761a7dc90a29- build: Upgrade polkadot to v0.9.27 2c498572636f2b34d53b1c51b7283a761a7dc90a
2330
24- build: Upgrade polkadot to v0.9.26 85515e54c4ca1b82a2630034e55dcc804c643bf831- build: Upgrade polkadot to v0.9.26 85515e54c4ca1b82a2630034e55dcc804c643bf8
2532
26- refactor: Remove `#[transactional]` from extrinsics 7fd36cea2f6e00c02c67ccc1de9649ae404efd3133- refactor: Remove `#[transactional]` from extrinsics 7fd36cea2f6e00c02c67ccc1de9649ae404efd31
2734
28Every extrinsic now runs in transaction implicitly, and35Every extrinsic now runs in transaction implicitly, and
29`#[transactional]` on pallet dispatchable is now meaningless36`#[transactional]` on pallet dispatchable is now meaningless
3037
31Upstream-Change: https://github.com/paritytech/substrate/issues/1080638Upstream-Change: https://github.com/paritytech/substrate/issues/10806
3239
33- refactor: Switch to new prefix removal methods 26734e9567589d75cdd99e404eabf11d5a97d97540- refactor: Switch to new prefix removal methods 26734e9567589d75cdd99e404eabf11d5a97d975
3441
35New methods allows to call `remove_prefix` with limit multiple times42New methods allows to call `remove_prefix` with limit multiple times
36in the same block43in the same block
3946
40Upstream-Change: https://github.com/paritytech/substrate/pull/1149047Upstream-Change: https://github.com/paritytech/substrate/pull/11490
4148
42- build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b49- build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b
4350
44## [v0.1.1] - 2022-07-2551## [v0.1.1] - 2022-07-25
4552
46### Added53### Added
4754
48- Method for creating `ERC721Metadata` compatible NFT collection.55- Method for creating `ERC721Metadata` compatible NFT collection.
49- Method for creating `ERC721Metadata` compatible ReFungible collection.56- Method for creating `ERC721Metadata` compatible ReFungible collection.
50- Method for creating ReFungible collection.57- Method for creating ReFungible collection.
5158
modifiedpallets/unique/Cargo.tomldiffbeforeafterboth
9license = 'GPLv3'9license = 'GPLv3'
10name = 'pallet-unique'10name = 'pallet-unique'
11repository = 'https://github.com/UniqueNetwork/unique-chain'11repository = 'https://github.com/UniqueNetwork/unique-chain'
12version = "0.2.0"12version = "0.2.1"
1313
14[package.metadata.docs.rs]14[package.metadata.docs.rs]
15targets = ['x86_64-unknown-linux-gnu']15targets = ['x86_64-unknown-linux-gnu']
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
19use core::marker::PhantomData;19use core::marker::PhantomData;
20use ethereum as _;20use ethereum as _;
21use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};21use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};
22use frame_support::traits::Get;22use frame_support::{traits::Get, storage::StorageNMap};
23
24use crate::sp_api_hidden_includes_decl_storage::hidden_include::StorageDoubleMap;
23use pallet_common::{25use pallet_common::{
24 CollectionById,26 CollectionById,
25 dispatch::CollectionDispatch,27 dispatch::CollectionDispatch,
38};40};
3941
40use crate::{Config, SelfWeightOf, weights::WeightInfo};42use crate::{
43 Config, SelfWeightOf, weights::WeightInfo, NftTransferBasket, FungibleTransferBasket,
44 ReFungibleTransferBasket, NftApproveBasket, FungibleApproveBasket, RefungibleApproveBasket,
45};
4146
42use sp_std::vec::Vec;47use sp_std::vec::Vec;
296 Ok(())301 Ok(())
297 }302 }
303
304 #[weight(<SelfWeightOf<T>>::destroy_collection())]
305 #[solidity(rename_selector = "destroyCollection")]
306 fn destroy_collection(&mut self, caller: caller, collection_address: address) -> Result<void> {
307 let caller = T::CrossAccountId::from_eth(caller);
308 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)
309 .ok_or("Invalid collection address format".into())
310 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
311 let collection = <pallet_common::CollectionHandle<T>>::try_get(collection_id)
312 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
313 collection
314 .check_is_internal()
315 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
316
317 T::CollectionDispatch::destroy(caller, collection)
318 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
319
320 let _ = <NftTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);
321 let _ = <FungibleTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);
322 let _ = <ReFungibleTransferBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);
323
324 let _ = <NftApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);
325 let _ = <FungibleApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);
326 let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);
327
328 Ok(())
329 }
298330
299 /// Check if a collection exists331 /// Check if a collection exists
300 /// @param collectionAddress Address of the collection in question332 /// @param collectionAddress Address of the collection in question
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
23}23}
2424
25/// @title Contract, which allows users to operate with collections25/// @title Contract, which allows users to operate with collections
26/// @dev the ERC-165 identifier for this interface is 0x5891863126/// @dev the ERC-165 identifier for this interface is 0x0edfb42e
27contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {27contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
28 /// Create an NFT collection28 /// Create an NFT collection
29 /// @param name Name of the collection29 /// @param name Name of the collection
85 dummy = 0;85 dummy = 0;
86 }86 }
87
88 /// @dev EVM selector for this function is: 0x564e321f,
89 /// or in textual repr: destroyCollection(address)
90 function destroyCollection(address collectionAddress) public {
91 require(false, stub_error);
92 collectionAddress;
93 dummy = 0;
94 }
8795
88 /// Check if a collection exists96 /// Check if a collection exists
89 /// @param collectionAddress Address of the collection in question97 /// @param collectionAddress Address of the collection in question
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
18}18}
1919
20/// @title Contract, which allows users to operate with collections20/// @title Contract, which allows users to operate with collections
21/// @dev the ERC-165 identifier for this interface is 0x5891863121/// @dev the ERC-165 identifier for this interface is 0x0edfb42e
22interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {22interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
23 /// Create an NFT collection23 /// Create an NFT collection
24 /// @param name Name of the collection24 /// @param name Name of the collection
54 /// or in textual repr: makeCollectionERC721MetadataCompatible(address,string)54 /// or in textual repr: makeCollectionERC721MetadataCompatible(address,string)
55 function makeCollectionERC721MetadataCompatible(address collection, string memory baseUri) external;55 function makeCollectionERC721MetadataCompatible(address collection, string memory baseUri) external;
56
57 /// @dev EVM selector for this function is: 0x564e321f,
58 /// or in textual repr: destroyCollection(address)
59 function destroyCollection(address collectionAddress) external;
5660
57 /// Check if a collection exists61 /// Check if a collection exists
58 /// @param collectionAddress Address of the collection in question62 /// @param collectionAddress Address of the collection in question
modifiedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth
47 "stateMutability": "payable",47 "stateMutability": "payable",
48 "type": "function"48 "type": "function"
49 },49 },
50 {
51 "inputs": [
52 {
53 "internalType": "address",
54 "name": "collectionAddress",
55 "type": "address"
56 }
57 ],
58 "name": "destroyCollection",
59 "outputs": [],
60 "stateMutability": "nonpayable",
61 "type": "function"
62 },
50 {63 {
51 "inputs": [64 "inputs": [
52 {65 {
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
264 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');264 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
265 });265 });
266
267 itEth('destroyCollection test', async ({helper}) => {
268 const owner = await helper.eth.createAccountWithBalance(donor);
269 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
270 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
271
272 await expect(collectionHelper.methods
273 .destroyCollection(collectionAddress)
274 .send({from: owner})).to.be.fulfilled;
275
276 expect(await collectionHelper.methods
277 .isCollectionExist(collectionAddress)
278 .call()).to.be.false;
279 });
266});280});
267281
addedtests/src/eth/destroyCollection.test.tsdiffbeforeafterboth

no changes