Skip to content

Commit

Permalink
Region AssetTransactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Apr 26, 2024
1 parent 2c698b9 commit 91d4c15
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion runtime/regionx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

pub const CORETIME_CHAIN_PARA_ID: u32 = 1005;

/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
Expand Down Expand Up @@ -584,7 +586,7 @@ impl StateMachineHeightProviderT for StateMachineHeightProvider {
}

parameter_types! {
pub const CoretimeChain: StateMachine = StateMachine::Kusama(1005); // coretime-kusama
pub const CoretimeChain: StateMachine = StateMachine::Kusama(CORETIME_CHAIN_PARA_ID); // coretime-kusama
}

impl pallet_regions::Config for Runtime {
Expand Down
22 changes: 20 additions & 2 deletions runtime/regionx/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

use super::{
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
Regions, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
CORETIME_CHAIN_PARA_ID,
};
use frame_support::{
match_types, parameter_types,
Expand All @@ -32,12 +33,16 @@ use xcm_builder::{
FrameTransactionalProcessor, FungibleAdapter, IsConcrete, NativeAsset, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, NonFungibleAdapter,
};
use xcm_executor::XcmExecutor;

parameter_types! {
pub const RelayLocation: MultiLocation = MultiLocation::parent();
pub const BrokerPalletLocation: MultiLocation = MultiLocation {
parents: 1,
interior: X2(Parachain(CORETIME_CHAIN_PARA_ID), PalletInstance(50))
};
pub const RelayNetwork: Option<NetworkId> = None;
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
Expand Down Expand Up @@ -69,6 +74,19 @@ pub type LocalAssetTransactor = FungibleAdapter<
(),
>;

pub type RegionTransactor = NonFungibleAdapter<
// Use this non-fungible implementation:
Regions,
// This adapter will handle coretime regions from the broker pallet.
IsConcrete<BrokerPalletLocation>,
// Convert an XCM Location into a local account id:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
// We don't track any teleports.
(),
>;

/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
/// biases the kind of local `Origin` it will become.
Expand Down

0 comments on commit 91d4c15

Please sign in to comment.