Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Nov 11, 2024
1 parent 0abe6f9 commit 4189356
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
24 changes: 0 additions & 24 deletions tokens/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,6 @@ thread_local! {
]);
}

pub struct TenToFourteen;
impl SortedMembers<AccountId> for TenToFourteen {
fn sorted_members() -> Vec<AccountId> {
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);
Expand Down
26 changes: 23 additions & 3 deletions xtokens/src/mock/para_relative_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -115,6 +116,25 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
}

pub struct MultiNativeAsset<ReserveProvider>(PhantomData<ReserveProvider>);
impl<ReserveProvider> ContainsPair<Asset, Location> for MultiNativeAsset<ReserveProvider>
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;
Expand Down

0 comments on commit 4189356

Please sign in to comment.