difftreelog
patch: Change dispathed call for create item (return collection id).
in: master
4 files changed
pallets/common/src/dispatch.rsdiffbeforeafterboth--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -8,6 +8,7 @@
weights::Pays,
traits::Get,
};
+use sp_runtime::DispatchError;
use up_data_structs::{CollectionId, CreateCollectionData};
use crate::{pallet::Config, CommonCollectionOperations, CollectionHandle};
@@ -78,7 +79,7 @@
fn create(
sender: T::CrossAccountId,
data: CreateCollectionData<T::AccountId>,
- ) -> DispatchResult;
+ ) -> Result<CollectionId, DispatchError>;
/// Delete the collection.
///
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.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -352,7 +352,7 @@
// =========
- T::CollectionDispatch::create(T::CrossAccountId::from_sub(sender), data)?;
+ let _id = T::CollectionDispatch::create(T::CrossAccountId::from_sub(sender), data)?;
Ok(())
}
runtime/common/src/dispatch.rsdiffbeforeafterboth--- a/runtime/common/src/dispatch.rs
+++ b/runtime/common/src/dispatch.rs
@@ -17,6 +17,7 @@
use frame_support::{dispatch::DispatchResult, ensure};
use pallet_evm::{PrecompileHandle, PrecompileResult};
use sp_core::H160;
+use sp_runtime::DispatchError;
use sp_std::{borrow::ToOwned, vec::Vec};
use pallet_common::{
CollectionById, CollectionHandle, CommonCollectionOperations, erc::CommonEvmHandler,
@@ -30,6 +31,7 @@
};
use up_data_structs::{
CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,
+ CollectionId,
};
pub enum CollectionDispatchT<T>
@@ -51,8 +53,8 @@
fn create(
sender: T::CrossAccountId,
data: CreateCollectionData<T::AccountId>,
- ) -> DispatchResult {
- let _id = match data.mode {
+ ) -> Result<CollectionId, DispatchError> {
+ let id = match data.mode {
CollectionMode::NFT => <PalletNonfungible<T>>::init_collection(sender, data, false)?,
CollectionMode::Fungible(decimal_points) => {
// check params
@@ -64,7 +66,7 @@
}
CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,
};
- Ok(())
+ Ok(id)
}
fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {