git.delta.rocks / unique-network / refs/commits / 9b72a3a55cc6

difftreelog

Weight trader removed

Dev2022-08-29parent: #6fb8930.patch.diff
in: master

8 files changed

modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
before · node/cli/src/chain_spec.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 sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};18use sc_service::ChainType;19use sp_core::{sr25519, Pair, Public};20use sp_runtime::traits::{IdentifyAccount, Verify};21use std::collections::BTreeMap;2223use serde::{Deserialize, Serialize};24use serde_json::map::Map;2526use up_common::types::opaque::*;2728#[cfg(feature = "unique-runtime")]29pub use unique_runtime as default_runtime;3031#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]32pub use quartz_runtime as default_runtime;3334#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]35pub use opal_runtime as default_runtime;3637/// The `ChainSpec` parameterized for the unique runtime.38#[cfg(feature = "unique-runtime")]39pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;4041/// The `ChainSpec` parameterized for the quartz runtime.42#[cfg(feature = "quartz-runtime")]43pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;4445/// The `ChainSpec` parameterized for the opal runtime.46pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;4748#[cfg(feature = "unique-runtime")]49pub type DefaultChainSpec = UniqueChainSpec;5051#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]52pub type DefaultChainSpec = QuartzChainSpec;5354#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]55pub type DefaultChainSpec = OpalChainSpec;5657pub enum RuntimeId {58	#[cfg(feature = "unique-runtime")]59	Unique,6061	#[cfg(feature = "quartz-runtime")]62	Quartz,6364	Opal,65	Unknown(String),66}676869#[cfg(not(feature = "unique-runtime"))]70/// PARA_ID for Opal/Quartz71const PARA_ID: u32 = 2095;7273#[cfg(feature = "unique-runtime")]74/// PARA_ID for Unique75const PARA_ID: u32 = 2037;7677pub trait RuntimeIdentification {78	fn runtime_id(&self) -> RuntimeId;79}8081impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {82	fn runtime_id(&self) -> RuntimeId {83		#[cfg(feature = "unique-runtime")]84		if self.id().starts_with("unique") || self.id().starts_with("unq") {85			return RuntimeId::Unique;86		}8788		#[cfg(feature = "quartz-runtime")]89		if self.id().starts_with("quartz") || self.id().starts_with("qtz") {90			return RuntimeId::Quartz;91		}9293		if self.id().starts_with("opal") || self.id() == "dev" || self.id() == "local_testnet" {94			return RuntimeId::Opal;95		}9697		RuntimeId::Unknown(self.id().into())98	}99}100101pub enum ServiceId {102	Prod,103	Dev,104}105106pub trait ServiceIdentification {107	fn service_id(&self) -> ServiceId;108}109110impl ServiceIdentification for Box<dyn sc_service::ChainSpec> {111	fn service_id(&self) -> ServiceId {112		if self.id().ends_with("dev") {113			ServiceId::Dev114		} else {115			ServiceId::Prod116		}117	}118}119120/// Helper function to generate a crypto pair from seed121pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {122	TPublic::Pair::from_string(&format!("//{}", seed), None)123		.expect("static values are valid; qed")124		.public()125}126127/// The extensions for the [`ChainSpec`].128#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]129#[serde(deny_unknown_fields)]130pub struct Extensions {131	/// The relay chain of the Parachain.132	pub relay_chain: String,133	/// The id of the Parachain.134	pub para_id: u32,135}136137impl Extensions {138	/// Try to get the extension from the given `ChainSpec`.139	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {140		sc_chain_spec::get_extension(chain_spec.extensions())141	}142}143144type AccountPublic = <Signature as Verify>::Signer;145146/// Helper function to generate an account ID from seed147pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId148where149	AccountPublic: From<<TPublic::Pair as Pair>::Public>,150{151	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()152}153154macro_rules! testnet_genesis {155	(156		$runtime:path,157		$root_key:expr,158		$initial_authorities:expr,159		$endowed_accounts:expr,160		$id:expr161	) => {{162		use $runtime::*;163164		GenesisConfig {165			system: SystemConfig {166				code: WASM_BINARY167					.expect("WASM binary was not build, please build it!")168					.to_vec(),169			},170			balances: BalancesConfig {171				balances: $endowed_accounts172					.iter()173					.cloned()174					// 1e13 UNQ175					.map(|k| (k, 1 << 100))176					.collect(),177			},178			treasury: Default::default(),179			tokens: TokensConfig { balances: vec![] },180			sudo: SudoConfig {181				key: Some($root_key),182			},183			vesting: VestingConfig { vesting: vec![] },184			parachain_info: ParachainInfoConfig {185				parachain_id: $id.into(),186			},187			parachain_system: Default::default(),188			aura: AuraConfig {189				authorities: $initial_authorities,190			},191			aura_ext: Default::default(),192			evm: EVMConfig {193				accounts: BTreeMap::new(),194			},195			ethereum: EthereumConfig {},196		}197	}};198}199200pub fn development_config() -> DefaultChainSpec {201	let mut properties = Map::new();202	properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());203	properties.insert("tokenDecimals".into(), 18.into());204	properties.insert(205		"ss58Format".into(),206		default_runtime::SS58Prefix::get().into(),207	);208209	DefaultChainSpec::from_genesis(210		// Name211		format!(212			"{}{}",213			default_runtime::RUNTIME_NAME.to_uppercase(),214			if cfg!(feature = "unique-runtime") {215				""216			} else {217				" by UNIQUE"218			}219		)220		.as_str(),221		// ID222		format!("{}_dev", default_runtime::RUNTIME_NAME).as_str(),223		ChainType::Local,224		move || {225			testnet_genesis!(226				default_runtime,227				// Sudo account228				get_account_id_from_seed::<sr25519::Public>("Alice"),229				vec![230					get_from_seed::<AuraId>("Alice"),231					get_from_seed::<AuraId>("Bob"),232				],233				// Pre-funded accounts234				vec![235					get_account_id_from_seed::<sr25519::Public>("Alice"),236					get_account_id_from_seed::<sr25519::Public>("Bob"),237					get_account_id_from_seed::<sr25519::Public>("Charlie"),238					get_account_id_from_seed::<sr25519::Public>("Dave"),239					get_account_id_from_seed::<sr25519::Public>("Eve"),240					get_account_id_from_seed::<sr25519::Public>("Ferdie"),241					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),242					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),243					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),244					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),245					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),246					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),247				],248				PARA_ID249			)250		},251		// Bootnodes252		vec![],253		// Telemetry254		None,255		// Protocol ID256		None,257		None,258		// Properties259		Some(properties),260		// Extensions261		Extensions {262			relay_chain: "rococo-dev".into(),263			para_id: PARA_ID,264		},265	)266}267268pub fn local_testnet_config() -> DefaultChainSpec {269	let mut properties = Map::new();270	properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());271	properties.insert("tokenDecimals".into(), 18.into());272	properties.insert(273		"ss58Format".into(),274		default_runtime::SS58Prefix::get().into(),275	);276277	DefaultChainSpec::from_genesis(278		// Name279		format!(280			"{}{}",281			default_runtime::RUNTIME_NAME.to_uppercase(),282			if cfg!(feature = "unique-runtime") {283				""284			} else {285				" by UNIQUE"286			}287		)288		.as_str(),289		// ID290		format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),291		ChainType::Local,292		move || {293			testnet_genesis!(294				default_runtime,295				// Sudo account296				get_account_id_from_seed::<sr25519::Public>("Alice"),297				vec![298					get_from_seed::<AuraId>("Alice"),299					get_from_seed::<AuraId>("Bob"),300				],301				// Pre-funded accounts302				vec![303					get_account_id_from_seed::<sr25519::Public>("Alice"),304					get_account_id_from_seed::<sr25519::Public>("Bob"),305					get_account_id_from_seed::<sr25519::Public>("Charlie"),306					get_account_id_from_seed::<sr25519::Public>("Dave"),307					get_account_id_from_seed::<sr25519::Public>("Eve"),308					get_account_id_from_seed::<sr25519::Public>("Ferdie"),309					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),310					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),311					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),312					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),313					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),314					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),315				],316				PARA_ID317			)318		},319		// Bootnodes320		vec![],321		// Telemetry322		None,323		// Protocol ID324		None,325		None,326		// Properties327		Some(properties),328		// Extensions329		Extensions {330			relay_chain: "westend-local".into(),331			para_id: PARA_ID,332		},333	)334}
after · node/cli/src/chain_spec.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 sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};18use sc_service::ChainType;19use sp_core::{sr25519, Pair, Public};20use sp_runtime::traits::{IdentifyAccount, Verify};21use std::collections::BTreeMap;2223use serde::{Deserialize, Serialize};24use serde_json::map::Map;2526use up_common::types::opaque::*;2728#[cfg(feature = "unique-runtime")]29pub use unique_runtime as default_runtime;3031#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]32pub use quartz_runtime as default_runtime;3334#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]35pub use opal_runtime as default_runtime;3637/// The `ChainSpec` parameterized for the unique runtime.38#[cfg(feature = "unique-runtime")]39pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;4041/// The `ChainSpec` parameterized for the quartz runtime.42#[cfg(feature = "quartz-runtime")]43pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;4445/// The `ChainSpec` parameterized for the opal runtime.46pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;4748#[cfg(feature = "unique-runtime")]49pub type DefaultChainSpec = UniqueChainSpec;5051#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]52pub type DefaultChainSpec = QuartzChainSpec;5354#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]55pub type DefaultChainSpec = OpalChainSpec;5657pub enum RuntimeId {58	#[cfg(feature = "unique-runtime")]59	Unique,6061	#[cfg(feature = "quartz-runtime")]62	Quartz,6364	Opal,65	Unknown(String),66}6768#[cfg(not(feature = "unique-runtime"))]69/// PARA_ID for Opal/Quartz70const PARA_ID: u32 = 2095;7172#[cfg(feature = "unique-runtime")]73/// PARA_ID for Unique74const PARA_ID: u32 = 2037;7576pub trait RuntimeIdentification {77	fn runtime_id(&self) -> RuntimeId;78}7980impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {81	fn runtime_id(&self) -> RuntimeId {82		#[cfg(feature = "unique-runtime")]83		if self.id().starts_with("unique") || self.id().starts_with("unq") {84			return RuntimeId::Unique;85		}8687		#[cfg(feature = "quartz-runtime")]88		if self.id().starts_with("quartz") || self.id().starts_with("qtz") {89			return RuntimeId::Quartz;90		}9192		if self.id().starts_with("opal") || self.id() == "dev" || self.id() == "local_testnet" {93			return RuntimeId::Opal;94		}9596		RuntimeId::Unknown(self.id().into())97	}98}99100pub enum ServiceId {101	Prod,102	Dev,103}104105pub trait ServiceIdentification {106	fn service_id(&self) -> ServiceId;107}108109impl ServiceIdentification for Box<dyn sc_service::ChainSpec> {110	fn service_id(&self) -> ServiceId {111		if self.id().ends_with("dev") {112			ServiceId::Dev113		} else {114			ServiceId::Prod115		}116	}117}118119/// Helper function to generate a crypto pair from seed120pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {121	TPublic::Pair::from_string(&format!("//{}", seed), None)122		.expect("static values are valid; qed")123		.public()124}125126/// The extensions for the [`ChainSpec`].127#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]128#[serde(deny_unknown_fields)]129pub struct Extensions {130	/// The relay chain of the Parachain.131	pub relay_chain: String,132	/// The id of the Parachain.133	pub para_id: u32,134}135136impl Extensions {137	/// Try to get the extension from the given `ChainSpec`.138	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {139		sc_chain_spec::get_extension(chain_spec.extensions())140	}141}142143type AccountPublic = <Signature as Verify>::Signer;144145/// Helper function to generate an account ID from seed146pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId147where148	AccountPublic: From<<TPublic::Pair as Pair>::Public>,149{150	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()151}152153macro_rules! testnet_genesis {154	(155		$runtime:path,156		$root_key:expr,157		$initial_authorities:expr,158		$endowed_accounts:expr,159		$id:expr160	) => {{161		use $runtime::*;162163		GenesisConfig {164			system: SystemConfig {165				code: WASM_BINARY166					.expect("WASM binary was not build, please build it!")167					.to_vec(),168			},169			balances: BalancesConfig {170				balances: $endowed_accounts171					.iter()172					.cloned()173					// 1e13 UNQ174					.map(|k| (k, 1 << 100))175					.collect(),176			},177			treasury: Default::default(),178			tokens: TokensConfig { balances: vec![] },179			sudo: SudoConfig {180				key: Some($root_key),181			},182			vesting: VestingConfig { vesting: vec![] },183			parachain_info: ParachainInfoConfig {184				parachain_id: $id.into(),185			},186			parachain_system: Default::default(),187			aura: AuraConfig {188				authorities: $initial_authorities,189			},190			aura_ext: Default::default(),191			evm: EVMConfig {192				accounts: BTreeMap::new(),193			},194			ethereum: EthereumConfig {},195		}196	}};197}198199pub fn development_config() -> DefaultChainSpec {200	let mut properties = Map::new();201	properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());202	properties.insert("tokenDecimals".into(), 18.into());203	properties.insert(204		"ss58Format".into(),205		default_runtime::SS58Prefix::get().into(),206	);207208	DefaultChainSpec::from_genesis(209		// Name210		format!(211			"{}{}",212			default_runtime::RUNTIME_NAME.to_uppercase(),213			if cfg!(feature = "unique-runtime") {214				""215			} else {216				" by UNIQUE"217			}218		)219		.as_str(),220		// ID221		format!("{}_dev", default_runtime::RUNTIME_NAME).as_str(),222		ChainType::Local,223		move || {224			testnet_genesis!(225				default_runtime,226				// Sudo account227				get_account_id_from_seed::<sr25519::Public>("Alice"),228				vec![229					get_from_seed::<AuraId>("Alice"),230					get_from_seed::<AuraId>("Bob"),231				],232				// Pre-funded accounts233				vec![234					get_account_id_from_seed::<sr25519::Public>("Alice"),235					get_account_id_from_seed::<sr25519::Public>("Bob"),236					get_account_id_from_seed::<sr25519::Public>("Charlie"),237					get_account_id_from_seed::<sr25519::Public>("Dave"),238					get_account_id_from_seed::<sr25519::Public>("Eve"),239					get_account_id_from_seed::<sr25519::Public>("Ferdie"),240					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),241					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),242					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),243					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),244					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),245					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),246				],247				PARA_ID248			)249		},250		// Bootnodes251		vec![],252		// Telemetry253		None,254		// Protocol ID255		None,256		None,257		// Properties258		Some(properties),259		// Extensions260		Extensions {261			relay_chain: "rococo-dev".into(),262			para_id: PARA_ID,263		},264	)265}266267pub fn local_testnet_config() -> DefaultChainSpec {268	let mut properties = Map::new();269	properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());270	properties.insert("tokenDecimals".into(), 18.into());271	properties.insert(272		"ss58Format".into(),273		default_runtime::SS58Prefix::get().into(),274	);275276	DefaultChainSpec::from_genesis(277		// Name278		format!(279			"{}{}",280			default_runtime::RUNTIME_NAME.to_uppercase(),281			if cfg!(feature = "unique-runtime") {282				""283			} else {284				" by UNIQUE"285			}286		)287		.as_str(),288		// ID289		format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),290		ChainType::Local,291		move || {292			testnet_genesis!(293				default_runtime,294				// Sudo account295				get_account_id_from_seed::<sr25519::Public>("Alice"),296				vec![297					get_from_seed::<AuraId>("Alice"),298					get_from_seed::<AuraId>("Bob"),299				],300				// Pre-funded accounts301				vec![302					get_account_id_from_seed::<sr25519::Public>("Alice"),303					get_account_id_from_seed::<sr25519::Public>("Bob"),304					get_account_id_from_seed::<sr25519::Public>("Charlie"),305					get_account_id_from_seed::<sr25519::Public>("Dave"),306					get_account_id_from_seed::<sr25519::Public>("Eve"),307					get_account_id_from_seed::<sr25519::Public>("Ferdie"),308					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),309					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),310					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),311					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),312					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),313					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),314				],315				PARA_ID316			)317		},318		// Bootnodes319		vec![],320		// Telemetry321		None,322		// Protocol ID323		None,324		None,325		// Properties326		Some(properties),327		// Extensions328		Extensions {329			relay_chain: "westend-local".into(),330			para_id: PARA_ID,331		},332	)333}
modifiedpallets/foreing-assets/src/lib.rsdiffbeforeafterboth
--- a/pallets/foreing-assets/src/lib.rs
+++ b/pallets/foreing-assets/src/lib.rs
@@ -458,7 +458,7 @@
 
 use xcm::latest::{Fungibility::Fungible as XcmFungible};
 
