Skip to content

Commit

Permalink
Address change request
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanS98 committed Dec 5, 2023
1 parent 55f67d2 commit 4741f7f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
18 changes: 17 additions & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ pub mod parachains {
}

/// Creates a location for the given asset in this format: `fn <asset_name>_location() -> MultiLocation`
#[macro_export]
macro_rules! parachain_asset_location {
// Also declares a constant variable <asset_name>_ASSET_ID with <asset_value>.
// This assumes that the following constant variables exist:
Expand Down Expand Up @@ -194,6 +193,23 @@ pub mod parachains {
pub use super::super::polkadot::asset_hub::*;
}
}

pub mod moonbase_alpha_relay {
pub mod moonbase_alpha {
use xcm::latest::{
Junction::{PalletInstance, Parachain},
Junctions::X2,
};

pub const PARA_ID: u32 = 1000;
pub const BALANCES_PALLET_INDEX: u8 = 3;

parachain_asset_location!(
DEV,
X2(Parachain(PARA_ID), PalletInstance(BALANCES_PALLET_INDEX),)
);
}
}
}

#[cfg(test)]
Expand Down
18 changes: 0 additions & 18 deletions runtime/foucoco/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,3 @@ pub mod native_locations {
}
}
}

pub mod moonbase_alpha_relay {
pub mod moonbase {
use runtime_common::parachain_asset_location;
use xcm::latest::{
Junction::{PalletInstance, Parachain},
Junctions::X2,
};

pub const PARA_ID: u32 = 1000;
pub const BALANCES_PALLET_INDEX: u8 = 110;

parachain_asset_location!(
DEV,
X2(Parachain(PARA_ID), PalletInstance(BALANCES_PALLET_INDEX),)
);
}
}
6 changes: 3 additions & 3 deletions runtime/foucoco/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::{
RuntimeCall, RuntimeEvent, RuntimeOrigin, Tokens, WeightToFee, XcmpQueue,
};
use crate::assets::{
moonbase_alpha_relay::moonbase::DEV_location,
native_locations::{native_location_external_pov, native_location_local_pov},
xcm_assets,
};
Expand All @@ -19,6 +18,7 @@ use orml_traits::{
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::impls::ToAuthor;
use runtime_common::parachains::moonbase_alpha_relay::moonbase_alpha;
use sp_runtime::traits::Convert;
use xcm::latest::{prelude::*, Weight as XCMWeight};
use xcm_builder::{
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Convert<CurrencyId, Option<MultiLocation>> for CurrencyIdConvert {
match id {
CurrencyId::XCM(xcm_assets::RELAY) => Some(MultiLocation::parent()),
// Moonbase testnet native token
CurrencyId::XCM(xcm_assets::MOONBASE_DEV) => Some(DEV_location()),
CurrencyId::XCM(xcm_assets::MOONBASE_DEV) => Some(moonbase_alpha::DEV_location()),
CurrencyId::Native => Some(native_location_external_pov()),
_ => None,
}
Expand All @@ -82,7 +82,7 @@ impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
// The XCM pallet will try to re-anchor the location before it reaches here
loc if loc == native_location_local_pov() => Some(CurrencyId::Native),
// Moonbase testnet native token
loc if loc == DEV_location() => Some(xcm_assets::MOONBASE_DEV_id()),
loc if loc == moonbase_alpha::DEV_location() => Some(xcm_assets::MOONBASE_DEV_id()),
_ => None,
}
}
Expand Down

0 comments on commit 4741f7f

Please sign in to comment.