Skip to content

Commit

Permalink
get tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Nov 10, 2024
1 parent 7506400 commit 0abe6f9
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions xtokens/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate as orml_xtokens;

use frame_support::{
construct_runtime, derive_impl, ensure, 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 @@ -16,7 +16,7 @@ use sp_runtime::{
traits::{Convert, IdentityLookup},
AccountId32,
};
use sp_std::cell::RefCell;
use sp_std::{cell::RefCell, marker::PhantomData};
use xcm::v4::{prelude::*, Weight};
use xcm_builder::{
AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, ParentIsPreset, RelayChainAsNative,
Expand All @@ -26,8 +26,11 @@ use xcm_builder::{
use xcm_executor::{Config, XcmExecutor};

use crate::mock::AllTokensAreCreatedEqualToWeight;
use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key, RateLimiterError};
use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use orml_traits::{
location::{AbsoluteReserveProvider, Reserve},
parameter_type_with_key, RateLimiterError,
};
use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter};

pub type AccountId = AccountId32;

Expand Down Expand Up @@ -117,6 +120,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 0abe6f9

Please sign in to comment.