-pub struct UsingAnyCurrencyComponents<
+pub struct FreeForAll<
 	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
 	AssetId: Get<MultiLocation>,
 	AccountId,
@@ -476,8 +476,7 @@
 		AccountId,
 		Currency: CurrencyT<AccountId>,
 		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
-	> WeightTrader
-	for UsingAnyCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+	> WeightTrader for FreeForAll<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
 {
 	fn new() -> Self {
 		Self(0, Zero::zero(), PhantomData)
@@ -485,46 +484,7 @@
 
 	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
 		log::trace!(target: "fassets::weight", "buy_weight weight: {:?}, payment: {:?}", weight, payment);
-
-		let amount: Currency::Balance = (0 as u32).into();
-		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
-
-		let asset_id = payment
-			.fungible
-			.iter()
-			.next()
-			.map_or(Err(XcmError::TooExpensive), |v| Ok(v.0))?;
-
-		// First fungible pays fee
-		let required = MultiAsset {
-			id: asset_id.clone(),
-			fun: XcmFungible(u128_amount),
-		};
-
-		log::trace!(
-			target: "fassets::weight", "buy_weight payment: {:?}, required: {:?}",
-			payment, required,
-		);
-
-		let unused = payment
-			.checked_sub(required)
-			.map_err(|_| XcmError::TooExpensive)?;
-		self.0 = self.0.saturating_add(weight);
-		self.1 = self.1.saturating_add(amount);
-		Ok(unused)
-	}
-
-	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
-		let weight = weight.min(self.0);
-		let amount = WeightToFee::weight_to_fee(&weight);
-		self.0 -= weight;
-		self.1 = self.1.saturating_sub(amount);
-		let amount: u128 = amount.saturated_into();
-		if amount > 0 {
-			Some((AssetId::get(), amount).into())
-		} else {
-			None
-		}
+		Ok(payment)
 	}
 }
 impl<
