git.delta.rocks / unique-network / refs/commits / 2477690c31b6

difftreelog

fix use latest xcm version in imports

Daniel Shiposha2023-01-25parent: #40455c4.patch.diff
in: master

11 files changed

modifiedpallets/configuration/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/configuration/src/benchmarking.rs
+++ b/pallets/configuration/src/benchmarking.rs
@@ -20,7 +20,7 @@
 use frame_benchmarking::benchmarks;
 use frame_system::{EventRecord, RawOrigin};
 use frame_support::{assert_ok, BoundedVec, traits::Currency};
-use xcm::v1::MultiLocation;
+use xcm::latest::MultiLocation;
 
 fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
 	let events = frame_system::Pallet::<T>::events();
modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -47,7 +47,7 @@
 		BoundedVec, log,
 	};
 	use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};
-	use xcm::v1::MultiLocation;
+	use xcm::latest::MultiLocation;
 
 	pub use crate::weights::WeightInfo;
 	pub type BalanceOf<T> =
modifiedpallets/foreign-assets/src/lib.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/lib.rs
+++ b/pallets/foreign-assets/src/lib.rs
@@ -52,10 +52,10 @@
 use sp_std::{boxed::Box, vec::Vec};
 use up_data_structs::{CollectionId, TokenId, CreateCollectionData};
 
-// NOTE:v1::MultiLocation is used in storages, we would need to do migration if upgrade the
-// MultiLocation in the future.
+// NOTE: MultiLocation is used in storages, we will need to do migration if upgrade the
+// MultiLocation to the XCM v3.
 use xcm::opaque::latest::{prelude::XcmError, Weight};
-use xcm::{v1::MultiLocation, VersionedMultiLocation};
+use xcm::{latest::MultiLocation, VersionedMultiLocation};
 use xcm_executor::{traits::WeightTrader, Assets};
 
 use pallet_common::erc::CrossAccountId;
modifiedruntime/common/config/orml.rsdiffbeforeafterboth
--- a/runtime/common/config/orml.rs
+++ b/runtime/common/config/orml.rs
@@ -21,8 +21,7 @@
 use frame_system::EnsureSigned;
 use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};
 use sp_runtime::traits::Convert;
-use xcm::v1::{Junction::*, Junctions::*, MultiLocation, NetworkId};
-use xcm::latest::Weight;
+use xcm::latest::{Weight, Junction::*, Junctions::*, MultiLocation, NetworkId};
 use xcm_builder::LocationInverter;
 use xcm_executor::XcmExecutor;
 use sp_std::{vec, vec::Vec};
modifiedruntime/common/config/xcm/foreignassets.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/foreignassets.rs
+++ b/runtime/common/config/xcm/foreignassets.rs
@@ -19,8 +19,7 @@
 	parameter_types,
 };
 use sp_runtime::traits::Convert;
