1use super::{
2 AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
3 Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
4};
5use frame_support::{
6 parameter_types,
7 traits::{ConstU32, Contains, Disabled, Everything, Nothing},
8 weights::Weight,
9};
10use frame_system::EnsureRoot;
11use pallet_xcm::XcmPassthrough;
12use polkadot_runtime_common::impls::ToAuthor;
13use xcm::latest::prelude::*;
14#[allow(deprecated)]
15use xcm_builder::CurrencyAdapter;
16use xcm_builder::{
17 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
18 DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
19 FixedWeightBounds, FrameTransactionalProcessor, IsConcrete, NativeAsset, ParentIsPreset,
20 RelayChainAsNative, SiblingParachainAsNative, SignedAccountId32AsNative, SignedToAccountId32,
21 SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
22 WithComputedOrigin, WithUniqueTopic,
23};
24use xcm_executor::XcmExecutor;
25
26parameter_types! {
27 pub const TokenLocation: Location = Here.into_location();
28 pub const RelayLocation: Location = Location::parent();
29 pub const RelayNetwork: Option<NetworkId> = None;
30 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
31 pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into();
32}
33
34pub type LocationToAccountId = (
38 AccountId32Aliases<RelayNetwork, AccountId>,
40 ParentIsPreset<AccountId>,
42);
43
44#[allow(deprecated)]
46pub type LocalAssetTransactor = CurrencyAdapter<
47 Balances,
49 IsConcrete<RelayLocation>,
51 LocationToAccountId,
53 AccountId,
55 (),
57>;
58
59#[allow(deprecated)]
60pub type LocalBalancesTransactor =
61 CurrencyAdapter<Balances, IsConcrete<TokenLocation>, LocationToAccountId, AccountId, ()>;
62
63pub type AssetTransactors = (LocalBalancesTransactor, LocalAssetTransactor);
64
65pub type XcmOriginToTransactDispatchOrigin = (
69 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
73 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
76 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
79 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
82 XcmPassthrough<RuntimeOrigin>,
84);
85
86parameter_types! {
87 pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
89 pub const MaxInstructions: u32 = 100;
90 pub const MaxAssetsIntoHolding: u32 = 64;
91}
92
93pub struct ParentOrParentsPlurality;
94impl Contains<Location> for ParentOrParentsPlurality {
95 fn contains(location: &Location) -> bool {
96 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
97 }
98}
99
100pub type Barrier = TrailingSetTopicAsId<
101 DenyThenTry<
102 DenyRecursively<DenyReserveTransferToRelayChain>,
103 (
104 TakeWeightCredit,
105 WithComputedOrigin<
106 (
107 AllowTopLevelPaidExecutionFrom<Everything>,
108 AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
109 ),
111 UniversalLocation,
112 ConstU32<8>,
113 >,
114 ),
115 >,
116>;
117
118pub struct XcmConfig;
119impl xcm_executor::Config for XcmConfig {
120 type RuntimeCall = RuntimeCall;
121 type XcmSender = XcmRouter;
122 type XcmEventEmitter = PolkadotXcm;
123 type AssetTransactor = AssetTransactors;
124 type OriginConverter = XcmOriginToTransactDispatchOrigin;
125 type IsReserve = NativeAsset;
126 type IsTeleporter = (); type UniversalLocation = UniversalLocation;
128 type Barrier = Barrier;
129 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
130 type Trader =
131 UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToAuthor<Runtime>>;
132 type ResponseHandler = PolkadotXcm;
133 type AssetTrap = PolkadotXcm;
134 type AssetClaims = PolkadotXcm;
135 type SubscriptionService = PolkadotXcm;
136 type PalletInstancesInfo = AllPalletsWithSystem;
137 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
138 type AssetLocker = ();
139 type AssetExchanger = ();
140 type FeeManager = ();
141 type MessageExporter = ();
142 type UniversalAliases = Nothing;
143 type CallDispatcher = RuntimeCall;
144 type SafeCallFilter = Everything;
145 type Aliasers = Nothing;
146 type TransactionalProcessor = FrameTransactionalProcessor;
147 type HrmpNewChannelOpenRequestHandler = ();
148 type HrmpChannelAcceptedHandler = ();
149 type HrmpChannelClosingHandler = ();
150 type XcmRecorder = PolkadotXcm;
151}
152
153pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
155
156pub type XcmRouter = WithUniqueTopic<(
159 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
161 XcmpQueue,
163)>;
164
165#[cfg(feature = "runtime-benchmarks")]
166parameter_types! {
167 pub ReachableDest: Option<Location> = Some(Parent.into());
168}
169
170impl pallet_xcm::Config for Runtime {
171 type RuntimeEvent = RuntimeEvent;
172 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
173 type XcmRouter = XcmRouter;
174 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
175 type XcmExecuteFilter = Everything;
176 type XcmExecutor = XcmExecutor<XcmConfig>;
177 type XcmTeleportFilter = Everything;
178 type XcmReserveTransferFilter = Nothing;
179 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
180 type UniversalLocation = UniversalLocation;
181 type RuntimeOrigin = RuntimeOrigin;
182 type RuntimeCall = RuntimeCall;
183
184 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
185 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
187 type Currency = Balances;
188 type CurrencyMatcher = ();
189 type TrustedLockers = ();
190 type SovereignAccountOf = LocationToAccountId;
191 type MaxLockers = ConstU32<8>;
192 type WeightInfo = pallet_xcm::TestWeightInfo;
193 type AdminOrigin = EnsureRoot<AccountId>;
194 type MaxRemoteLockConsumers = ConstU32<0>;
195 type RemoteLockConsumerIdentifier = ();
196 type AuthorizedAliasConsideration = Disabled;
197}
198
199impl cumulus_pallet_xcm::Config for Runtime {
200 type RuntimeEvent = RuntimeEvent;
201 type XcmExecutor = XcmExecutor<XcmConfig>;
202}