1use super::{
17 AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, FeeAssetId, Fellows,
18 ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent,
19 RuntimeHoldReason, RuntimeOrigin, TransactionByteFee, WeightToFee, WestendTreasuryAccount,
20 XcmpQueue,
21};
22use frame_support::{
23 parameter_types,
24 traits::{
25 fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals,
26 Everything, LinearStoragePrice, Nothing,
27 },
28};
29use frame_system::EnsureRoot;
30use pallet_collator_selection::StakingPotAccountId;
31use pallet_xcm::{AuthorizedAliasers, XcmPassthrough};
32use parachains_common::xcm_config::{
33 AliasAccountId32FromSiblingSystemChain, AllSiblingSystemParachains, ConcreteAssetFromSystem,
34 ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
35};
36use polkadot_parachain_primitives::primitives::Sibling;
37use polkadot_runtime_common::xcm_sender::ExponentialPrice;
38use westend_runtime_constants::{system_parachain::ASSET_HUB_ID, xcm as xcm_constants};
39use xcm::latest::{prelude::*, WESTEND_GENESIS_HASH};
40use xcm_builder::{
41 AccountId32Aliases, AliasChildLocation, AliasOriginRootUsingFilter,
42 AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
43 AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
44 DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal,
45 DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
46 HashedDescription, IsConcrete, LocatableAssetId, LocationAsSuperuser, OriginToPluralityVoice,
47 ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
48 SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
49 SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
50 UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
51 XcmFeeManagerFromComponents,
52};
53use xcm_executor::XcmExecutor;
54
55pub use testnet_parachains_constants::westend::locations::GovernanceLocation;
57
58parameter_types! {
59 pub const RootLocation: Location = Location::here();
60 pub const WndLocation: Location = Location::parent();
61 pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH));
62 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
63 pub UniversalLocation: InteriorLocation =
64 [GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
65 pub RelayTreasuryLocation: Location = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
66 pub CheckingAccount: AccountId = PolkadotXcm::check_account();
67 pub const FellowshipAdminBodyId: BodyId = BodyId::Index(xcm_constants::body::FELLOWSHIP_ADMIN_INDEX);
68 pub AssetHub: Location = (Parent, Parachain(ASSET_HUB_ID)).into();
69 pub const TreasurerBodyId: BodyId = BodyId::Treasury;
70 pub AssetHubUsdtId: AssetId = (PalletInstance(50), GeneralIndex(1984)).into();
71 pub UsdtAssetHub: LocatableAssetId = LocatableAssetId {
72 location: AssetHub::get(),
73 asset_id: AssetHubUsdtId::get(),
74 };
75 pub WndAssetHub: LocatableAssetId = LocatableAssetId {
76 location: AssetHub::get(),
77 asset_id: WndLocation::get().into(),
78 };
79}
80
81pub type LocationToAccountId = (
85 ParentIsPreset<AccountId>,
87 SiblingParachainConvertsVia<Sibling, AccountId>,
89 AccountId32Aliases<RelayNetwork, AccountId>,
91 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
93);
94
95pub type FungibleTransactor = FungibleAdapter<
97 Balances,
99 IsConcrete<WndLocation>,
101 LocationToAccountId,
103 AccountId,
105 (),
107>;
108
109pub type XcmOriginToTransactDispatchOrigin = (
113 LocationAsSuperuser<Equals<GovernanceLocation>, RuntimeOrigin>,
115 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
119 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
122 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
125 ParentAsSuperuser<RuntimeOrigin>,
128 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
131 XcmPassthrough<RuntimeOrigin>,
133);
134
135parameter_types! {
136 pub const MaxInstructions: u32 = 100;
137 pub const MaxAssetsIntoHolding: u32 = 64;
138 pub const FellowsBodyId: BodyId = BodyId::Technical;
140}
141
142pub struct ParentOrParentsPlurality;
143impl Contains<Location> for ParentOrParentsPlurality {
144 fn contains(location: &Location) -> bool {
145 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
146 }
147}
148
149pub struct LocalPlurality;
150impl Contains<Location> for LocalPlurality {
151 fn contains(loc: &Location) -> bool {
152 matches!(loc.unpack(), (0, [Plurality { .. }]))
153 }
154}
155
156pub type Barrier = TrailingSetTopicAsId<
157 DenyThenTry<
158 DenyRecursively<DenyReserveTransferToRelayChain>,
159 (
160 TakeWeightCredit,
162 AllowKnownQueryResponses<PolkadotXcm>,
164 WithComputedOrigin<
166 (
167 AllowTopLevelPaidExecutionFrom<Everything>,
170 AllowExplicitUnpaidExecutionFrom<(
172 ParentOrParentsPlurality,
173 Equals<GovernanceLocation>,
174 )>,
175 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
177 AllowHrmpNotificationsFromRelayChain,
179 ),
180 UniversalLocation,
181 ConstU32<8>,
182 >,
183 ),
184 >,
185>;
186
187pub type WaivedLocations = (
191 RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
192 Equals<RelayTreasuryLocation>,
193 Equals<RootLocation>,
194 LocalPlurality,
195);
196
197pub type TrustedTeleporters = ConcreteAssetFromSystem<WndLocation>;
200
201pub type TrustedAliasers = (
208 AliasChildLocation,
209 AliasAccountId32FromSiblingSystemChain,
210 AliasOriginRootUsingFilter<AssetHub, Everything>,
211 AuthorizedAliasers<Runtime>,
212);
213
214pub struct XcmConfig;
215impl xcm_executor::Config for XcmConfig {
216 type RuntimeCall = RuntimeCall;
217 type XcmSender = XcmRouter;
218 type XcmEventEmitter = PolkadotXcm;
219 type AssetTransactor = FungibleTransactor;
220 type OriginConverter = XcmOriginToTransactDispatchOrigin;
221 type IsReserve = ();
224 type IsTeleporter = TrustedTeleporters;
225 type UniversalLocation = UniversalLocation;
226 type Barrier = Barrier;
227 type Weigher = WeightInfoBounds<
228 crate::weights::xcm::CollectivesWestendXcmWeight<RuntimeCall>,
229 RuntimeCall,
230 MaxInstructions,
231 >;
232 type Trader = UsingComponents<
233 WeightToFee,
234 WndLocation,
235 AccountId,
236 Balances,
237 ResolveTo<StakingPotAccountId<Runtime>, Balances>,
238 >;
239 type ResponseHandler = PolkadotXcm;
240 type AssetTrap = PolkadotXcm;
241 type AssetClaims = PolkadotXcm;
242 type SubscriptionService = PolkadotXcm;
243 type PalletInstancesInfo = AllPalletsWithSystem;
244 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
245 type AssetLocker = ();
246 type AssetExchanger = ();
247 type FeeManager = XcmFeeManagerFromComponents<
248 WaivedLocations,
249 SendXcmFeeToAccount<Self::AssetTransactor, WestendTreasuryAccount>,
250 >;
251 type MessageExporter = ();
252 type UniversalAliases = Nothing;
253 type CallDispatcher = RuntimeCall;
254 type SafeCallFilter = Everything;
255 type Aliasers = TrustedAliasers;
256 type TransactionalProcessor = FrameTransactionalProcessor;
257 type HrmpNewChannelOpenRequestHandler = ();
258 type HrmpChannelAcceptedHandler = ();
259 type HrmpChannelClosingHandler = ();
260 type XcmRecorder = PolkadotXcm;
261}
262
263pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
266
267pub type PriceForParentDelivery =
268 ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
269
270pub type XcmRouter = WithUniqueTopic<(
273 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, PriceForParentDelivery>,
275 XcmpQueue,
277)>;
278
279#[cfg(feature = "runtime-benchmarks")]
280parameter_types! {
281 pub ReachableDest: Option<Location> = Some(Parent.into());
282}
283
284pub type FellowsToPlurality = OriginToPluralityVoice<RuntimeOrigin, Fellows, FellowsBodyId>;
286
287parameter_types! {
288 pub const DepositPerItem: Balance = crate::deposit(1, 0);
289 pub const DepositPerByte: Balance = crate::deposit(0, 1);
290 pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias);
291}
292
293impl pallet_xcm::Config for Runtime {
294 type RuntimeEvent = RuntimeEvent;
295 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, FellowsToPlurality>;
297 type XcmRouter = XcmRouter;
298 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
300 type XcmExecuteFilter = Everything;
301 type XcmExecutor = XcmExecutor<XcmConfig>;
302 type XcmTeleportFilter = Everything;
303 type XcmReserveTransferFilter = Nothing; type Weigher = WeightInfoBounds<
305 crate::weights::xcm::CollectivesWestendXcmWeight<RuntimeCall>,
306 RuntimeCall,
307 MaxInstructions,
308 >;
309 type UniversalLocation = UniversalLocation;
310 type RuntimeOrigin = RuntimeOrigin;
311 type RuntimeCall = RuntimeCall;
312 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
313 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
314 type Currency = Balances;
315 type CurrencyMatcher = ();
316 type TrustedLockers = ();
317 type SovereignAccountOf = LocationToAccountId;
318 type MaxLockers = ConstU32<8>;
319 type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
320 type AdminOrigin = EnsureRoot<AccountId>;
321 type MaxRemoteLockConsumers = ConstU32<0>;
322 type RemoteLockConsumerIdentifier = ();
323 type AuthorizedAliasConsideration = HoldConsideration<
325 AccountId,
326 Balances,
327 AuthorizeAliasHoldReason,
328 LinearStoragePrice<DepositPerItem, DepositPerByte, Balance>,
329 >;
330}
331
332impl cumulus_pallet_xcm::Config for Runtime {
333 type RuntimeEvent = RuntimeEvent;
334 type XcmExecutor = XcmExecutor<XcmConfig>;
335}