use frame::{
deps::frame_system,
runtime::prelude::*,
traits::{Everything, Nothing},
};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin,
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
SignedToAccountId32,
};
use xcm_executor::XcmExecutor;
use super::{AccountId, Balances, MessageQueue, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
parameter_types! {
pub RelayLocation: Location = Location::parent();
pub ThisNetwork: NetworkId = NetworkId::Polkadot;
}
pub type LocationToAccountId = (
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
AccountId32Aliases<ThisNetwork, AccountId>,
);
#[docify::export]
mod asset_transactor {
use super::*;
parameter_types! {
pub ParentRelayLocation: Location = Location::parent();
}
pub type FungibleTransactor = FungibleAdapter<
Balances,
IsConcrete<ParentRelayLocation>,
LocationToAccountId,
AccountId,
(),
>;
pub type AssetTransactor = FungibleTransactor;
}
#[docify::export]
mod is_reserve {
use super::*;
parameter_types! {
pub RelayTokenForRelay: (AssetFilter, Location) =
(Wild(AllOf { id: AssetId(Parent.into()), fun: WildFungible }), Parent.into());
}
pub type IsReserve = xcm_builder::Case<RelayTokenForRelay>;
}
mod weigher {
use super::*;
use xcm_builder::FixedWeightBounds;
parameter_types! {
pub const WeightPerInstruction: Weight = Weight::from_parts(1, 1);
pub const MaxInstructions: u32 = 100;
}
pub type Weigher = FixedWeightBounds<WeightPerInstruction, RuntimeCall, MaxInstructions>;
}
parameter_types! {
pub UniversalLocation: InteriorLocation = [GlobalConsensus(NetworkId::Polkadot), Parachain(2222)].into();
}
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
type XcmSender = ();
type AssetTransactor = asset_transactor::AssetTransactor;
type OriginConverter = ();
type IsReserve = is_reserve::IsReserve;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = xcm_builder::AllowUnpaidExecutionFrom<Everything>;
type Weigher = weigher::Weigher;
type Trader = ();
type ResponseHandler = ();
type AssetTrap = ();
type AssetLocker = ();
type AssetExchanger = ();
type AssetClaims = ();
type SubscriptionService = ();
type PalletInstancesInfo = ();
type FeeManager = ();
type MaxAssetsIntoHolding = frame::traits::ConstU32<1>;
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 = ();
}
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>;
impl pallet_xcm::Config for Runtime {
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
type XcmRouter = super::super::network::ParachainXcmRouter<MessageQueue>; type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything;
type Weigher = weigher::Weigher;
type UniversalLocation = UniversalLocation;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
type AdminOrigin = frame_system::EnsureRoot<AccountId>;
type TrustedLockers = ();
type MaxLockers = frame::traits::ConstU32<0>;
type MaxRemoteLockConsumers = frame::traits::ConstU32<0>;
type RemoteLockConsumerIdentifier = ();
type SovereignAccountOf = LocationToAccountId;
type Currency = Balances;
type CurrencyMatcher = IsConcrete<RelayLocation>;
type WeightInfo = pallet_xcm::TestWeightInfo;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
}