use super::{
AccountId, AllPalletsWithSystem, ParachainInfo, Runtime, RuntimeCall, RuntimeEvent,
RuntimeOrigin,
};
use frame_support::{
parameter_types,
traits::{Contains, Everything, Nothing},
weights::Weight,
};
use xcm::latest::{prelude::*, WESTEND_GENESIS_HASH};
use xcm_builder::{
AllowExplicitUnpaidExecutionFrom, FixedWeightBounds, FrameTransactionalProcessor,
ParentAsSuperuser, ParentIsPreset, SovereignSignedViaLocation,
};
parameter_types! {
pub const WestendLocation: Location = Location::parent();
pub const WestendNetwork: NetworkId = NetworkId::ByGenesis(WESTEND_GENESIS_HASH);
pub UniversalLocation: InteriorLocation = [GlobalConsensus(WestendNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
}
pub type XcmOriginToTransactDispatchOrigin = (
SovereignSignedViaLocation<ParentIsPreset<AccountId>, RuntimeOrigin>,
ParentAsSuperuser<RuntimeOrigin>,
);
pub struct JustTheParent;
impl Contains<Location> for JustTheParent {
fn contains(location: &Location) -> bool {
matches!(location.unpack(), (1, []))
}
}
parameter_types! {
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
}
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
type XcmSender = (); type AssetTransactor = (); type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = (); type IsTeleporter = (); type UniversalLocation = UniversalLocation;
type Barrier = AllowExplicitUnpaidExecutionFrom<JustTheParent>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>; type Trader = (); type ResponseHandler = (); type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type AssetLocker = ();
type AssetExchanger = ();
type FeeManager = ();
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type XcmRecorder = ();
}
impl cumulus_pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
}