@@ -533,7 +493,7 @@
 		AccountId,
 		Currency: CurrencyT<AccountId>,
 		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
-	> Drop for UsingAnyCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+	> Drop for FreeForAll<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
 {
 	fn drop(&mut self) {
 		OnUnbalanced::on_unbalanced(Currency::issue(self.1));
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -171,10 +171,9 @@
 	/// Foreign collection flag
 	#[pallet::storage]
 	pub type ForeignCollection<T: Config> =
-	StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = bool, QueryKind = ValueQuery>;
+		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = bool, QueryKind = ValueQuery>;
 }
 
-
 /// Wrapper around untyped collection handle, asserting inner collection is of fungible type.
 /// Required for interaction with Fungible collections, type safety and implementation [`solidity_interface`][`evm_coder::solidity_interface`].
 pub struct FungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);
@@ -340,7 +339,7 @@
 				to: H160::default(),
 				value: amount.into(),
 			}
-				.to_log(collection_id_to_address(collection.id)),
+			.to_log(collection_id_to_address(collection.id)),
 		);
 		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
 			collection.id,
@@ -560,7 +559,7 @@
 					to: *user.as_eth(),
 					value: amount.into(),
 				}
-					.to_log(collection_id_to_address(collection.id)),
+				.to_log(collection_id_to_address(collection.id)),
 			);
 			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
 				collection.id,
