git.delta.rocks / unique-network / refs/commits / d0b6ad7ebb12

difftreelog

refactor rename xcm executor config

Daniel Shiposha2023-03-22parent: #aee14e9.patch.diff
in: master

2 files changed

modifiedruntime/common/config/orml.rsdiffbeforeafterboth
before · runtime/common/config/orml.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	parameter_types,19	traits::{Contains, Everything},20};21use frame_system::EnsureSigned;22use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};23use sp_runtime::traits::Convert;24use xcm::latest::{Weight, Junction::*, Junctions::*, MultiLocation};25use xcm_executor::XcmExecutor;26use sp_std::{vec, vec::Vec};27use pallet_foreign_assets::{CurrencyId, NativeCurrency};28use crate::{29	Runtime, RuntimeEvent, RelayChainBlockNumberProvider,30	runtime_common::config::{31		xcm::{32			SelfLocation, Weigher, XcmConfig, UniversalLocation,33			xcm_assets::{CurrencyIdConvert},34		},35		pallets::TreasuryAccountId,36		substrate::{MaxLocks, MaxReserves},37	},38};3940use up_common::{41	types::{AccountId, Balance},42	constants::*,43};4445// Signed version of balance46pub type Amount = i128;4748parameter_types! {49	pub const MinVestedTransfer: Balance = 10 * UNIQUE;50	pub const MaxVestingSchedules: u32 = 28;5152	pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 1000); // ? TODO: recheck this53	pub const MaxAssetsForTransfer: usize = 2;54}5556parameter_type_with_key! {57	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {58		Some(100_000_000_000)59	};60}6162parameter_type_with_key! {63	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {64		match currency_id {65			CurrencyId::NativeAssetId(symbol) => match symbol {66				NativeCurrency::Here => 0,67				NativeCurrency::Parent=> 0,68			},69			_ => 100_00070		}71	};72}7374pub fn get_all_module_accounts() -> Vec<AccountId> {75	vec![TreasuryAccountId::get()]76}7778pub struct DustRemovalWhitelist;79impl Contains<AccountId> for DustRemovalWhitelist {80	fn contains(a: &AccountId) -> bool {81		get_all_module_accounts().contains(a)82	}83}8485pub struct AccountIdToMultiLocation;86impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {87	fn convert(account: AccountId) -> MultiLocation {88		X1(AccountId32 {89			network: None,90			id: account.into(),91		})92		.into()93	}94}9596pub struct CurrencyHooks;97impl orml_traits::currency::MutationHooks<AccountId, CurrencyId, Balance> for CurrencyHooks {98	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;99	type OnSlash = ();100	type PreTransfer = ();101	type PostTransfer = ();102	type PreDeposit = ();103	type PostDeposit = ();104	type OnNewTokenAccount = ();105	type OnKilledTokenAccount = ();106}107108impl orml_vesting::Config for Runtime {109	type RuntimeEvent = RuntimeEvent;110	type Currency = pallet_balances::Pallet<Runtime>;111	type MinVestedTransfer = MinVestedTransfer;112	type VestedTransferOrigin = EnsureSigned<AccountId>;113	type WeightInfo = ();114	type MaxVestingSchedules = MaxVestingSchedules;115	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;116}117118impl orml_tokens::Config for Runtime {119	type RuntimeEvent = RuntimeEvent;120	type Balance = Balance;121	type Amount = Amount;122	type CurrencyId = CurrencyId;123	type WeightInfo = ();124	type ExistentialDeposits = ExistentialDeposits;125	type CurrencyHooks = CurrencyHooks;126	type MaxLocks = MaxLocks;127	type MaxReserves = MaxReserves;128	// TODO: Add all module accounts129	type DustRemovalWhitelist = DustRemovalWhitelist;130	/// The id type for named reserves.131	type ReserveIdentifier = ();132}133134impl orml_xtokens::Config for Runtime {135	type RuntimeEvent = RuntimeEvent;136	type Balance = Balance;137	type CurrencyId = CurrencyId;138	type CurrencyIdConvert = CurrencyIdConvert;139	type AccountIdToMultiLocation = AccountIdToMultiLocation;140	type SelfLocation = SelfLocation;141	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;142	type Weigher = Weigher;143	type BaseXcmWeight = BaseXcmWeight;144	type MaxAssetsForTransfer = MaxAssetsForTransfer;145	type MinXcmFee = ParachainMinFee;146	type MultiLocationsFilter = Everything;147	type ReserveProvider = AbsoluteReserveProvider;148	type UniversalLocation = UniversalLocation;149}
after · runtime/common/config/orml.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	parameter_types,19	traits::{Contains, Everything},20};21use frame_system::EnsureSigned;22use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};23use sp_runtime::traits::Convert;24use xcm::latest::{Weight, Junction::*, Junctions::*, MultiLocation};25use xcm_executor::XcmExecutor;26use sp_std::{vec, vec::Vec};27use pallet_foreign_assets::{CurrencyId, NativeCurrency};28use crate::{29	Runtime, RuntimeEvent, RelayChainBlockNumberProvider,30	runtime_common::config::{31		xcm::{32			SelfLocation, Weigher, XcmExecutorConfig, UniversalLocation,33			xcm_assets::{CurrencyIdConvert},34		},35		pallets::TreasuryAccountId,36		substrate::{MaxLocks, MaxReserves},37	},38};3940use up_common::{41	types::{AccountId, Balance},42	constants::*,43};4445// Signed version of balance46pub type Amount = i128;4748parameter_types! {49	pub const MinVestedTransfer: Balance = 10 * UNIQUE;50	pub const MaxVestingSchedules: u32 = 28;5152	pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 1000); // ? TODO: recheck this53	pub const MaxAssetsForTransfer: usize = 2;54}5556parameter_type_with_key! {57	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {58		Some(100_000_000_000)59	};60}6162parameter_type_with_key! {63	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {64		match currency_id {65			CurrencyId::NativeAssetId(symbol) => match symbol {66				NativeCurrency::Here => 0,67				NativeCurrency::Parent=> 0,68			},69			_ => 100_00070		}71	};72}7374pub fn get_all_module_accounts() -> Vec<AccountId> {75	vec![TreasuryAccountId::get()]76}7778pub struct DustRemovalWhitelist;79impl Contains<AccountId> for DustRemovalWhitelist {80	fn contains(a: &AccountId) -> bool {81		get_all_module_accounts().contains(a)82	}83}8485pub struct AccountIdToMultiLocation;86impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {87	fn convert(account: AccountId) -> MultiLocation {88		X1(AccountId32 {89			network: None,90			id: account.into(),91		})92		.into()93	}94}9596pub struct CurrencyHooks;97impl orml_traits::currency::MutationHooks<AccountId, CurrencyId, Balance> for CurrencyHooks {98	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;99	type OnSlash = ();100	type PreTransfer = ();101	type PostTransfer = ();102	type PreDeposit = ();103	type PostDeposit = ();104	type OnNewTokenAccount = ();105	type OnKilledTokenAccount = ();106}107108impl orml_vesting::Config for Runtime {109	type RuntimeEvent = RuntimeEvent;110	type Currency = pallet_balances::Pallet<Runtime>;111	type MinVestedTransfer = MinVestedTransfer;112	type VestedTransferOrigin = EnsureSigned<AccountId>;113	type WeightInfo = ();114	type MaxVestingSchedules = MaxVestingSchedules;115	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;116}117118impl orml_tokens::Config for Runtime {119	type RuntimeEvent = RuntimeEvent;120	type Balance = Balance;121	type Amount = Amount;122	type CurrencyId = CurrencyId;123	type WeightInfo = ();124	type ExistentialDeposits = ExistentialDeposits;125	type CurrencyHooks = CurrencyHooks;126	type MaxLocks = MaxLocks;127	type MaxReserves = MaxReserves;128	// TODO: Add all module accounts129	type DustRemovalWhitelist = DustRemovalWhitelist;130	/// The id type for named reserves.131	type ReserveIdentifier = ();132}133134impl orml_xtokens::Config for Runtime {135	type RuntimeEvent = RuntimeEvent;136	type Balance = Balance;137	type CurrencyId = CurrencyId;138	type CurrencyIdConvert = CurrencyIdConvert;139	type AccountIdToMultiLocation = AccountIdToMultiLocation;140	type SelfLocation = SelfLocation;141	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;142	type Weigher = Weigher;143	type BaseXcmWeight = BaseXcmWeight;144	type MaxAssetsForTransfer = MaxAssetsForTransfer;145	type MinXcmFee = ParachainMinFee;146	type MultiLocationsFilter = Everything;147	type ReserveProvider = AbsoluteReserveProvider;148	type UniversalLocation = UniversalLocation;149}
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -28,7 +28,7 @@
 	SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
 	SignedToAccountId32, SovereignSignedViaLocation, ParentIsPreset,
 };
