Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify IsForeignConcreteAsset Implementation #2276

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
};
use assets_common::{
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset},
matching::{FromNetwork, IsSiblingParachainAsset},
};
use frame_support::{
match_types, parameter_types,
Expand Down Expand Up @@ -523,7 +523,7 @@ pub type WaivedLocations = (
/// - Sibling parachains' assets from where they originate (as `ForeignCreators`).
pub type TrustedTeleporters = (
ConcreteAssetFromSystem<TokenLocation>,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
IsSiblingParachainAsset<parachain_info::Pallet<Runtime>>,
);

pub struct XcmConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
};
use assets_common::{
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
matching::{FromSiblingParachain, IsForeignConcreteAsset},
matching::IsSiblingParachainAsset,
};
use frame_support::{
match_types, parameter_types,
Expand Down Expand Up @@ -543,7 +543,7 @@ pub type WaivedLocations = (
/// - Sibling parachains' assets from where they originate (as `ForeignCreators`).
pub type TrustedTeleporters = (
ConcreteAssetFromSystem<WestendLocation>,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
IsSiblingParachainAsset<parachain_info::Pallet<Runtime>>,
);

pub struct XcmConfig;
Expand Down
12 changes: 6 additions & 6 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ frame_support::parameter_types! {
pub ParentLocation: MultiLocation = MultiLocation::parent();
}

/// Accepts an asset if it is from the origin.
pub struct IsForeignConcreteAsset<IsForeign>(sp_std::marker::PhantomData<IsForeign>);
impl<IsForeign: ContainsPair<MultiLocation, MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
for IsForeignConcreteAsset<IsForeign>
/// Accepts an asset if it is from a sibling parachain.
pub struct IsSiblingParachainAsset<SelfParaId>(sp_std::marker::PhantomData<SelfParaId>);
impl<SelfParaId: Get<ParaId>> ContainsPair<MultiAsset, MultiLocation>
for IsSiblingParachainAsset<SelfParaId>
{
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin);
matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, origin))
log::trace!(target: "xcm::contains", "IsSiblingParachainAsset asset: {:?}, origin: {:?}", asset, origin);
matches!(asset.id, Concrete(ref id) if <FromSiblingParachain<SelfParaId>>::contains(id, origin))
}
}

Expand Down
Loading