modifiedruntime/common/config/pallets/foreign_asset.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/foreign_asset.rs
+++ b/runtime/common/config/pallets/foreign_asset.rs
@@ -2,8 +2,8 @@
 use up_common::types::AccountId;
 
 impl pallet_foreing_assets::Config for Runtime {
-    type Event = Event;
-    type Currency = Balances;
-    type RegisterOrigin = frame_system::EnsureRoot<AccountId>;
-    type WeightInfo = ();
+	type Event = Event;
+	type Currency = Balances;
+	type RegisterOrigin = frame_system::EnsureRoot<AccountId>;
+	type WeightInfo = ();
 }
modifiedruntime/common/config/xcm.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm.rs
+++ b/runtime/common/config/xcm.rs
@@ -16,8 +16,8 @@
 
 use frame_support::{
 	traits::{
-		Contains, tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get, Everything,
-		fungibles,
+		Contains, tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get,
+		Everything, fungibles,
 	},
 	weights::{Weight, WeightToFeePolynomial, WeightToFee},
 	parameter_types, match_types,
@@ -37,21 +37,23 @@
 };
 use xcm_builder::{
 	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
-	FixedWeightBounds, FungiblesAdapter, LocationInverter, NativeAsset, ParentAsSuperuser, RelayChainAsNative,
-	SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
-	SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, ParentIsPreset,
-	ConvertedConcreteAssetId
+	FixedWeightBounds, FungiblesAdapter, LocationInverter, NativeAsset, ParentAsSuperuser,
+	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
+	ParentIsPreset, ConvertedConcreteAssetId,
 };
 use xcm_executor::{Config, XcmExecutor, Assets};
