Skip to content

Commit

Permalink
rename struct to ConcreteAssetFromRelay and add more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusrodri committed Sep 12, 2024
1 parent 5f8b494 commit 3fe32b4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
18 changes: 7 additions & 11 deletions runtime/moonbase/tests/xcm_mock/statemint_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,28 +296,24 @@ parameter_types! {
// https://github.com/paritytech/polkadot-sdk/blob/f4eb41773611008040c9d4d8a8e6b7323eccfca1/cumulus
// /parachains/common/src/xcm_config.rs#L118
//
// without the extra check for the system parachain, because we don't need it in tests.
//
// That checks ensures that our paraId is lower than ~1900.
// If we keep it enabled our tests will fail given that our paraIds are 1, 2, 3 and so on.
pub struct ConcreteAssetFromSystem<AssetLocation>(sp_std::marker::PhantomData<AssetLocation>);
// The difference with the original "ConcreteAssetFromSystem" (which is used by AssetHub),
// is that in our tests we only need to check if the asset matches the relay one.
pub struct ConcreteAssetFromRelay<AssetLocation>(sp_std::marker::PhantomData<AssetLocation>);
impl<AssetLocation: Get<Location>> ContainsPair<Asset, Location>
for ConcreteAssetFromSystem<AssetLocation>
for ConcreteAssetFromRelay<AssetLocation>
{
fn contains(asset: &Asset, origin: &Location) -> bool {
let is_system = match origin.unpack() {
let is_relay = match origin.unpack() {
// The Relay Chain
(1, []) => true,
// System parachain
(1, [Parachain(_id)]) => false,
// Others
_ => false,
};
asset.id.0 == AssetLocation::get() && is_system
asset.id.0 == AssetLocation::get() && is_relay
}
}

pub type TrustedTeleporters = (ConcreteAssetFromSystem<RelayTokenLocation>,);
pub type TrustedTeleporters = (ConcreteAssetFromRelay<RelayTokenLocation>,);

pub struct XcmConfig;
impl Config for XcmConfig {
Expand Down
7 changes: 7 additions & 0 deletions runtime/moonbase/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,13 @@ fn send_dot_from_moonbeam_to_statemint_via_xtokens_transfer() {
0,
WeightLimit::Unlimited
));

// Transfer the XCM execution fee amount to ParaA's sovereign account
assert_ok!(RelayBalances::transfer_keep_alive(
relay_chain::RuntimeOrigin::signed(RELAYALICE),
para_a_account(),
4000000000u128
));
});

// Send DOTs from AssetHub to ParaA (Moonbeam)
Expand Down
18 changes: 7 additions & 11 deletions runtime/moonbeam/tests/xcm_mock/statemint_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,28 +298,24 @@ parameter_types! {
// https://github.com/paritytech/polkadot-sdk/blob/f4eb41773611008040c9d4d8a8e6b7323eccfca1/cumulus
// /parachains/common/src/xcm_config.rs#L118
//
// without the extra check for the system parachain, because we don't need it in tests.
//
// That checks ensures that our paraId is lower than ~1900.
// If we keep it enabled our tests will fail given that our paraIds are 1, 2, 3 and so on.
pub struct ConcreteAssetFromSystem<AssetLocation>(sp_std::marker::PhantomData<AssetLocation>);
// The difference with the original "ConcreteAssetFromSystem" (which is used by AssetHub),
// is that in our tests we only need to check if the asset matches the relay one.
pub struct ConcreteAssetFromRelay<AssetLocation>(sp_std::marker::PhantomData<AssetLocation>);
impl<AssetLocation: Get<Location>> ContainsPair<Asset, Location>
for ConcreteAssetFromSystem<AssetLocation>
for ConcreteAssetFromRelay<AssetLocation>
{
fn contains(asset: &Asset, origin: &Location) -> bool {
let is_system = match origin.unpack() {
let is_relay = match origin.unpack() {
// The Relay Chain
(1, []) => true,
// System parachain
(1, [Parachain(_id)]) => false,
// Others
_ => false,
};
asset.id.0 == AssetLocation::get() && is_system
asset.id.0 == AssetLocation::get() && is_relay
}
}

pub type TrustedTeleporters = (ConcreteAssetFromSystem<RelayTokenLocation>,);
pub type TrustedTeleporters = (ConcreteAssetFromRelay<RelayTokenLocation>,);

pub struct XcmConfig;
impl Config for XcmConfig {
Expand Down
18 changes: 7 additions & 11 deletions runtime/moonriver/tests/xcm_mock/statemine_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,28 +298,24 @@ parameter_types! {
// https://github.com/paritytech/polkadot-sdk/blob/f4eb41773611008040c9d4d8a8e6b7323eccfca1/cumulus
// /parachains/common/src/xcm_config.rs#L118
//
// without the extra check for the system parachain, because we don't need it in tests.
//
// That checks ensures that our paraId is lower than ~1900.
// If we keep it enabled our tests will fail given that our paraIds are 1, 2, 3 and so on.
pub struct ConcreteAssetFromSystem<AssetLocation>(sp_std::marker::PhantomData<AssetLocation>);
// The difference with the original "ConcreteAssetFromSystem" (which is used by AssetHub),
// is that in our tests we only need to check if the asset matches the relay one.
pub struct ConcreteAssetFromRelay<AssetLocation>(sp_std::marker::PhantomData<AssetLocation>);
impl<AssetLocation: Get<Location>> ContainsPair<Asset, Location>
for ConcreteAssetFromSystem<AssetLocation>
for ConcreteAssetFromRelay<AssetLocation>
{
fn contains(asset: &Asset, origin: &Location) -> bool {
let is_system = match origin.unpack() {
let is_relay = match origin.unpack() {
// The Relay Chain
(1, []) => true,
// System parachain
(1, [Parachain(_id)]) => false,
// Others
_ => false,
};
asset.id.0 == AssetLocation::get() && is_system
asset.id.0 == AssetLocation::get() && is_relay
}
}

pub type TrustedTeleporters = (ConcreteAssetFromSystem<RelayTokenLocation>,);
pub type TrustedTeleporters = (ConcreteAssetFromRelay<RelayTokenLocation>,);

pub struct XcmConfig;
impl Config for XcmConfig {
Expand Down

0 comments on commit 3fe32b4

Please sign in to comment.