-use xcm_executor::{Config, XcmExecutor, traits::ShouldExecute};
+use xcm_executor::{XcmExecutor, traits::ShouldExecute};
 use sp_std::{marker::PhantomData, vec::Vec};
 use crate::{
 	Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, ParachainInfo, ParachainSystem, PolkadotXcm,
@@ -182,8 +182,8 @@
 
 pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
 
-pub struct XcmConfig<T>(PhantomData<T>);
-impl<T> Config for XcmConfig<T>
+pub struct XcmExecutorConfig<T>(PhantomData<T>);
+impl<T> xcm_executor::Config for XcmExecutorConfig<T>
 where
 	T: pallet_configuration::Config,
 {
@@ -227,7 +227,7 @@
 	type XcmRouter = XcmRouter;
 	type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
 	type XcmExecuteFilter = Everything;
-	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
+	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;
 	type XcmTeleportFilter = Everything;
 	type XcmReserveTransferFilter = Everything;
 	type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
@@ -248,13 +248,13 @@
 
 impl cumulus_pallet_xcm::Config for Runtime {
 	type RuntimeEvent = RuntimeEvent;
-	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
+	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;
 }
 
 impl cumulus_pallet_xcmp_queue::Config for Runtime {
 	type WeightInfo = ();
 	type RuntimeEvent = RuntimeEvent;
-	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
+	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;
 	type ChannelInfo = ParachainSystem;
 	type VersionWrapper = ();
 	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
@@ -265,6 +265,6 @@
 
 impl cumulus_pallet_dmp_queue::Config for Runtime {
 	type RuntimeEvent = RuntimeEvent;
-	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
+	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;
 	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
 }