-use xcm_executor::traits::{Convert as ConvertXcm, JustTry, MatchesFungible, WeightTrader, FilterAssetLocation};
+use xcm_executor::traits::{
+	Convert as ConvertXcm, JustTry, MatchesFungible, WeightTrader, FilterAssetLocation,
+};
 use pallet_foreing_assets::{
-	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency,
-	UsingAnyCurrencyComponents, TryAsForeing, ForeignAssetId,
+	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency, FreeForAll,
+	TryAsForeing, ForeignAssetId,
 };
 use sp_std::{borrow::Borrow, marker::PhantomData, vec, vec::Vec};
 use crate::{
 	Runtime, Call, Event, Origin, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, XcmpQueue,
-	xcm_config::Barrier
+	xcm_config::Barrier,
 };
 #[cfg(feature = "foreign-assets")]
 use crate::ForeingAssets;
@@ -83,8 +85,22 @@
 pub struct OnlySelfCurrency;
 impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
 	fn matches_fungible(a: &MultiAsset) -> Option<B> {
+		let paraid = Parachain(ParachainInfo::parachain_id().into());
 		match (&a.id, &a.fun) {
-			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
+			(
+				Concrete(MultiLocation {
+					parents: 1,
+					interior: X1(loc),
+				}),
+				XcmFungible(ref amount),
+			) if paraid == *loc => CheckedConversion::checked_from(*amount),
+			(
+				Concrete(MultiLocation {
+					parents: 0,
+					interior: Here,
+				}),
+				XcmFungible(ref amount),
+			) => CheckedConversion::checked_from(*amount),
 			_ => None,
 		}
 	}
@@ -188,48 +204,7 @@
 	}
 
 	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
-		let amount: Currency::Balance = (0 as u32).into();
-		//let amount = WeightToFee::weight_to_fee(&weight);
-		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
-
-		// location to this parachain through relay chain
-		let option1: xcm::v1::AssetId = Concrete(MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(ParachainInfo::parachain_id().into())),
-		});
-		// direct location
-		let option2: xcm::v1::AssetId = Concrete(MultiLocation {
-			parents: 0,
-			interior: Here,
-		});
-
-		let required = if payment.fungible.contains_key(&option1) {
-			(option1, u128_amount).into()
-		} else if payment.fungible.contains_key(&option2) {
-			(option2, u128_amount).into()
-		} else {
-			(Concrete(MultiLocation::default()), u128_amount).into()
-		};
-
-		let unused = payment
-			.checked_sub(required)
-			.map_err(|_| XcmError::TooExpensive)?;
-		self.0 = self.0.saturating_add(weight);
-		self.1 = self.1.saturating_add(amount);
-		Ok(unused)
-	}
-
-	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
-		let weight = weight.min(self.0);
-		let amount = WeightToFee::weight_to_fee(&weight);
-		self.0 -= weight;
-		self.1 = self.1.saturating_sub(amount);
-		let amount: u128 = amount.saturated_into();
-		if amount > 0 {
-			Some((AssetId::get(), amount).into())
-		} else {
-			None
-		}
+		Ok(payment)
 	}
 }
 impl<
@@ -255,9 +230,9 @@
 
 #[cfg(feature = "foreign-assets")]
 impl<AccountId, ForeingAssets> Contains<<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId>
-for NonZeroIssuance<AccountId, ForeingAssets>
-	where
-		ForeingAssets: fungibles::Inspect<AccountId>,
+	for NonZeroIssuance<AccountId, ForeingAssets>
+where
+	ForeingAssets: fungibles::Inspect<AccountId>,
 {
 	fn contains(id: &<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
 		!ForeingAssets::total_issuance(*id).is_zero()
@@ -268,11 +243,11 @@
 pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);
 #[cfg(feature = "foreign-assets")]
 impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>
-ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>
-	where
-		AssetId: Borrow<AssetId>,
-		AssetId: TryAsForeing<AssetId, ForeignAssetId>,
-		AssetIds: Borrow<AssetId>,
+	ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>
+where
+	AssetId: Borrow<AssetId>,
+	AssetId: TryAsForeing<AssetId, ForeignAssetId>,
+	AssetIds: Borrow<AssetId>,
 {
 	fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {
 		let id = id.borrow();
@@ -377,10 +352,13 @@
 pub type IsReserve = NativeAsset;
 
 #[cfg(feature = "foreign-assets")]
-type Trader<T> =
-	UsingAnyCurrencyComponents<
-		pallet_configuration::WeightToFee<T, Balance>,
-		RelayLocation, AccountId, Balances, ()>;
+type Trader<T> = FreeForAll<
+	pallet_configuration::WeightToFee<T, Balance>,
+	RelayLocation,
+	AccountId,
+	Balances,
+	(),
+>;
 #[cfg(not(feature = "foreign-assets"))]
 type Trader<T> = UsingOnlySelfCurrencyComponents<
 	pallet_configuration::WeightToFee<T, Balance>,
@@ -451,4 +429,3 @@
 	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
 	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
 }
-
modifiedruntime/opal/src/xcm_config.rsdiffbeforeafterboth
--- a/runtime/opal/src/xcm_config.rs
+++ b/runtime/opal/src/xcm_config.rs
@@ -32,9 +32,9 @@
 	v1::{BodyId, Junction::*, Junctions::*, MultiLocation, NetworkId},
 };
 use xcm_builder::{
-	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
-	EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentAsSuperuser,
-	ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, EnsureXcmOrigin,
+	FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentAsSuperuser, ParentIsPreset,
+	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
 	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
 	ConvertedConcreteAssetId,
 };
@@ -49,8 +49,8 @@
 };
 
 use crate::{
-	Balances, Call, DmpQueue, Event, ForeingAssets, Origin, ParachainInfo,
-	ParachainSystem, PolkadotXcm, Runtime, XcmpQueue,
+	Balances, Call, DmpQueue, Event, ForeingAssets, Origin, ParachainInfo, ParachainSystem,
+	PolkadotXcm, Runtime, XcmpQueue,
 };
 use crate::runtime_common::config::substrate::{TreasuryModuleId, MaxLocks, MaxReserves};
 use crate::runtime_common::config::pallets::TreasuryAccountId;
@@ -58,8 +58,8 @@
 use crate::*;
 
 use pallet_foreing_assets::{
-	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency,
-	UsingAnyCurrencyComponents, TryAsForeing, ForeignAssetId,
+	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency, FreeForAll,
+	TryAsForeing, ForeignAssetId,
 };
 
 // Signed version of balance
@@ -330,7 +330,7 @@
 	type Barrier = Barrier;
 	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
 	type Trader =
-		UsingAnyCurrencyComponents<LinearFee<Balance>, RelayLocation, AccountId, Balances, ()>;
+		FreeForAll<LinearFee<Balance>, RelayLocation, AccountId, Balances, ()>;
 	type ResponseHandler = (); // Don't handle responses for now.
 	type SubscriptionService = PolkadotXcm;
 	type AssetTrap = PolkadotXcm;
modifiedruntime/quartz/src/xcm_config.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_config.rs
+++ b/runtime/quartz/src/xcm_config.rs
@@ -50,7 +50,7 @@
 };
 use pallet_foreing_assets::{
     AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency,
-    UsingAnyCurrencyComponents, TryAsForeing, ForeignAssetId,
+    FreeForAll, TryAsForeing, ForeignAssetId,
 };
 use crate::{
     Balances, Call, DmpQueue, Event, Origin, ParachainInfo,
modifiedruntime/unique/src/xcm_config.rsdiffbeforeafterboth
--- a/runtime/unique/src/xcm_config.rs
+++ b/runtime/unique/src/xcm_config.rs
@@ -50,7 +50,7 @@
 };
 use pallet_foreing_assets::{
     AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, CurrencyId, NativeCurrency,
-    UsingAnyCurrencyComponents, TryAsForeing, ForeignAssetId,
+    FreeForAll, TryAsForeing, ForeignAssetId,
 };
 use crate::{
     Balances, Call, DmpQueue, Event, Origin, ParachainInfo,