-use xcm::v1::{Junction::*, MultiLocation, Junctions::*};
-use xcm::latest::MultiAsset;
+use xcm::latest::{MultiAsset, Junction::*, MultiLocation, Junctions::*};
 use xcm_builder::{FungiblesAdapter, ConvertedConcreteAssetId};
 use xcm_executor::traits::{Convert as ConvertXcm, JustTry, FilterAssetLocation};
 use pallet_foreign_assets::{
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -21,8 +21,7 @@
 use frame_system::EnsureRoot;
 use pallet_xcm::XcmPassthrough;
 use polkadot_parachain::primitives::Sibling;
-use xcm::v1::{Junction::*, MultiLocation, NetworkId};
-use xcm::latest::{prelude::*, Weight};
+use xcm::latest::{prelude::*, Weight, MultiLocation, NetworkId};
 use xcm_builder::{
 	AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, ParentAsSuperuser,
 	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
modifiedruntime/common/config/xcm/nativeassets.rsdiffbeforeafterboth
before · runtime/common/config/xcm/nativeassets.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	traits::{tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get},19	weights::WeightToFeePolynomial,20};21use sp_runtime::traits::{CheckedConversion, Zero, Convert};22use xcm::v1::{Junction::*, MultiLocation, Junctions::*};23use xcm::latest::{24	AssetId::{Concrete},25	Fungibility::Fungible as XcmFungible,26	MultiAsset, Error as XcmError, Weight,27};28use xcm_builder::{CurrencyAdapter, NativeAsset};29use xcm_executor::{30	Assets,31	traits::{MatchesFungible, WeightTrader},32};33use pallet_foreign_assets::{AssetIds, NativeCurrency};34use sp_std::marker::PhantomData;35use crate::{Balances, ParachainInfo};36use super::{LocationToAccountId, RelayLocation};3738use up_common::types::{AccountId, Balance};3940pub struct OnlySelfCurrency;41impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {42	fn matches_fungible(a: &MultiAsset) -> Option<B> {43		let paraid = Parachain(ParachainInfo::parachain_id().into());44		match (&a.id, &a.fun) {45			(46				Concrete(MultiLocation {47					parents: 1,48					interior: X1(loc),49				}),50				XcmFungible(ref amount),51			) if paraid == *loc => CheckedConversion::checked_from(*amount),52			(53				Concrete(MultiLocation {54					parents: 0,55					interior: Here,56				}),57				XcmFungible(ref amount),58			) => CheckedConversion::checked_from(*amount),59			_ => None,60		}61	}62}6364/// Means for transacting assets on this chain.65pub type LocalAssetTransactor = CurrencyAdapter<66	// Use this currency:67	Balances,68	// Use this currency when it is a fungible asset matching the given location or name:69	OnlySelfCurrency,70	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:71	LocationToAccountId,72	// Our chain's account ID type (we can't get away without mentioning it explicitly):73	AccountId,74	// We don't track any teleports.75	(),76>;7778pub type AssetTransactors = LocalAssetTransactor;7980pub type IsReserve = NativeAsset;8182pub struct UsingOnlySelfCurrencyComponents<83	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,84	AssetId: Get<MultiLocation>,85	AccountId,86	Currency: CurrencyT<AccountId>,87	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,88>(89	Weight,90	Currency::Balance,91	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,92);93impl<94		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,95		AssetId: Get<MultiLocation>,96		AccountId,97		Currency: CurrencyT<AccountId>,98		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,99	> WeightTrader100	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>101{102	fn new() -> Self {103		Self(0, Zero::zero(), PhantomData)104	}105106	fn buy_weight(&mut self, _weight: Weight, payment: Assets) -> Result<Assets, XcmError> {107		Ok(payment)108	}109}110impl<111		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,112		AssetId: Get<MultiLocation>,113		AccountId,114		Currency: CurrencyT<AccountId>,115		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,116	> Drop117	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>118{119	fn drop(&mut self) {120		OnUnbalanced::on_unbalanced(Currency::issue(self.1));121	}122}123124pub type Trader<T> = UsingOnlySelfCurrencyComponents<125	pallet_configuration::WeightToFee<T, Balance>,126	RelayLocation,127	AccountId,128	Balances,129	(),130>;131132pub struct CurrencyIdConvert;133impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {134	fn convert(id: AssetIds) -> Option<MultiLocation> {135		match id {136			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(137				1,138				X1(Parachain(ParachainInfo::get().into())),139			)),140			_ => None,141		}142	}143}
after · runtime/common/config/xcm/nativeassets.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	traits::{tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get},19	weights::WeightToFeePolynomial,20};21use sp_runtime::traits::{CheckedConversion, Zero, Convert};22use xcm::latest::{23	AssetId::{Concrete},24	Fungibility::Fungible as XcmFungible,25	MultiAsset, Error as XcmError, Weight,26	Junction::*,27	MultiLocation,28	Junctions::*,29};30use xcm_builder::{CurrencyAdapter, NativeAsset};31use xcm_executor::{32	Assets,33	traits::{MatchesFungible, WeightTrader},34};35use pallet_foreign_assets::{AssetIds, NativeCurrency};36use sp_std::marker::PhantomData;37use crate::{Balances, ParachainInfo};38use super::{LocationToAccountId, RelayLocation};3940use up_common::types::{AccountId, Balance};4142pub struct OnlySelfCurrency;43impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {44	fn matches_fungible(a: &MultiAsset) -> Option<B> {45		let paraid = Parachain(ParachainInfo::parachain_id().into());46		match (&a.id, &a.fun) {47			(48				Concrete(MultiLocation {49					parents: 1,50					interior: X1(loc),51				}),52				XcmFungible(ref amount),53			) if paraid == *loc => CheckedConversion::checked_from(*amount),54			(55				Concrete(MultiLocation {56					parents: 0,57					interior: Here,58				}),59				XcmFungible(ref amount),60			) => CheckedConversion::checked_from(*amount),61			_ => None,62		}63	}64}6566/// Means for transacting assets on this chain.67pub type LocalAssetTransactor = CurrencyAdapter<68	// Use this currency:69	Balances,70	// Use this currency when it is a fungible asset matching the given location or name:71	OnlySelfCurrency,72	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:73	LocationToAccountId,74	// Our chain's account ID type (we can't get away without mentioning it explicitly):75	AccountId,76	// We don't track any teleports.77	(),78>;7980pub type AssetTransactors = LocalAssetTransactor;8182pub type IsReserve = NativeAsset;8384pub struct UsingOnlySelfCurrencyComponents<85	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,86	AssetId: Get<MultiLocation>,87	AccountId,88	Currency: CurrencyT<AccountId>,89	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,90>(91	Weight,92	Currency::Balance,93	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,94);95impl<96		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,97		AssetId: Get<MultiLocation>,98		AccountId,99		Currency: CurrencyT<AccountId>,100		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,101	> WeightTrader102	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>103{104	fn new() -> Self {105		Self(0, Zero::zero(), PhantomData)106	}107108	fn buy_weight(&mut self, _weight: Weight, payment: Assets) -> Result<Assets, XcmError> {109		Ok(payment)110	}111}112impl<113		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,114		AssetId: Get<MultiLocation>,115		AccountId,116		Currency: CurrencyT<AccountId>,117		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,118	> Drop119	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>120{121	fn drop(&mut self) {122		OnUnbalanced::on_unbalanced(Currency::issue(self.1));123	}124}125126pub type Trader<T> = UsingOnlySelfCurrencyComponents<127	pallet_configuration::WeightToFee<T, Balance>,128	RelayLocation,129	AccountId,130	Balances,131	(),132>;133134pub struct CurrencyIdConvert;135impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {136	fn convert(id: AssetIds) -> Option<MultiLocation> {137		match id {138			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(139				1,140				X1(Parachain(ParachainInfo::get().into())),141			)),142			_ => None,143		}144	}145}
modifiedruntime/common/xcm.rsdiffbeforeafterboth
--- a/runtime/common/xcm.rs
+++ b/runtime/common/xcm.rs
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use sp_std::{vec::Vec, marker::PhantomData};
-use xcm::v1::MultiLocation;
+use xcm::latest::MultiLocation;
 use frame_support::traits::Get;
 
 pub struct OverridableAllowedLocations<T, L>(PhantomData<(T, L)>)
modifiedruntime/opal/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/opal/src/xcm_barrier.rs
+++ b/runtime/opal/src/xcm_barrier.rs
@@ -15,10 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::traits::Everything;
-use xcm::{
-	latest::{Xcm, Weight},
-	v1::MultiLocation,
-};
+use xcm::latest::{Xcm, Weight, MultiLocation};
 use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit};
 use xcm_executor::traits::ShouldExecute;
 
modifiedruntime/quartz/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -19,7 +19,7 @@
 	traits::{Get, Everything},
 };
 use sp_std::{vec, vec::Vec};
-use xcm::v1::{Junction::*, Junctions::*, MultiLocation};
+use xcm::latest::{Junction::*, Junctions::*, MultiLocation};
 use xcm_builder::{
 	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom,
modifiedruntime/unique/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/unique/src/xcm_barrier.rs
+++ b/runtime/unique/src/xcm_barrier.rs
@@ -19,7 +19,7 @@
 	traits::{Get, Everything},
 };
 use sp_std::{vec, vec::Vec};
-use xcm::v1::{Junction::*, Junctions::*, MultiLocation};
+use xcm::latest::{Junction::*, Junctions::*, MultiLocation};
 use xcm_builder::{
 	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom,