difftreelog
patch: Change dispathed call for create item (return collection id).
in: master
4 files changed
pallets/common/src/dispatch.rsdiffbeforeafterboth8 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};121313use 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>;828383 /// Delete the collection.84 /// Delete the collection.84 ///85 ///pallets/unique/src/eth/mod.rsdiffbeforeafterboth32 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};3738179 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>)?;185185186 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>)?;213212214 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>)?;238237239 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>)?;265264266 let address = pallet_common::eth::collection_id_to_address(collection_id);265 let address = pallet_common::eth::collection_id_to_address(collection_id);pallets/unique/src/lib.rsdiffbeforeafterboth352352353 // =========353 // =========354354355 T::CollectionDispatch::create(T::CrossAccountId::from_sub(sender), data)?;355 let _id = T::CollectionDispatch::create(T::CrossAccountId::from_sub(sender), data)?;356356357 Ok(())357 Ok(())358 }358 }runtime/common/src/dispatch.rsdiffbeforeafterboth17use 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};343635pub 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 params64 }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 }697170 fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {72 fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {