git.delta.rocks / unique-network / refs/commits / 52730495c578

difftreelog

patch: Change dispathed call for create item (return collection id).

Trubnikov Sergey2022-07-25parent: #6434da3.patch.diff
in: master

4 files changed

modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
8 weights::Pays,8 weights::Pays,
9 traits::Get,9 traits::Get,
10};10};
11use sp_runtime::DispatchError;
11use up_data_structs::{CollectionId, CreateCollectionData};12use up_data_structs::{CollectionId, CreateCollectionData};
1213
13use crate::{pallet::Config, CommonCollectionOperations, CollectionHandle};14use crate::{pallet::Config, CommonCollectionOperations, CollectionHandle};
78 fn create(79 fn create(
79 sender: T::CrossAccountId,80 sender: T::CrossAccountId,
80 data: CreateCollectionData<T::AccountId>,81 data: CreateCollectionData<T::AccountId>,
81 ) -> DispatchResult;82 ) -> Result<CollectionId, DispatchError>;
8283
83 /// Delete the collection.84 /// Delete the collection.
84 ///85 ///
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
32 static_property::{key, value as property_value},32 static_property::{key, value as property_value},
33 CollectionHelpersEvents,33 CollectionHelpersEvents,
34 },34 },
35 dispatch::CollectionDispatch,
35};36};
36use crate::{SelfWeightOf, Config, weights::WeightInfo};37use crate::{SelfWeightOf, Config, weights::WeightInfo};
3738
179 Default::default(),180 Default::default(),
180 false,181 false,
181 )?;182 )?;
182 let collection_id =183 let collection_id = T::CollectionDispatch::create(caller, data)
183 <pallet_nonfungible::Pallet<T>>::init_collection(caller.clone(), data, false)
184 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;184 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
185185
186 let address = pallet_common::eth::collection_id_to_address(collection_id);186 let address = pallet_common::eth::collection_id_to_address(collection_id);
207 base_uri_value,207 base_uri_value,
208 true,208 true,
209 )?;209 )?;
210 let collection_id =210 let collection_id = T::CollectionDispatch::create(caller, data)
211 <pallet_nonfungible::Pallet<T>>::init_collection(caller.clone(), data, true)
212 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;211 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
213212
214 let address = pallet_common::eth::collection_id_to_address(collection_id);213 let address = pallet_common::eth::collection_id_to_address(collection_id);
233 Default::default(),232 Default::default(),
234 false,233 false,
235 )?;234 )?;
236 let collection_id = <pallet_refungible::Pallet<T>>::init_collection(caller.clone(), data)235 let collection_id = T::CollectionDispatch::create(caller, data)
237 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;236 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
238237
239 let address = pallet_common::eth::collection_id_to_address(collection_id);238 let address = pallet_common::eth::collection_id_to_address(collection_id);
260 base_uri_value,259 base_uri_value,
261 true,260 true,
262 )?;261 )?;
263 let collection_id = <pallet_refungible::Pallet<T>>::init_collection(caller.clone(), data)262 let collection_id = T::CollectionDispatch::create(caller, data)
264 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;263 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
265264
266 let address = pallet_common::eth::collection_id_to_address(collection_id);265 let address = pallet_common::eth::collection_id_to_address(collection_id);
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
352352
353 // =========353 // =========
354354
355 T::CollectionDispatch::create(T::CrossAccountId::from_sub(sender), data)?;355 let _id = T::CollectionDispatch::create(T::CrossAccountId::from_sub(sender), data)?;
356356
357 Ok(())357 Ok(())
358 }358 }
modifiedruntime/common/src/dispatch.rsdiffbeforeafterboth
17use frame_support::{dispatch::DispatchResult, ensure};17use frame_support::{dispatch::DispatchResult, ensure};
18use pallet_evm::{PrecompileHandle, PrecompileResult};18use pallet_evm::{PrecompileHandle, PrecompileResult};
19use sp_core::H160;19use sp_core::H160;
20use sp_runtime::DispatchError;
20use sp_std::{borrow::ToOwned, vec::Vec};21use sp_std::{borrow::ToOwned, vec::Vec};
21use pallet_common::{22use pallet_common::{
22 CollectionById, CollectionHandle, CommonCollectionOperations, erc::CommonEvmHandler,23 CollectionById, CollectionHandle, CommonCollectionOperations, erc::CommonEvmHandler,
30};31};
31use up_data_structs::{32use up_data_structs::{
32 CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,33 CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,
34 CollectionId,
33};35};
3436
35pub enum CollectionDispatchT<T>37pub enum CollectionDispatchT<T>
51 fn create(53 fn create(
52 sender: T::CrossAccountId,54 sender: T::CrossAccountId,
53 data: CreateCollectionData<T::AccountId>,55 data: CreateCollectionData<T::AccountId>,
54 ) -> DispatchResult {56 ) -> Result<CollectionId, DispatchError> {
55 let _id = match data.mode {57 let id = match data.mode {
56 CollectionMode::NFT => <PalletNonfungible<T>>::init_collection(sender, data, false)?,58 CollectionMode::NFT => <PalletNonfungible<T>>::init_collection(sender, data, false)?,
57 CollectionMode::Fungible(decimal_points) => {59 CollectionMode::Fungible(decimal_points) => {
58 // check params60 // check params
64 }66 }
65 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,67 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,
66 };68 };
67 Ok(())69 Ok(id)
68 }70 }
6971
70 fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {72 fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {