Skip to content

Commit

Permalink
Register Moonbase DEV on Moonbeam Foucoco testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanS98 committed Dec 5, 2023
1 parent 95e9f3b commit c1121ee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ 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
23 changes: 23 additions & 0 deletions runtime/foucoco/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod xcm_assets {
use runtime_common::create_xcm_id;
create_xcm_id!(RELAY, 0);
create_xcm_id!(MOONBASE_DEV, 2);
}

/// Locations for native currency and all natively issued tokens
Expand Down Expand Up @@ -35,3 +36,25 @@ pub mod native_locations {
}
}
}

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

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: 5 additions & 1 deletion runtime/foucoco/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{
};
use crate::assets::{
native_locations::{native_location_external_pov, native_location_local_pov},
xcm_assets,
xcm_assets, moonbase_alpha_relay::moonbase::DEV_location,
};
use core::marker::PhantomData;
use frame_support::{
Expand Down Expand Up @@ -63,6 +63,8 @@ impl Convert<CurrencyId, Option<MultiLocation>> for CurrencyIdConvert {
fn convert(id: CurrencyId) -> Option<MultiLocation> {
match id {
CurrencyId::XCM(xcm_assets::RELAY) => Some(MultiLocation::parent()),
// Moonbase testnet native token
CurrencyId::XCM(xcm_assets::MOONBASE_DEV) => Some(DEV_location()),
CurrencyId::Native => Some(native_location_external_pov()),
_ => None,
}
Expand All @@ -78,6 +80,8 @@ impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
// Our native currency location with re-anchoring
// 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()),
_ => None,
}
}
Expand Down

0 comments on commit c1121ee

Please sign in to comment.