Skip to content

Commit

Permalink
allow snowbridge assets (#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh authored May 22, 2024
1 parent 84cbc0e commit e425a4b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
25 changes: 24 additions & 1 deletion runtime/bifrost-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,14 +651,37 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

/// Matches foreign assets from a given origin.
/// Foreign assets are assets bridged from other consensus systems. i.e parents > 1.
pub struct IsForeignNativeAssetFrom<Origin>(PhantomData<Origin>);
impl<Origin> ContainsPair<MultiAsset, MultiLocation> for IsForeignNativeAssetFrom<Origin>
where
Origin: Get<MultiLocation>,
{
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
let loc = Origin::get();
&loc == origin &&
matches!(
asset,
MultiAsset { id: Concrete(MultiLocation { parents: 2, .. }), fun: Fungible(_) },
)
}
}

parameter_types! {
/// Location of Asset Hub
pub AssetHubLocation: MultiLocation = (Parent, Parachain(1000)).into();
}

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type AssetClaims = PolkadotXcm;
type AssetTransactor = BifrostAssetTransactor;
type AssetTrap = BifrostDropAssets<ToTreasury>;
type Barrier = Barrier;
type RuntimeCall = RuntimeCall;
type IsReserve = MultiNativeAsset<RelativeReserveProvider>;
type IsReserve =
(IsForeignNativeAssetFrom<AssetHubLocation>, MultiNativeAsset<RelativeReserveProvider>);
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
Expand Down
25 changes: 24 additions & 1 deletion runtime/bifrost-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,37 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

/// Matches foreign assets from a given origin.
/// Foreign assets are assets bridged from other consensus systems. i.e parents > 1.
pub struct IsForeignNativeAssetFrom<Origin>(PhantomData<Origin>);
impl<Origin> ContainsPair<MultiAsset, MultiLocation> for IsForeignNativeAssetFrom<Origin>
where
Origin: Get<MultiLocation>,
{
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
let loc = Origin::get();
&loc == origin &&
matches!(
asset,
MultiAsset { id: Concrete(MultiLocation { parents: 2, .. }), fun: Fungible(_) },
)
}
}

parameter_types! {
/// Location of Asset Hub
pub AssetHubLocation: MultiLocation = (Parent, Parachain(1000)).into();
}

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type AssetClaims = PolkadotXcm;
type AssetTransactor = BifrostAssetTransactor;
type AssetTrap = BifrostDropAssets<ToTreasury>;
type Barrier = Barrier;
type RuntimeCall = RuntimeCall;
type IsReserve = MultiNativeAsset<RelativeReserveProvider>;
type IsReserve =
(IsForeignNativeAssetFrom<AssetHubLocation>, MultiNativeAsset<RelativeReserveProvider>);
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
Expand Down

0 comments on commit e425a4b

Please sign in to comment.