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

difftreelog

fix get rid of unneeded comments in xcm configs

Daniel Shiposha2022-09-05parent: #f8304b7.patch.diff
in: master

2 files changed

modifiedruntime/opal/src/xcm_config.rsdiffbeforeafterboth
before · runtime/opal/src/xcm_config.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 cumulus_pallet_xcm;18use frame_support::{19	{match_types, parameter_types, weights::Weight},20	pallet_prelude::Get,21	traits::{Contains, Everything, fungibles},22};23use frame_system::EnsureRoot;24use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};25use pallet_xcm::XcmPassthrough;26use polkadot_parachain::primitives::Sibling;27use sp_runtime::traits::{AccountIdConversion, CheckedConversion, Convert, Zero};28use sp_std::{borrow::Borrow, marker::PhantomData, vec, vec::Vec};29use xcm::{30	latest::{MultiAsset, Xcm},31	prelude::{Concrete, Fungible as XcmFungible},32	v1::{BodyId, Junction::*, Junctions::*, MultiLocation, NetworkId},33};34use xcm_builder::{35	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, EnsureXcmOrigin,36	FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentAsSuperuser, ParentIsPreset,37	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,38	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,39	ConvertedConcreteAssetId,40};41use xcm_executor::{42	{Config, XcmExecutor},43	traits::{Convert as ConvertXcm, FilterAssetLocation, JustTry, MatchesFungible, ShouldExecute},44};4546use up_common::{47	constants::{MAXIMUM_BLOCK_WEIGHT, UNIQUE},48	types::{AccountId, Balance},49};5051use crate::{52	Balances, Call, DmpQueue, Event, ForeingAssets, Origin, ParachainInfo, ParachainSystem,53	PolkadotXcm, Runtime, XcmpQueue,54};55use crate::runtime_common::config::substrate::{TreasuryModuleId, MaxLocks, MaxReserves};56use crate::runtime_common::config::pallets::TreasuryAccountId;57use crate::runtime_common::config::xcm::*;58use crate::*;5960use pallet_foreing_assets::{61	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency, FreeForAll,62	TryAsForeing, ForeignAssetId,63};6465// Signed version of balance66pub type Amount = i128;6768/*69parameter_types! {70	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;71	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;72}7374impl cumulus_pallet_parachain_system::Config for Runtime {75	type Event = Event;76	type SelfParaId = parachain_info::Pallet<Self>;77	type OnSystemEvent = ();78	type OutboundXcmpMessageSource = XcmpQueue;79	type DmpMessageHandler = DmpQueue;80	type ReservedDmpWeight = ReservedDmpWeight;81	type ReservedXcmpWeight = ReservedXcmpWeight;82	type XcmpMessageHandler = XcmpQueue;83}8485impl parachain_info::Config for Runtime {}8687impl cumulus_pallet_aura_ext::Config for Runtime {}88 */8990parameter_types! {91	pub const RelayLocation: MultiLocation = MultiLocation::parent();92	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;93	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();94	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();95	pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));96}9798/*99/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used100/// when determining ownership of accounts for asset transacting and when attempting to use XCM101/// `Transact` in order to determine the dispatch Origin.102pub type LocationToAccountId = (103	// The parent (Relay-chain) origin converts to the default `AccountId`.104	ParentIsPreset<AccountId>,105	// Sibling parachain origins convert to AccountId via the `ParaId::into`.106	SiblingParachainConvertsVia<Sibling, AccountId>,107	// Straight up local `AccountId32` origins just alias directly to `AccountId`.108	AccountId32Aliases<RelayNetwork, AccountId>,109);110111pub struct OnlySelfCurrency;112113impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {114	fn matches_fungible(a: &MultiAsset) -> Option<B> {115		match (&a.id, &a.fun) {116			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),117			_ => None,118		}119	}120}121122/// Means for transacting assets on this chain.123pub type LocalAssetTransactor = CurrencyAdapter<124	// Use this currency:125	Balances,126	// Use this currency when it is a fungible asset matching the given location or name:127	OnlySelfCurrency,128	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:129	LocationToAccountId,130	// Our chain's account ID type (we can't get away without mentioning it explicitly):131	AccountId,132	// We don't track any teleports.133	(),134>;135136 */137138/*139parameter_types! {140	pub CheckingAccount: AccountId = PolkadotXcm::check_account();141}142143/// Allow checking in assets that have issuance > 0.144pub struct NonZeroIssuance<AccountId, ForeingAssets>(PhantomData<(AccountId, ForeingAssets)>);145impl<AccountId, ForeingAssets> Contains<<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId>146	for NonZeroIssuance<AccountId, ForeingAssets>147where148	ForeingAssets: fungibles::Inspect<AccountId>,149{150	fn contains(id: &<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {151		!ForeingAssets::total_issuance(*id).is_zero()152	}153}154155pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);156impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>157	ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>158where159	AssetId: Borrow<AssetId>,160	AssetId: TryAsForeing<AssetId, ForeignAssetId>,161	AssetIds: Borrow<AssetId>,162{163	fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {164		let id = id.borrow();165166		log::trace!(167			target: "xcm::AsInnerId::Convert",168			"AsInnerId {:?}",169			id170		);171172		let parent = MultiLocation::parent();173		let here = MultiLocation::here();174		let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));175176		if *id == parent {177			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent));178		}179180		if *id == here || *id == self_location {181			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here));182		}183184		match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(id.clone()) {185			Some(AssetIds::ForeignAssetId(foreign_asset_id)) => {186				ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id))187			}188			_ => ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(0)),189		}190	}191192	fn reverse_ref(what: impl Borrow<AssetId>) -> Result<MultiLocation, ()> {193		log::trace!(194			target: "xcm::AsInnerId::Reverse",195			"AsInnerId",196		);197198		let asset_id = what.borrow();199200		let parent_id =201			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap();202		let here_id =203			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap();204205		if asset_id.clone() == parent_id {206			return Ok(MultiLocation::parent());207		}208209		if asset_id.clone() == here_id {210			return Ok(MultiLocation::new(211				1,212				X1(Parachain(ParachainInfo::get().into())),213			));214		}215216		match <AssetId as TryAsForeing<AssetId, ForeignAssetId>>::try_as_foreing(asset_id.clone()) {217			Some(fid) => match XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid) {218				Some(location) => Ok(location),219				None => Err(()),220			},221			None => Err(()),222		}223	}224}225226/// Means for transacting assets besides the native currency on this chain.227pub type FungiblesTransactor = FungiblesAdapter<228	// Use this fungibles implementation:229	ForeingAssets,230	// Use this currency when it is a fungible asset matching the given location or name:231	ConvertedConcreteAssetId<AssetIds, Balance, AsInnerId<AssetIds, JustTry>, JustTry>,232	// Convert an XCM MultiLocation into a local account id:233	LocationToAccountId,234	// Our chain's account ID type (we can't get away without mentioning it explicitly):235	AccountId,236	// We only want to allow teleports of known assets. We use non-zero issuance as an indication237	// that this asset is known.238	NonZeroIssuance<AccountId, ForeingAssets>,239	// The account to use for tracking teleports.240	CheckingAccount,241>;242243/// Means for transacting assets on this chain.244pub type AssetTransactors = FungiblesTransactor;245 */246247/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,248/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can249/// biases the kind of local `Origin` it will become.250pub type XcmOriginToTransactDispatchOrigin = (251	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location252	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for253	// foreign chains who want to have a local sovereign account on this chain which they control.254	SovereignSignedViaLocation<LocationToAccountId, Origin>,255	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when256	// recognised.257	RelayChainAsNative<RelayOrigin, Origin>,258	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when259	// recognised.260	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,261	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a262	// transaction from the Root origin.263	ParentAsSuperuser<Origin>,264	// Native signed account converter; this just converts an `AccountId32` origin into a normal265	// `Origin::Signed` origin of the same 32-byte value.266	SignedAccountId32AsNative<RelayNetwork, Origin>,267	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.268	XcmPassthrough<Origin>,269);270271parameter_types! {272	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.273	pub UnitWeightCost: Weight = 1_000_000;274	// 1200 UNIQUEs buy 1 second of weight.275	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);276	pub const MaxInstructions: u32 = 100;277	pub const MaxAuthorities: u32 = 100_000;278}279280match_types! {281	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {282		MultiLocation { parents: 1, interior: Here } |283		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }284	};285}286287/// Execution barrier that just takes `max_weight` from `weight_credit`.288///289/// Useful to allow XCM execution by local chain users via extrinsics.290/// E.g. `pallet_xcm::reserve_asset_transfer` to transfer a reserve asset291/// out of the local chain to another one.292pub struct AllowAllDebug;293impl ShouldExecute for AllowAllDebug {294	fn should_execute<Call>(295		_origin: &MultiLocation,296		_message: &mut Xcm<Call>,297		max_weight: Weight,298		weight_credit: &mut Weight,299	) -> Result<(), ()> {300		Ok(())301	}302}303304pub type Barrier = DenyThenTry<305	DenyTransact,306	(307		TakeWeightCredit,308		AllowTopLevelPaidExecutionFrom<Everything>,309		AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,310		// ^^^ Parent & its unit plurality gets free execution311		AllowAllDebug,312	)313>;314315pub struct AllAsset;316impl FilterAssetLocation for AllAsset {317	fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {318		true319	}320}321322/* /// CHANGEME!!!323pub struct XcmConfig;324impl Config for XcmConfig {325	type Call = Call;326	type XcmSender = XcmRouter;327	// How to withdraw and deposit an asset.328	type AssetTransactor = AssetTransactors;329	type OriginConverter = XcmOriginToTransactDispatchOrigin;330	type IsReserve = AllAsset; //NativeAsset;331	type IsTeleporter = (); // Teleportation is disabled332	type LocationInverter = LocationInverter<Ancestry>;333	type Barrier = Barrier;334	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;335	type Trader =336		FreeForAll<LinearFee<Balance>, RelayLocation, AccountId, Balances, ()>;337	type ResponseHandler = (); // Don't handle responses for now.338	type SubscriptionService = PolkadotXcm;339	type AssetTrap = PolkadotXcm;340	type AssetClaims = PolkadotXcm;341}342 */343344/*345/// No local origins on this chain are allowed to dispatch XCM sends/executions.346pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);347348/// The means for routing XCM messages which are not for local execution into the right message349/// queues.350pub type XcmRouter = (351	// Two routers - use UMP to communicate with the relay chain:352	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,353	// ..and XCMP to communicate with the sibling chains.354	XcmpQueue,355);356 */357358/*359impl pallet_xcm::Config for Runtime {360	type Event = Event;361	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;362	type XcmRouter = XcmRouter;363	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;364	type XcmExecuteFilter = Everything;365	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;366	type XcmTeleportFilter = Everything;367	type XcmReserveTransferFilter = Everything;368	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;369	type LocationInverter = LocationInverter<Ancestry>;370	type Origin = Origin;371	type Call = Call;372	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;373	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;374}375 */376377/*378impl cumulus_pallet_xcm::Config for Runtime {379	type Event = Event;380	type XcmExecutor = XcmExecutor<XcmConfig>;381}382383impl cumulus_pallet_xcmp_queue::Config for Runtime {384	type WeightInfo = ();385	type Event = Event;386	type XcmExecutor = XcmExecutor<XcmConfig>;387	type ChannelInfo = ParachainSystem;388	type VersionWrapper = ();389	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;390	type ControllerOrigin = EnsureRoot<AccountId>;391	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;392}393394impl cumulus_pallet_dmp_queue::Config for Runtime {395	type Event = Event;396	type XcmExecutor = XcmExecutor<XcmConfig>;397	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;398}399 */400401pub struct CurrencyIdConvert;402impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {403	fn convert(id: AssetIds) -> Option<MultiLocation> {404		match id {405			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(406				1,407				X1(Parachain(ParachainInfo::get().into())),408			)),409			AssetIds::NativeAssetId(NativeCurrency::Parent) => Some(MultiLocation::parent()),410			AssetIds::ForeignAssetId(foreign_asset_id) => {411				XcmForeignAssetIdMapping::<Runtime>::get_multi_location(foreign_asset_id)412			}413		}414	}415}416impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {417	fn convert(location: MultiLocation) -> Option<CurrencyId> {418		if location == MultiLocation::here()419			|| location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))420		{421			return Some(AssetIds::NativeAssetId(NativeCurrency::Here));422		}423424		if location == MultiLocation::parent() {425			return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));426		}427428		if let Some(currency_id) =429			XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())430		{431			return Some(currency_id);432		}433434		None435	}436}437438pub fn get_all_module_accounts() -> Vec<AccountId> {439	vec![TreasuryModuleId::get().into_account_truncating()]440}441442pub struct DustRemovalWhitelist;443impl Contains<AccountId> for DustRemovalWhitelist {444	fn contains(a: &AccountId) -> bool {445		get_all_module_accounts().contains(a)446	}447}448449parameter_type_with_key! {450	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {451		match currency_id {452			CurrencyId::NativeAssetId(symbol) => match symbol {453				NativeCurrency::Here => 0,454				NativeCurrency::Parent=> 0,455			},456			_ => 100_000457		}458	};459}460461impl orml_tokens::Config for Runtime {462	type Event = Event;463	type Balance = Balance;464	type Amount = Amount;465	type CurrencyId = CurrencyId;466	type WeightInfo = ();467	type ExistentialDeposits = ExistentialDeposits;468	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;469	type MaxLocks = MaxLocks;470	type MaxReserves = MaxReserves;471	// TODO: Add all module accounts472	type DustRemovalWhitelist = DustRemovalWhitelist;473	/// The id type for named reserves.474	type ReserveIdentifier = ();475	type OnNewTokenAccount = ();476	type OnKilledTokenAccount = ();477}478479parameter_types! {480	pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this481	pub const MaxAssetsForTransfer: usize = 2;482}483484parameter_type_with_key! {485	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {486		Some(100_000_000_000)487	};488}489490pub struct AccountIdToMultiLocation;491impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {492	fn convert(account: AccountId) -> MultiLocation {493		X1(AccountId32 {494			network: NetworkId::Any,495			id: account.into(),496		})497		.into()498	}499}500501impl orml_xtokens::Config for Runtime {502	type Event = Event;503	type Balance = Balance;504	type CurrencyId = CurrencyId;505	type CurrencyIdConvert = CurrencyIdConvert;506	type AccountIdToMultiLocation = AccountIdToMultiLocation;507	type SelfLocation = SelfLocation;508	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;509	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;510	type BaseXcmWeight = BaseXcmWeight;511	type LocationInverter = LocationInverter<Ancestry>;512	type MaxAssetsForTransfer = MaxAssetsForTransfer;513	type MinXcmFee = ParachainMinFee;514	type MultiLocationsFilter = Everything;515	type ReserveProvider = AbsoluteReserveProvider;516}
after · runtime/opal/src/xcm_config.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 cumulus_pallet_xcm;18use frame_support::{19	{match_types, parameter_types, weights::Weight},20	pallet_prelude::Get,21	traits::{Contains, Everything, fungibles},22};23use frame_system::EnsureRoot;24use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};25use pallet_xcm::XcmPassthrough;26use polkadot_parachain::primitives::Sibling;27use sp_runtime::traits::{AccountIdConversion, CheckedConversion, Convert, Zero};28use sp_std::{borrow::Borrow, marker::PhantomData, vec, vec::Vec};29use xcm::{30	latest::{MultiAsset, Xcm},31	prelude::{Concrete, Fungible as XcmFungible},32	v1::{BodyId, Junction::*, Junctions::*, MultiLocation, NetworkId},33};34use xcm_builder::{35	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, EnsureXcmOrigin,36	FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentAsSuperuser, ParentIsPreset,37	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,38	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,39	ConvertedConcreteAssetId,40};41use xcm_executor::{42	{Config, XcmExecutor},43	traits::{Convert as ConvertXcm, FilterAssetLocation, JustTry, MatchesFungible, ShouldExecute},44};4546use up_common::{47	constants::{MAXIMUM_BLOCK_WEIGHT, UNIQUE},48	types::{AccountId, Balance},49};5051use crate::{52	Balances, Call, DmpQueue, Event, ForeingAssets, Origin, ParachainInfo, ParachainSystem,53	PolkadotXcm, Runtime, XcmpQueue,54};55use crate::runtime_common::config::substrate::{TreasuryModuleId, MaxLocks, MaxReserves};56use crate::runtime_common::config::pallets::TreasuryAccountId;57use crate::runtime_common::config::xcm::*;58use crate::*;5960use pallet_foreing_assets::{61	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency, FreeForAll,62	TryAsForeing, ForeignAssetId,63};6465// Signed version of balance66pub type Amount = i128;6768parameter_types! {69	pub const RelayLocation: MultiLocation = MultiLocation::parent();70	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;71	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();72	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();73	pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));74}7576/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,77/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can78/// biases the kind of local `Origin` it will become.79pub type XcmOriginToTransactDispatchOrigin = (80	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location81	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for82	// foreign chains who want to have a local sovereign account on this chain which they control.83	SovereignSignedViaLocation<LocationToAccountId, Origin>,84	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when85	// recognised.86	RelayChainAsNative<RelayOrigin, Origin>,87	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when88	// recognised.89	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,90	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a91	// transaction from the Root origin.92	ParentAsSuperuser<Origin>,93	// Native signed account converter; this just converts an `AccountId32` origin into a normal94	// `Origin::Signed` origin of the same 32-byte value.95	SignedAccountId32AsNative<RelayNetwork, Origin>,96	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.97	XcmPassthrough<Origin>,98);99100parameter_types! {101	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.102	pub UnitWeightCost: Weight = 1_000_000;103	// 1200 UNIQUEs buy 1 second of weight.104	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);105	pub const MaxInstructions: u32 = 100;106	pub const MaxAuthorities: u32 = 100_000;107}108109match_types! {110	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {111		MultiLocation { parents: 1, interior: Here } |112		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }113	};114}115116/// Execution barrier that just takes `max_weight` from `weight_credit`.117///118/// Useful to allow XCM execution by local chain users via extrinsics.119/// E.g. `pallet_xcm::reserve_asset_transfer` to transfer a reserve asset120/// out of the local chain to another one.121pub struct AllowAllDebug;122impl ShouldExecute for AllowAllDebug {123	fn should_execute<Call>(124		_origin: &MultiLocation,125		_message: &mut Xcm<Call>,126		max_weight: Weight,127		weight_credit: &mut Weight,128	) -> Result<(), ()> {129		Ok(())130	}131}132133pub type Barrier = DenyThenTry<134	DenyTransact,135	(136		TakeWeightCredit,137		AllowTopLevelPaidExecutionFrom<Everything>,138		AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,139		// ^^^ Parent & its unit plurality gets free execution140		AllowAllDebug,141	)142>;143144pub struct AllAsset;145impl FilterAssetLocation for AllAsset {146	fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {147		true148	}149}150151pub struct CurrencyIdConvert;152impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {153	fn convert(id: AssetIds) -> Option<MultiLocation> {154		match id {155			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(156				1,157				X1(Parachain(ParachainInfo::get().into())),158			)),159			AssetIds::NativeAssetId(NativeCurrency::Parent) => Some(MultiLocation::parent()),160			AssetIds::ForeignAssetId(foreign_asset_id) => {161				XcmForeignAssetIdMapping::<Runtime>::get_multi_location(foreign_asset_id)162			}163		}164	}165}166impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {167	fn convert(location: MultiLocation) -> Option<CurrencyId> {168		if location == MultiLocation::here()169			|| location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))170		{171			return Some(AssetIds::NativeAssetId(NativeCurrency::Here));172		}173174		if location == MultiLocation::parent() {175			return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));176		}177178		if let Some(currency_id) =179			XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())180		{181			return Some(currency_id);182		}183184		None185	}186}187188pub fn get_all_module_accounts() -> Vec<AccountId> {189	vec![TreasuryModuleId::get().into_account_truncating()]190}191192pub struct DustRemovalWhitelist;193impl Contains<AccountId> for DustRemovalWhitelist {194	fn contains(a: &AccountId) -> bool {195		get_all_module_accounts().contains(a)196	}197}198199parameter_type_with_key! {200	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {201		match currency_id {202			CurrencyId::NativeAssetId(symbol) => match symbol {203				NativeCurrency::Here => 0,204				NativeCurrency::Parent=> 0,205			},206			_ => 100_000207		}208	};209}210211impl orml_tokens::Config for Runtime {212	type Event = Event;213	type Balance = Balance;214	type Amount = Amount;215	type CurrencyId = CurrencyId;216	type WeightInfo = ();217	type ExistentialDeposits = ExistentialDeposits;218	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;219	type MaxLocks = MaxLocks;220	type MaxReserves = MaxReserves;221	// TODO: Add all module accounts222	type DustRemovalWhitelist = DustRemovalWhitelist;223	/// The id type for named reserves.224	type ReserveIdentifier = ();225	type OnNewTokenAccount = ();226	type OnKilledTokenAccount = ();227}228229parameter_types! {230	pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this231	pub const MaxAssetsForTransfer: usize = 2;232}233234parameter_type_with_key! {235	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {236		Some(100_000_000_000)237	};238}239240pub struct AccountIdToMultiLocation;241impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {242	fn convert(account: AccountId) -> MultiLocation {243		X1(AccountId32 {244			network: NetworkId::Any,245			id: account.into(),246		})247		.into()248	}249}250251impl orml_xtokens::Config for Runtime {252	type Event = Event;253	type Balance = Balance;254	type CurrencyId = CurrencyId;255	type CurrencyIdConvert = CurrencyIdConvert;256	type AccountIdToMultiLocation = AccountIdToMultiLocation;257	type SelfLocation = SelfLocation;258	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;259	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;260	type BaseXcmWeight = BaseXcmWeight;261	type LocationInverter = LocationInverter<Ancestry>;262	type MaxAssetsForTransfer = MaxAssetsForTransfer;263	type MinXcmFee = ParachainMinFee;264	type MultiLocationsFilter = Everything;265	type ReserveProvider = AbsoluteReserveProvider;266}
modifiedruntime/quartz/src/xcm_config.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_config.rs
+++ b/runtime/quartz/src/xcm_config.rs
@@ -175,7 +175,6 @@
     type ReserveProvider = AbsoluteReserveProvider;
 }
 
-
 parameter_type_with_key! {
 	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {
 		match currency_id {
@@ -194,7 +193,6 @@
         get_all_module_accounts().contains(a)
     }
 }
-
 
 pub struct CurrencyIdConvert;
 impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {
@@ -209,31 +207,6 @@
         }
     }
 }
-/*
-impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
-    fn convert(location: MultiLocation) -> Option<CurrencyId> {
-        if location == MultiLocation::here()
-            || location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))
-        {
-            return Some(AssetIds::NativeAssetId(NativeCurrency::Here));
-        }
-
-        if location == MultiLocation::parent() {
-            return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));
-        }
-
-        if let Some(currency_id) =
-        XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())
-        {
-            return Some(currency_id);
-        }
-
-        None
-    }
-}
-
- */
-
 
 parameter_types! {
 	pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this