diff --git a/tokens/src/mock.rs b/tokens/src/mock.rs index ad9afb909..56ee19b78 100644 --- a/tokens/src/mock.rs +++ b/tokens/src/mock.rs @@ -56,30 +56,6 @@ thread_local! { ]); } -pub struct TenToFourteen; -impl SortedMembers for TenToFourteen { - fn sorted_members() -> Vec { - TEN_TO_FOURTEEN.with(|v| v.borrow().clone()) - } - #[cfg(feature = "runtime-benchmarks")] - fn add(new: &AccountId) { - TEN_TO_FOURTEEN.with(|v| { - let mut members = v.borrow_mut(); - members.push(new.clone()); - members.sort(); - }) - } -} - -impl ContainsLengthBound for TenToFourteen { - fn max_len() -> usize { - TEN_TO_FOURTEEN.with(|v| v.borrow().len()) - } - fn min_len() -> usize { - 0 - } -} - parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); pub const Burn: Permill = Permill::from_percent(50); diff --git a/xtokens/src/mock/para_relative_view.rs b/xtokens/src/mock/para_relative_view.rs index f912eaf58..360c43ebc 100644 --- a/xtokens/src/mock/para_relative_view.rs +++ b/xtokens/src/mock/para_relative_view.rs @@ -3,7 +3,7 @@ use crate as orml_xtokens; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{ConstU128, ConstU32, Contains, Everything, Get, Nothing}, + traits::{ConstU128, ConstU32, Contains, ContainsPair, Everything, Get, Nothing}, }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; @@ -12,6 +12,7 @@ use sp_runtime::{ traits::{Convert, IdentityLookup}, AccountId32, BoundedVec, }; +use sp_std::marker::PhantomData; use xcm::v4::{prelude::*, Weight}; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, @@ -22,10 +23,10 @@ use xcm_executor::{Config, XcmExecutor}; use crate::mock::AllTokensAreCreatedEqualToWeight; use orml_traits::{ - location::{AbsoluteReserveProvider, RelativeReserveProvider}, + location::{AbsoluteReserveProvider, RelativeReserveProvider, Reservegit}, parameter_type_with_key, }; -use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}; +use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter}; pub type AccountId = AccountId32; @@ -115,6 +116,25 @@ parameter_types! { pub const MaxAssetsIntoHolding: u32 = 64; } +pub struct MultiNativeAsset(PhantomData); +impl ContainsPair for MultiNativeAsset +where + ReserveProvider: Reserve, +{ + fn contains(asset: &Asset, origin: &Location) -> bool { + if let Some(ref reserve) = ReserveProvider::reserve(asset) { + if reserve == origin { + return true; + } + } + // allow parachain to be reserved of relay to bypass https://github.com/paritytech/polkadot-sdk/pull/5660 + if asset.id.0 == Location::parent() { + return true; + } + false + } +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall;