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
before · runtime/common/config/xcm/foreignassets.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::{Contains, Get, fungibles},19	parameter_types,20};21use sp_runtime::traits::Convert;22use xcm::v1::{Junction::*, MultiLocation, Junctions::*};23use xcm::latest::MultiAsset;24use xcm_builder::{FungiblesAdapter, ConvertedConcreteAssetId};25use xcm_executor::traits::{Convert as ConvertXcm, JustTry, FilterAssetLocation};26use pallet_foreign_assets::{27	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, NativeCurrency, FreeForAll, TryAsForeign,28	ForeignAssetId, CurrencyId,29};30use sp_std::{borrow::Borrow, marker::PhantomData};31use crate::{Runtime, Balances, ParachainInfo, PolkadotXcm, ForeignAssets};3233use super::{LocationToAccountId, RelayLocation};3435use up_common::types::{AccountId, Balance};3637parameter_types! {38	pub CheckingAccount: AccountId = PolkadotXcm::check_account();39}4041/// No teleports are allowed42pub struct NoTeleports<AccountId, ForeignAssets>(PhantomData<(AccountId, ForeignAssets)>);4344impl<AccountId, ForeignAssets> Contains<<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId>45	for NoTeleports<AccountId, ForeignAssets>46where47	ForeignAssets: fungibles::Inspect<AccountId>,48{49	fn contains(_id: &<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {50		false51	}52}5354pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);55impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>56	ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>57where58	AssetId: Borrow<AssetId>,59	AssetId: TryAsForeign<AssetId, ForeignAssetId>,60	AssetIds: Borrow<AssetId>,61{62	fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {63		let id = id.borrow();6465		log::trace!(66			target: "xcm::AsInnerId::Convert",67			"AsInnerId {:?}",68			id69		);7071		let parent = MultiLocation::parent();72		let here = MultiLocation::here();73		let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));7475		if *id == parent {76			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent));77		}7879		if *id == here || *id == self_location {80			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here));81		}8283		match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(id.clone()) {84			Some(AssetIds::ForeignAssetId(foreign_asset_id)) => {85				ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id))86			}87			_ => Err(()),88		}89	}9091	fn reverse_ref(what: impl Borrow<AssetId>) -> Result<MultiLocation, ()> {92		log::trace!(93			target: "xcm::AsInnerId::Reverse",94			"AsInnerId",95		);9697		let asset_id = what.borrow();9899		let parent_id =100			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap();101		let here_id =102			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap();103104		if asset_id.clone() == parent_id {105			return Ok(MultiLocation::parent());106		}107108		if asset_id.clone() == here_id {109			return Ok(MultiLocation::new(110				1,111				X1(Parachain(ParachainInfo::get().into())),112			));113		}114115		match <AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(asset_id.clone()) {116			Some(fid) => match XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid) {117				Some(location) => Ok(location),118				None => Err(()),119			},120			None => Err(()),121		}122	}123}124125/// Means for transacting assets besides the native currency on this chain.126pub type FungiblesTransactor = FungiblesAdapter<127	// Use this fungibles implementation:128	ForeignAssets,129	// Use this currency when it is a fungible asset matching the given location or name:130	ConvertedConcreteAssetId<AssetIds, Balance, AsInnerId<AssetIds, JustTry>, JustTry>,131	// Convert an XCM MultiLocation into a local account id:132	LocationToAccountId,133	// Our chain's account ID type (we can't get away without mentioning it explicitly):134	AccountId,135	// No teleports are allowed136	NoTeleports<AccountId, ForeignAssets>,137	// The account to use for tracking teleports.138	CheckingAccount,139>;140141/// Means for transacting assets on this chain.142pub type AssetTransactors = FungiblesTransactor;143144pub struct AllAsset;145impl FilterAssetLocation for AllAsset {146	fn filter_asset_location(_asset: &MultiAsset, _origin: &MultiLocation) -> bool {147		true148	}149}150151pub type IsReserve = AllAsset;152153pub type Trader<T> = FreeForAll<154	pallet_configuration::WeightToFee<T, Balance>,155	RelayLocation,156	AccountId,157	Balances,158	(),159>;160161pub struct CurrencyIdConvert;162impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {163	fn convert(id: AssetIds) -> Option<MultiLocation> {164		match id {165			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(166				1,167				X1(Parachain(ParachainInfo::get().into())),168			)),169			AssetIds::NativeAssetId(NativeCurrency::Parent) => Some(MultiLocation::parent()),170			AssetIds::ForeignAssetId(foreign_asset_id) => {171				XcmForeignAssetIdMapping::<Runtime>::get_multi_location(foreign_asset_id)172			}173		}174	}175}176177impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {178	fn convert(location: MultiLocation) -> Option<CurrencyId> {179		if location == MultiLocation::here()180			|| location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))181		{182			return Some(AssetIds::NativeAssetId(NativeCurrency::Here));183		}184185		if location == MultiLocation::parent() {186			return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));187		}188189		if let Some(currency_id) =190			XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())191		{192			return Some(currency_id);193		}194195		None196	}197}
after · runtime/common/config/xcm/foreignassets.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::{Contains, Get, fungibles},19	parameter_types,20};21use sp_runtime::traits::Convert;22use xcm::latest::{MultiAsset, Junction::*, MultiLocation, Junctions::*};23use xcm_builder::{FungiblesAdapter, ConvertedConcreteAssetId};24use xcm_executor::traits::{Convert as ConvertXcm, JustTry, FilterAssetLocation};25use pallet_foreign_assets::{26	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, NativeCurrency, FreeForAll, TryAsForeign,27	ForeignAssetId, CurrencyId,28};29use sp_std::{borrow::Borrow, marker::PhantomData};30use crate::{Runtime, Balances, ParachainInfo, PolkadotXcm, ForeignAssets};3132use super::{LocationToAccountId, RelayLocation};3334use up_common::types::{AccountId, Balance};3536parameter_types! {37	pub CheckingAccount: AccountId = PolkadotXcm::check_account();38}3940/// No teleports are allowed41pub struct NoTeleports<AccountId, ForeignAssets>(PhantomData<(AccountId, ForeignAssets)>);4243impl<AccountId, ForeignAssets> Contains<<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId>44	for NoTeleports<AccountId, ForeignAssets>45where46	ForeignAssets: fungibles::Inspect<AccountId>,47{48	fn contains(_id: &<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {49		false50	}51}5253pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);54impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>55	ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>56where57	AssetId: Borrow<AssetId>,58	AssetId: TryAsForeign<AssetId, ForeignAssetId>,59	AssetIds: Borrow<AssetId>,60{61	fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {62		let id = id.borrow();6364		log::trace!(65			target: "xcm::AsInnerId::Convert",66			"AsInnerId {:?}",67			id68		);6970		let parent = MultiLocation::parent();71		let here = MultiLocation::here();72		let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));7374		if *id == parent {75			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent));76		}7778		if *id == here || *id == self_location {79			return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here));80		}8182		match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(id.clone()) {83			Some(AssetIds::ForeignAssetId(foreign_asset_id)) => {84				ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id))85			}86			_ => Err(()),87		}88	}8990	fn reverse_ref(what: impl Borrow<AssetId>) -> Result<MultiLocation, ()> {91		log::trace!(92			target: "xcm::AsInnerId::Reverse",93			"AsInnerId",94		);9596		let asset_id = what.borrow();9798		let parent_id =99			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap();100		let here_id =101			ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap();102103		if asset_id.clone() == parent_id {104			return Ok(MultiLocation::parent());105		}106107		if asset_id.clone() == here_id {108			return Ok(MultiLocation::new(109				1,110				X1(Parachain(ParachainInfo::get().into())),111			));112		}113114		match <AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(asset_id.clone()) {115			Some(fid) => match XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid) {116				Some(location) => Ok(location),117				None => Err(()),118			},119			None => Err(()),120		}121	}122}123124/// Means for transacting assets besides the native currency on this chain.125pub type FungiblesTransactor = FungiblesAdapter<126	// Use this fungibles implementation:127	ForeignAssets,128	// Use this currency when it is a fungible asset matching the given location or name:129	ConvertedConcreteAssetId<AssetIds, Balance, AsInnerId<AssetIds, JustTry>, JustTry>,130	// Convert an XCM MultiLocation into a local account id:131	LocationToAccountId,132	// Our chain's account ID type (we can't get away without mentioning it explicitly):133	AccountId,134	// No teleports are allowed135	NoTeleports<AccountId, ForeignAssets>,136	// The account to use for tracking teleports.137	CheckingAccount,138>;139140/// Means for transacting assets on this chain.141pub type AssetTransactors = FungiblesTransactor;142143pub struct AllAsset;144impl FilterAssetLocation for AllAsset {145	fn filter_asset_location(_asset: &MultiAsset, _origin: &MultiLocation) -> bool {146		true147	}148}149150pub type IsReserve = AllAsset;151152pub type Trader<T> = FreeForAll<153	pallet_configuration::WeightToFee<T, Balance>,154	RelayLocation,155	AccountId,156	Balances,157	(),158>;159160pub struct CurrencyIdConvert;161impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {162	fn convert(id: AssetIds) -> Option<MultiLocation> {163		match id {164			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(165				1,166				X1(Parachain(ParachainInfo::get().into())),167			)),168			AssetIds::NativeAssetId(NativeCurrency::Parent) => Some(MultiLocation::parent()),169			AssetIds::ForeignAssetId(foreign_asset_id) => {170				XcmForeignAssetIdMapping::<Runtime>::get_multi_location(foreign_asset_id)171			}172		}173	}174}175176impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {177	fn convert(location: MultiLocation) -> Option<CurrencyId> {178		if location == MultiLocation::here()179			|| location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))180		{181			return Some(AssetIds::NativeAssetId(NativeCurrency::Here));182		}183184		if location == MultiLocation::parent() {185			return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));186		}187188		if let Some(currency_id) =189			XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())190		{191			return Some(currency_id);192		}193194		None195	}196}
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
--- a/runtime/common/config/xcm/nativeassets.rs
+++ b/runtime/common/config/xcm/nativeassets.rs
@@ -19,11 +19,13 @@
 	weights::WeightToFeePolynomial,
 };
 use sp_runtime::traits::{CheckedConversion, Zero, Convert};
-use xcm::v1::{Junction::*, MultiLocation, Junctions::*};
 use xcm::latest::{
 	AssetId::{Concrete},
 	Fungibility::Fungible as XcmFungible,
 	MultiAsset, Error as XcmError, Weight,
+	Junction::*,
+	MultiLocation,
+	Junctions::*,
 };
 use xcm_builder::{CurrencyAdapter, NativeAsset};
 use xcm_executor::{
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,