git.delta.rocks / unique-network / refs/commits / 3ae92b8aacb2

difftreelog

refactor move collection dispatch to runtime

Yaroslav Bolyukin2022-04-07parent: #059f10c.patch.diff
in: master

13 files changed

addedpallets/common/src/dispatch.rsdiffbeforeafterboth

no changes

modifiedpallets/common/src/lib.rsdiffbeforeafterboth
21use sp_std::vec::Vec;21use sp_std::vec::Vec;
22use pallet_evm::account::CrossAccountId;22use pallet_evm::account::CrossAccountId;
23use frame_support::{23use frame_support::{
24 dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo},24 dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo},
25 ensure, fail,25 ensure, fail,
26 traits::{Imbalance, Get, Currency},26 traits::{Imbalance, Get, Currency, WithdrawReasons, ExistenceRequirement},
27 BoundedVec,27 BoundedVec,
28 weights::Pays,
28};29};
29use pallet_evm::GasWeightMapping;30use pallet_evm::GasWeightMapping;
30use up_data_structs::{31use up_data_structs::{
31 COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, ExistenceRequirement,32 COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,
32 MAX_TOKEN_PREFIX_LENGTH, COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, Pays, PostDispatchInfo,33 COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,
33 TokenId, Weight, WithdrawReasons, CollectionStats, MAX_TOKEN_OWNERSHIP, CollectionMode,34 CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
34 NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
35 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,35 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,
36 CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit,36 CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit,
40use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};40use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
41#[cfg(feature = "runtime-benchmarks")]41#[cfg(feature = "runtime-benchmarks")]
42pub mod benchmarking;42pub mod benchmarking;
43pub mod dispatch;
43pub mod erc;44pub mod erc;
44pub mod eth;45pub mod eth;
4546
163 use super::*;164 use super::*;
164 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};165 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
165 use pallet_evm::account;166 use pallet_evm::account;
167 use dispatch::CollectionDispatch;
166 use frame_support::traits::Currency;168 use frame_support::traits::Currency;
167 use up_data_structs::TokenId;169 use up_data_structs::TokenId;
168 use scale_info::TypeInfo;170 use scale_info::TypeInfo;
171 use up_evm_mapping::CrossAccountId;
169172
170 #[pallet::config]173 #[pallet::config]
171 pub trait Config:174 pub trait Config:
179 type CollectionCreationPrice: Get<182 type CollectionCreationPrice: Get<
180 <<Self as Config>::Currency as Currency<Self::AccountId>>::Balance,183 <<Self as Config>::Currency as Currency<Self::AccountId>>::Balance,
181 >;184 >;
185 type CollectionDispatch: CollectionDispatch<Self>;
182186
183 type TreasuryAccountId: Get<Self::AccountId>;187 type TreasuryAccountId: Get<Self::AccountId>;
184 }188 }
modifiedpallets/unique/src/common.rsdiffbeforeafterboth
1616
17use core::marker::PhantomData;17use core::marker::PhantomData;
18use frame_support::{weights::Weight};18use frame_support::{weights::Weight};
19use pallet_common::{CommonWeightInfo};19use pallet_common::{CommonWeightInfo, dispatch::dispatch_weight};
2020
21use pallet_fungible::{common::CommonWeights as FungibleWeights};21use pallet_fungible::{common::CommonWeights as FungibleWeights};
22use pallet_nonfungible::{common::CommonWeights as NonfungibleWeights};22use pallet_nonfungible::{common::CommonWeights as NonfungibleWeights};
23use pallet_refungible::{common::CommonWeights as RefungibleWeights};23use pallet_refungible::{common::CommonWeights as RefungibleWeights};
24use up_data_structs::CreateItemExData;24use up_data_structs::CreateItemExData;
2525
26use crate::{Config, dispatch::dispatch_weight};26use crate::Config;
2727
28macro_rules! max_weight_of {28macro_rules! max_weight_of {
29 ($method:ident ( $($args:tt)* )) => {29 ($method:ident ( $($args:tt)* )) => {
3535
36pub struct CommonWeights<T: Config>(PhantomData<T>);36pub struct CommonWeights<T: Config>(PhantomData<T>);
37impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {37impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
38 fn create_item() -> up_data_structs::Weight {38 fn create_item() -> Weight {
39 dispatch_weight::<T>() + max_weight_of!(create_item())39 dispatch_weight::<T>() + max_weight_of!(create_item())
40 }40 }
4141
51 dispatch_weight::<T>() + max_weight_of!(burn_item())51 dispatch_weight::<T>() + max_weight_of!(burn_item())
52 }52 }
5353
54 fn transfer() -> up_data_structs::Weight {54 fn transfer() -> Weight {
55 dispatch_weight::<T>() + max_weight_of!(transfer())55 dispatch_weight::<T>() + max_weight_of!(transfer())
56 }56 }
5757
58 fn approve() -> up_data_structs::Weight {58 fn approve() -> Weight {
59 dispatch_weight::<T>() + max_weight_of!(approve())59 dispatch_weight::<T>() + max_weight_of!(approve())
60 }60 }
6161
62 fn transfer_from() -> up_data_structs::Weight {62 fn transfer_from() -> Weight {
63 dispatch_weight::<T>() + max_weight_of!(transfer_from())63 dispatch_weight::<T>() + max_weight_of!(transfer_from())
64 }64 }
6565
66 fn set_variable_metadata(bytes: u32) -> up_data_structs::Weight {66 fn set_variable_metadata(bytes: u32) -> Weight {
67 dispatch_weight::<T>() + max_weight_of!(set_variable_metadata(bytes))67 dispatch_weight::<T>() + max_weight_of!(set_variable_metadata(bytes))
68 }68 }
6969
deletedpallets/unique/src/dispatch.rsdiffbeforeafterboth

no changes

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
1616
17pub mod sponsoring;17pub mod sponsoring;
18
19use fp_evm::PrecompileResult;
20use pallet_common::{
21 CollectionById,
22 erc::CommonEvmHandler,
23 eth::{map_eth_to_id, map_eth_to_token_id},
24};
25use pallet_fungible::FungibleHandle;
26use pallet_nonfungible::NonfungibleHandle;
27use pallet_refungible::{RefungibleHandle, erc::RefungibleTokenHandle};
28use sp_std::borrow::ToOwned;
29use sp_std::vec::Vec;
30use sp_core::{H160, U256};
31use crate::{CollectionMode, Config, dispatch::Dispatched};
32use pallet_common::CollectionHandle;
33
34pub struct UniqueErcSupport<T: Config>(core::marker::PhantomData<T>);
35
36impl<T: Config> pallet_evm::OnMethodCall<T> for UniqueErcSupport<T> {
37 fn is_reserved(target: &H160) -> bool {
38 map_eth_to_id(target).is_some()
39 }
40 fn is_used(target: &H160) -> bool {
41 map_eth_to_id(target)
42 .map(<CollectionById<T>>::contains_key)
43 .unwrap_or(false)
44 }
45 fn get_code(target: &H160) -> Option<Vec<u8>> {
46 if let Some(collection_id) = map_eth_to_id(target) {
47 let collection = <CollectionById<T>>::get(collection_id)?;
48 Some(
49 match collection.mode {
50 CollectionMode::NFT => <NonfungibleHandle<T>>::CODE,
51 CollectionMode::Fungible(_) => <FungibleHandle<T>>::CODE,
52 CollectionMode::ReFungible => <RefungibleHandle<T>>::CODE,
53 }
54 .to_owned(),
55 )
56 } else if let Some((collection_id, _token_id)) = map_eth_to_token_id(target) {
57 let collection = <CollectionById<T>>::get(collection_id)?;
58 if collection.mode != CollectionMode::ReFungible {
59 return None;
60 }
61 // TODO: check token existence
62 Some(<RefungibleTokenHandle<T>>::CODE.to_owned())
63 } else {
64 None
65 }
66 }
67 fn call(
68 source: &H160,
69 target: &H160,
70 gas_limit: u64,
71 input: &[u8],
72 value: U256,
73 ) -> Option<PrecompileResult> {
74 if let Some(collection_id) = map_eth_to_id(target) {
75 let collection = <CollectionHandle<T>>::new_with_gas_limit(collection_id, gas_limit)?;
76 let dispatched = Dispatched::dispatch(collection);
77
78 match dispatched {
79 Dispatched::Fungible(h) => h.call(source, input, value),
80 Dispatched::Nonfungible(h) => h.call(source, input, value),
81 Dispatched::Refungible(h) => h.call(source, input, value),
82 }
83 } else if let Some((collection_id, token_id)) = map_eth_to_token_id(target) {
84 let collection = <CollectionHandle<T>>::new_with_gas_limit(collection_id, gas_limit)?;
85 if collection.mode != CollectionMode::ReFungible {
86 return None;
87 }
88
89 let handle = RefungibleHandle::cast(collection);
90 // TODO: check token existence
91 RefungibleTokenHandle(handle, token_id).call(source, input, value)
92 } else {
93 None
94 }
95 }
96}
9718
modifiedpallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth
25use core::marker::PhantomData;25use core::marker::PhantomData;
26use core::convert::TryInto;26use core::convert::TryInto;
27use pallet_evm::account::CrossAccountId;27use pallet_evm::account::CrossAccountId;
28use up_data_structs::{TokenId, CreateItemData, CreateNftData};
2829
29use pallet_nonfungible::erc::{30use pallet_nonfungible::erc::{
30 UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,31 UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
2626
27pub use serde::{Serialize, Deserialize};27pub use serde::{Serialize, Deserialize};
2828
29pub use frame_support::{29use frame_support::{
30 construct_runtime, decl_module, decl_storage, decl_error, decl_event,30 decl_module, decl_storage, decl_error, decl_event,
31 dispatch::DispatchResult,31 dispatch::DispatchResult,
32 ensure, fail, parameter_types,32 ensure,
33 traits::{
34 ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced, Randomness,
35 IsSubType, WithdrawReasons,
36 },
37 weights::{33 weights::{Weight},
38 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
39 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
40 WeightToFeePolynomial, DispatchClass,
41 },
42 StorageValue, transactional,34 transactional,
43 pallet_prelude::{DispatchResultWithPostInfo, ConstU32},35 pallet_prelude::{DispatchResultWithPostInfo, ConstU32},
44 BoundedVec,36 BoundedVec,
45};37};
46use scale_info::TypeInfo;38use scale_info::TypeInfo;
47use frame_system::{self as system, ensure_signed};39use frame_system::{self as system, ensure_signed};
48use sp_runtime::{sp_std::prelude::Vec};40use sp_runtime::{sp_std::prelude::Vec};
49use up_data_structs::{41use up_data_structs::{
50 MAX_DECIMAL_POINTS, VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT,42 VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, OFFCHAIN_SCHEMA_LIMIT,
51 OFFCHAIN_SCHEMA_LIMIT, MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH,43 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
52 MAX_TOKEN_PREFIX_LENGTH, AccessMode, CreateItemData, CollectionLimits, CollectionId,44 AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId,
53 CollectionMode, TokenId, SchemaVersion, SponsorshipState, MetaUpdatePermission,45 SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, CustomDataLimit,
54 CreateCollectionData, CustomDataLimit, CreateItemExData,46 CreateItemExData,
55};47};
56use pallet_common::{CollectionHandle, Pallet as PalletCommon, Error as CommonError, CommonWeightInfo};
57use pallet_evm::account::CrossAccountId;48use pallet_evm::account::CrossAccountId;
58use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle};49use pallet_common::{
59use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};50 CollectionHandle, Pallet as PalletCommon, Error as CommonError, CommonWeightInfo,
60use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};51 dispatch::dispatch_call, dispatch::CollectionDispatch,
52};
6153
62#[cfg(test)]54#[cfg(test)]
70pub use sponsorship::{UniqueSponsorshipHandler, UniqueSponsorshipPredict};62pub use sponsorship::{UniqueSponsorshipHandler, UniqueSponsorshipPredict};
71pub use eth::sponsoring::UniqueEthSponsorshipHandler;63pub use eth::sponsoring::UniqueEthSponsorshipHandler;
72
73pub use eth::UniqueErcSupport;
7464
75pub mod common;65pub mod common;
76use common::CommonWeights;66use common::CommonWeights;
77pub mod dispatch;
78use dispatch::dispatch_call;
7967
80#[cfg(feature = "runtime-benchmarks")]68#[cfg(feature = "runtime-benchmarks")]
81mod benchmarking;69mod benchmarking;
352 #[weight = <SelfWeightOf<T>>::create_collection()]340 #[weight = <SelfWeightOf<T>>::create_collection()]
353 #[transactional]341 #[transactional]
354 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {342 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {
355 let owner = ensure_signed(origin)?;343 let sender = ensure_signed(origin)?;
356344
357 let _id = match data.mode {345 // =========
358 CollectionMode::NFT => {<PalletNonfungible<T>>::init_collection(owner, data)?},346
359 CollectionMode::Fungible(decimal_points) => {
360 // check params
361 ensure!(decimal_points <= MAX_DECIMAL_POINTS, Error::<T>::CollectionDecimalPointLimitExceeded);
362 <PalletFungible<T>>::init_collection(owner, data)?347 T::CollectionDispatch::create(sender, data)?;
363 }
364 CollectionMode::ReFungible => {
365 <PalletRefungible<T>>::init_collection(owner, data)?
366 }
367 };
368348
369 Ok(())349 Ok(())
370 }350 }
384 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);364 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
385
386 let collection = <CollectionHandle<T>>::try_get(collection_id)?;365 let collection = <CollectionHandle<T>>::try_get(collection_id)?;
387 collection.check_is_owner(&sender)?;
388366
389 // =========367 // =========
390368
391 match collection.mode {
392 CollectionMode::ReFungible => PalletRefungible::destroy_collection(RefungibleHandle::cast(collection), &sender)?,369 T::CollectionDispatch::destroy(sender, collection)?;
393 CollectionMode::Fungible(_) => PalletFungible::destroy_collection(FungibleHandle::cast(collection), &sender)?,
394 CollectionMode::NFT => PalletNonfungible::destroy_collection(NonfungibleHandle::cast(collection), &sender)?,
395 }
396370
397 <NftTransferBasket<T>>::remove_prefix(collection_id, None);371 <NftTransferBasket<T>>::remove_prefix(collection_id, None);
398 <FungibleTransferBasket<T>>::remove_prefix(collection_id, None);372 <FungibleTransferBasket<T>>::remove_prefix(collection_id, None);
modifiedruntime/common/Cargo.tomldiffbeforeafterboth
12default = ['std']12default = ['std']
13std = [13std = [
14 'sp-core/std',14 'sp-core/std',
15 'sp-std/std',
15 'sp-runtime/std',16 'sp-runtime/std',
16 'codec/std',17 'codec/std',
17 'frame-support/std',18 'frame-support/std',
18 'frame-system/std',19 'frame-system/std',
19 'sp-consensus-aura/std',20 'sp-consensus-aura/std',
20 'pallet-common/std',21 'pallet-common/std',
22 'pallet-unique/std',
23 'pallet-fungible/std',
24 'pallet-nonfungible/std',
25 'pallet-refungible/std',
26 'up-data-structs/std',
27 'pallet-evm/std',
21 'fp-rpc/std',28 'fp-rpc/std',
22]29]
23runtime-benchmarks = [30runtime-benchmarks = [
31git = "https://github.com/paritytech/substrate"38git = "https://github.com/paritytech/substrate"
32branch = "polkadot-v0.9.20"39branch = "polkadot-v0.9.20"
40
41[dependencies.sp-std]
42default-features = false
43git = 'https://github.com/paritytech/substrate.git'
44branch = 'polkadot-v0.9.17'
3345
34[dependencies.sp-runtime]46[dependencies.sp-runtime]
35default-features = false47default-features = false
61default-features = false73default-features = false
62path = "../../pallets/common"74path = "../../pallets/common"
75
76[dependencies.pallet-unique]
77default-features = false
78path = "../../pallets/unique"
79
80[dependencies.pallet-fungible]
81default-features = false
82path = "../../pallets/fungible"
83
84[dependencies.pallet-nonfungible]
85default-features = false
86path = "../../pallets/nonfungible"
87
88[dependencies.pallet-refungible]
89default-features = false
90path = "../../pallets/refungible"
91
92[dependencies.up-data-structs]
93default-features = false
94path = "../../primitives/data-structs"
95
96[dependencies.pallet-evm]
97default-features = false
98git = "https://github.com/uniquenetwork/frontier.git"
99branch = "unique-polkadot-v0.9.17"
63100
64[dependencies.sp-consensus-aura]101[dependencies.sp-consensus-aura]
65default-features = false102default-features = false
addedruntime/common/src/dispatch.rsdiffbeforeafterboth

no changes

modifiedruntime/common/src/lib.rsdiffbeforeafterboth
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3pub mod constants;3pub mod constants;
4pub mod dispatch;
4pub mod runtime_apis;5pub mod runtime_apis;
5pub mod types;6pub mod types;
67
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
58 traits::{58 traits::{
59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
61 OnUnbalanced, Randomness, FindAuthor,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,
62 },62 },
63 weights::{63 weights::{
64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,
67 },67 },
68};68};
69use up_data_structs::*;69use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection};
70// use pallet_contracts::weights::WeightInfo;70// use pallet_contracts::weights::WeightInfo;
71// #[cfg(any(feature = "std", test))]71// #[cfg(any(feature = "std", test))]
72use frame_system::{72use frame_system::{
117use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};117use unique_runtime_common::{
118 impl_common_runtime_apis,
119 types::*,
120 constants::*,
121 dispatch::{CollectionDispatchT, CollectionDispatch},
122};
118123
119pub const RUNTIME_NAME: &str = "opal";124pub const RUNTIME_NAME: &str = "opal";
295 type Event = Event;300 type Event = Event;
296 type OnMethodCall = (301 type OnMethodCall = (
297 pallet_evm_migration::OnMethodCall<Self>,302 pallet_evm_migration::OnMethodCall<Self>,
298 pallet_unique::UniqueErcSupport<Self>,303 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
299 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,304 CollectionDispatchT<Self>,
300 );305 );
301 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;306 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
302 type ChainId = ChainId;307 type ChainId = ChainId;
871 type Currency = Balances;876 type Currency = Balances;
872 type CollectionCreationPrice = CollectionCreationPrice;877 type CollectionCreationPrice = CollectionCreationPrice;
873 type TreasuryAccountId = TreasuryAccountId;878 type TreasuryAccountId = TreasuryAccountId;
879 type CollectionDispatch = CollectionDispatchT<Self>;
880
881 type EvmTokenAddressMapping = EvmTokenAddressMapping;
882 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;
874}883}
884
885impl pallet_structure::Config for Runtime {
886 type Event = Event;
887 type Call = Call;
888 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
889}
875890
876impl pallet_fungible::Config for Runtime {891impl pallet_fungible::Config for Runtime {
877 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;892 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
11191134
1120macro_rules! dispatch_unique_runtime {1135macro_rules! dispatch_unique_runtime {
1121 ($collection:ident.$method:ident($($name:ident),*)) => {{1136 ($collection:ident.$method:ident($($name:ident),*)) => {{
1122 use pallet_unique::dispatch::Dispatched;
1123
1124 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1137 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
1125 let dispatch = collection.as_dyn();1138 let dispatch = collection.as_dyn();
11261139
1127 Ok(dispatch.$method($($name),*))1140 Ok(dispatch.$method($($name),*))
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
58 traits::{58 traits::{
59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
61 OnUnbalanced, Randomness, FindAuthor,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,
62 },62 },
63 weights::{63 weights::{
64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,
67 },67 },
68};68};
69use unique_runtime_common::dispatch::{CollectionDispatchT, CollectionDispatch};
69use up_data_structs::*;70use up_data_structs::*;
70// use pallet_contracts::weights::WeightInfo;71// use pallet_contracts::weights::WeightInfo;
71// #[cfg(any(feature = "std", test))]72// #[cfg(any(feature = "std", test))]
92// Polkadot imports93// Polkadot imports
93use pallet_xcm::XcmPassthrough;94use pallet_xcm::XcmPassthrough;
94use polkadot_parachain::primitives::Sibling;95use polkadot_parachain::primitives::Sibling;
96use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};
95use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
96use xcm_builder::{98use xcm_builder::{
97 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
274 type Event = Event;276 type Event = Event;
275 type OnMethodCall = (277 type OnMethodCall = (
276 pallet_evm_migration::OnMethodCall<Self>,278 pallet_evm_migration::OnMethodCall<Self>,
277 pallet_unique::UniqueErcSupport<Self>,279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
278 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,280 CollectionDispatchT<Self>,
279 );281 );
280 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;282 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
281 type ChainId = ChainId;283 type ChainId = ChainId;
851 type Currency = Balances;853 type Currency = Balances;
852 type CollectionCreationPrice = CollectionCreationPrice;854 type CollectionCreationPrice = CollectionCreationPrice;
853 type TreasuryAccountId = TreasuryAccountId;855 type TreasuryAccountId = TreasuryAccountId;
856 type CollectionDispatch = CollectionDispatchT<Self>;
857
858 type EvmTokenAddressMapping = EvmTokenAddressMapping;
859 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;
854}860}
861
862impl pallet_structure::Config for Runtime {
863 type Event = Event;
864 type Call = Call;
865 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
866}
855867
856impl pallet_evm::account::Config for Runtime {868impl pallet_evm::account::Config for Runtime {
857 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;869 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;
979 Fungible: pallet_fungible::{Pallet, Storage} = 67,991 Fungible: pallet_fungible::{Pallet, Storage} = 67,
980 Refungible: pallet_refungible::{Pallet, Storage} = 68,992 Refungible: pallet_refungible::{Pallet, Storage} = 68,
981 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,993 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
994 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
982995
983 // Frontier996 // Frontier
984 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,997 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
11051118
1106macro_rules! dispatch_unique_runtime {1119macro_rules! dispatch_unique_runtime {
1107 ($collection:ident.$method:ident($($name:ident),*)) => {{1120 ($collection:ident.$method:ident($($name:ident),*)) => {{
1108 use pallet_unique::dispatch::Dispatched;
1109
1110 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1121 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
1111 let dispatch = collection.as_dyn();1122 let dispatch = collection.as_dyn();
11121123
1113 Ok(dispatch.$method($($name),*))1124 Ok(dispatch.$method($($name),*))
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
58 traits::{58 traits::{
59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
61 OnUnbalanced, Randomness, FindAuthor,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,
62 },62 },
63 weights::{63 weights::{
64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,
67 },67 },
68};68};
69use unique_runtime_common::dispatch::{CollectionDispatchT, CollectionDispatch};
69use up_data_structs::*;70use up_data_structs::*;
70// use pallet_contracts::weights::WeightInfo;71// use pallet_contracts::weights::WeightInfo;
71// #[cfg(any(feature = "std", test))]72// #[cfg(any(feature = "std", test))]
91// Polkadot imports92// Polkadot imports
92use pallet_xcm::XcmPassthrough;93use pallet_xcm::XcmPassthrough;
93use polkadot_parachain::primitives::Sibling;94use polkadot_parachain::primitives::Sibling;
95use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};
94use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
95use xcm_builder::{97use xcm_builder::{
96 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
273 type Event = Event;275 type Event = Event;
274 type OnMethodCall = (276 type OnMethodCall = (
275 pallet_evm_migration::OnMethodCall<Self>,277 pallet_evm_migration::OnMethodCall<Self>,
276 pallet_unique::UniqueErcSupport<Self>,278 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
277 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,279 CollectionDispatchT<Self>,
278 );280 );
279 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;281 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
280 type ChainId = ChainId;282 type ChainId = ChainId;
849 type Currency = Balances;851 type Currency = Balances;
850 type CollectionCreationPrice = CollectionCreationPrice;852 type CollectionCreationPrice = CollectionCreationPrice;
851 type TreasuryAccountId = TreasuryAccountId;853 type TreasuryAccountId = TreasuryAccountId;
854 type CollectionDispatch = CollectionDispatchT<Self>;
855
856 type EvmTokenAddressMapping = EvmTokenAddressMapping;
857 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;
852}858}
859
860impl pallet_structure::Config for Runtime {
861 type Event = Event;
862 type Call = Call;
863 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
864}
853865
854impl pallet_evm::account::Config for Runtime {866impl pallet_evm::account::Config for Runtime {
855 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;867 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;
977 Fungible: pallet_fungible::{Pallet, Storage} = 67,989 Fungible: pallet_fungible::{Pallet, Storage} = 67,
978 Refungible: pallet_refungible::{Pallet, Storage} = 68,990 Refungible: pallet_refungible::{Pallet, Storage} = 68,
979 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,991 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
992 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
980993
981 // Frontier994 // Frontier
982 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,995 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
11031116
1104macro_rules! dispatch_unique_runtime {1117macro_rules! dispatch_unique_runtime {
1105 ($collection:ident.$method:ident($($name:ident),*)) => {{1118 ($collection:ident.$method:ident($($name:ident),*)) => {{
1106 use pallet_unique::dispatch::Dispatched;
1107
1108 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1119 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
1109 let dispatch = collection.as_dyn();1120 let dispatch = collection.as_dyn();
11101121
1111 Ok(dispatch.$method($($name),*))1122 Ok(dispatch.$method($($name),*))