1use super::{
20 parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, FellowshipAdmin,
21 GeneralAdmin, ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin,
22 TransactionByteFee, WeightToFee, XcmPallet,
23};
24use frame_support::{
25 match_types, parameter_types,
26 traits::{Everything, Nothing},
27 weights::Weight,
28};
29use frame_system::EnsureRoot;
30use pallet_xcm::XcmPassthrough;
31use polkadot_runtime_constants::{
32 currency::CENTS, system_parachain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX,
33};
34use runtime_common::{
35 xcm_sender::{ChildParachainRouter, ExponentialPrice},
36 ToAuthor,
37};
38use sp_core::ConstU32;
39use xcm::latest::prelude::*;
40use xcm_builder::{
41 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
42 AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
43 ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, DescribeBodyTerminal,
44 DescribeFamily, HashedDescription, IsConcrete, MintLocation, OriginToPluralityVoice,
45 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
46 TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
47};
48
49parameter_types! {
50 pub const TokenLocation: MultiLocation = Here.into_location();
54 pub const ThisNetwork: NetworkId = NetworkId::Polkadot;
56 pub const UniversalLocation: InteriorMultiLocation = X1(GlobalConsensus(ThisNetwork::get()));
58 pub CheckAccount: AccountId = XcmPallet::check_account();
60 pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
62}
63
64pub type SovereignAccountOf = (
67 ChildParachainConvertsVia<ParaId, AccountId>,
69 AccountId32Aliases<ThisNetwork, AccountId>,
71 HashedDescription<AccountId, DescribeFamily<DescribeBodyTerminal>>,
73);
74
75pub type LocalAssetTransactor = XcmCurrencyAdapter<
80 Balances,
82 IsConcrete<TokenLocation>,
84 SovereignAccountOf,
86 AccountId,
88 LocalCheckAccount,
90>;
91
92type LocalOriginConverter = (
96 SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
99 ChildParachainAsNative<parachains_origin::Origin, RuntimeOrigin>,
102 SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
105 XcmPassthrough<RuntimeOrigin>,
107);
108
109parameter_types! {
110 pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 1024);
112 pub const MaxInstructions: u32 = 100;
115 pub FeeAssetId: AssetId = Concrete(TokenLocation::get());
117 pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
119}
120
121pub type XcmRouter = WithUniqueTopic<(
124 ChildParachainRouter<
126 Runtime,
127 XcmPallet,
128 ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, Dmp>,
129 >,
130)>;
131
132parameter_types! {
133 pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
134 pub const StatemintLocation: MultiLocation = Parachain(STATEMINT_ID).into_location();
135 pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), StatemintLocation::get());
136 pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
137 pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());
138 pub const MaxAssetsIntoHolding: u32 = 64;
139}
140
141pub type TrustedTeleporters =
143 (xcm_builder::Case<DotForStatemint>, xcm_builder::Case<DotForCollectives>);
144
145match_types! {
146 pub type OnlyParachains: impl Contains<MultiLocation> = {
147 MultiLocation { parents: 0, interior: X1(Parachain(_)) }
148 };
149 pub type CollectivesOrFellows: impl Contains<MultiLocation> = {
150 MultiLocation { parents: 0, interior: X1(Parachain(COLLECTIVES_ID)) } |
151 MultiLocation { parents: 0, interior: X2(Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }) }
152 };
153}
154
155pub type Barrier = TrailingSetTopicAsId<(
157 TakeWeightCredit,
159 AllowKnownQueryResponses<XcmPallet>,
161 WithComputedOrigin<
162 (
163 AllowTopLevelPaidExecutionFrom<Everything>,
165 AllowSubscriptionsFrom<OnlyParachains>,
167 AllowExplicitUnpaidExecutionFrom<CollectivesOrFellows>,
169 ),
170 UniversalLocation,
171 ConstU32<8>,
172 >,
173)>;
174
175pub struct XcmConfig;
176impl xcm_executor::Config for XcmConfig {
177 type RuntimeCall = RuntimeCall;
178 type XcmSender = XcmRouter;
179 type AssetTransactor = LocalAssetTransactor;
180 type OriginConverter = LocalOriginConverter;
181 type IsReserve = ();
183 type IsTeleporter = TrustedTeleporters;
184 type UniversalLocation = UniversalLocation;
185 type Barrier = Barrier;
186 type Weigher = WeightInfoBounds<
187 crate::weights::xcm::PolkadotXcmWeight<RuntimeCall>,
188 RuntimeCall,
189 MaxInstructions,
190 >;
191 type Trader =
193 UsingComponents<WeightToFee, TokenLocation, AccountId, Balances, ToAuthor<Runtime>>;
194 type ResponseHandler = XcmPallet;
195 type AssetTrap = XcmPallet;
196 type AssetLocker = ();
197 type AssetExchanger = ();
198 type AssetClaims = XcmPallet;
199 type SubscriptionService = XcmPallet;
200 type PalletInstancesInfo = AllPalletsWithSystem;
201 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
202 type FeeManager = ();
203 type MessageExporter = ();
205 type UniversalAliases = Nothing;
206 type CallDispatcher = RuntimeCall;
207 type SafeCallFilter = Everything;
208 type Aliasers = Nothing;
209}
210
211parameter_types! {
212 pub const GeneralAdminBodyId: BodyId = BodyId::Administration;
214 pub const StakingAdminBodyId: BodyId = BodyId::Defense;
216 pub const FellowshipAdminBodyId: BodyId = BodyId::Index(FELLOWSHIP_ADMIN_INDEX);
218}
219
220#[cfg(feature = "runtime-benchmarks")]
221parameter_types! {
222 pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
223}
224
225pub type GeneralAdminToPlurality =
227 OriginToPluralityVoice<RuntimeOrigin, GeneralAdmin, GeneralAdminBodyId>;
228
229pub type LocalOriginToLocation = (
232 GeneralAdminToPlurality,
233 SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
235);
236
237pub type StakingAdminToPlurality =
239 OriginToPluralityVoice<RuntimeOrigin, StakingAdmin, StakingAdminBodyId>;
240
241pub type FellowshipAdminToPlurality =
243 OriginToPluralityVoice<RuntimeOrigin, FellowshipAdmin, FellowshipAdminBodyId>;
244
245pub type LocalPalletOriginToLocation = (
248 GeneralAdminToPlurality,
250 StakingAdminToPlurality,
252 FellowshipAdminToPlurality,
254);
255
256impl pallet_xcm::Config for Runtime {
257 type RuntimeEvent = RuntimeEvent;
258 type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalPalletOriginToLocation>;
261 type XcmRouter = XcmRouter;
262 type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
264 type XcmExecuteFilter = Nothing; type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
267 type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds<
270 crate::weights::xcm::PolkadotXcmWeight<RuntimeCall>,
271 RuntimeCall,
272 MaxInstructions,
273 >;
274 type UniversalLocation = UniversalLocation;
275 type RuntimeOrigin = RuntimeOrigin;
276 type RuntimeCall = RuntimeCall;
277 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
278 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
279 type Currency = Balances;
280 type CurrencyMatcher = ();
281 type TrustedLockers = ();
282 type SovereignAccountOf = SovereignAccountOf;
283 type MaxLockers = ConstU32<8>;
284 type MaxRemoteLockConsumers = ConstU32<0>;
285 type RemoteLockConsumerIdentifier = ();
286 type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
287 #[cfg(feature = "runtime-benchmarks")]
288 type ReachableDest = ReachableDest;
289 type AdminOrigin = EnsureRoot<AccountId>;
290}