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, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
parameter_types! {
pub HereLocation: Location = Location::here();
pub ThisNetwork: NetworkId = NetworkId::Polkadot;
}
pub type LocationToAccountId = (
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
AccountId32Aliases<ThisNetwork, AccountId>,
);
mod asset_transactor {
use super::*;
pub type FungibleTransactor = FungibleAdapter<
Balances,
IsConcrete<HereLocation>,
LocationToAccountId,
AccountId,
(),
>;
pub type AssetTransactor = FungibleTransactor;
}
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)].into();
}
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
type XcmSender = ();
type AssetTransactor = asset_transactor::AssetTransactor;
type OriginConverter = ();
type 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::RelayChainXcmRouter; 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<HereLocation>;
type WeightInfo = pallet_xcm::TestWeightInfo;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
}