Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Rococo Parachain XCM Adjustments #936

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions polkadot-parachains/parachains-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
# External dependencies
codec = { package = "parity-scale-codec", version = "2.3.0", features = ["derive"], default-features = false }
log = { version = "0.4.14", default-features = false }
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }

# Substrate dependencies
Expand Down
27 changes: 25 additions & 2 deletions polkadot-parachains/parachains-common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,16 @@ pub struct AssetsFrom<T>(PhantomData<T>);
impl<T: Get<MultiLocation>> FilterAssetLocation for AssetsFrom<T> {
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
let loc = T::get();
log::trace!(target: "xcm::AssetsFrom", "loc: {:?}, origin: {:?}", loc, origin);
&loc == origin &&
matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) }
if asset_loc.match_and_split(&loc).is_some())
match asset {
MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } =>
loc.parent_count() == asset_loc.parent_count() &&
loc.interior().iter().zip(asset_loc.interior().iter()).all(
|(prefix_junction, asset_junction)| prefix_junction == asset_junction,
apopiak marked this conversation as resolved.
Show resolved Hide resolved
),
_ => false,
}
}
}

Expand Down Expand Up @@ -278,5 +285,21 @@ mod tests {
),
"AssetsFrom should allow assets from any of its interior locations"
);

// make sure assets can have more than one junction inside the prefix location
let asset_location = SomeSiblingParachain::get()
.clone()
.pushed_with_interior(PalletInstance(50))
.unwrap()
.pushed_with_interior(GeneralIndex(42))
.expect("multilocation will only have 2 junctions; qed");
let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000.into() };
assert!(
AssetsFrom::<SomeSiblingParachain>::filter_asset_location(
&asset,
&SomeSiblingParachain::get()
),
"AssetsFrom should allow assets from any of its interior locations"
);
}
}
10 changes: 7 additions & 3 deletions polkadot-parachains/rococo-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, Case,
CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
Expand Down Expand Up @@ -391,9 +391,13 @@ parameter_types! {
// Statemint's Assets pallet index
pub StatemintAssetsPalletLocation: MultiLocation =
MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50)));
pub KsmFilter: MultiAssetFilter = MultiAssetFilter::Wild(WildMultiAsset::AllOf{ id: (1, Here).into(), fun: WildFungibility::Fungible });
pub KsmFromStatemint: (MultiAssetFilter, MultiLocation) = (
KsmFilter::get(), StatemintLocation::get()
);
}

pub type Reserves = (NativeAsset, AssetsFrom<StatemintLocation>);
pub type Reserves = (NativeAsset, AssetsFrom<StatemintLocation>, Case<KsmFromStatemint>);

pub struct XcmConfig;
impl Config for XcmConfig {
Expand Down