1use super::{
17 AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
18 Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
19};
20use crate::{TransactionByteFee, CENTS};
21use frame_support::{
22 parameter_types,
23 traits::{
24 tokens::imbalance::ResolveTo, ConstU32, Contains, Disabled, Equals, Everything, Nothing,
25 },
26};
27use frame_system::EnsureRoot;
28use pallet_collator_selection::StakingPotAccountId;
29use pallet_xcm::XcmPassthrough;
30use parachains_common::{
31 xcm_config::{
32 AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
33 RelayOrOtherSystemParachains,
34 },
35 TREASURY_PALLET_ID,
36};
37use polkadot_parachain_primitives::primitives::Sibling;
38use sp_runtime::traits::AccountIdConversion;
39use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
40use xcm_builder::{
41 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
42 AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
43 DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal,
44 DescribeFamily, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor,
45 FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset,
46 RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
47 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
48 TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
49 XcmFeeManagerFromComponents,
50};
51use xcm_executor::XcmExecutor;
52
53parameter_types! {
54 pub const RootLocation: Location = Location::here();
55 pub const RelayLocation: Location = Location::parent();
56 pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH));
57 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
58 pub UniversalLocation: InteriorLocation =
59 [GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
60 pub const MaxInstructions: u32 = 100;
61 pub const MaxAssetsIntoHolding: u32 = 64;
62 pub const GovernanceLocation: Location = Location::parent();
63 pub const FellowshipLocation: Location = Location::parent();
64 pub FeeAssetId: AssetId = AssetId(RelayLocation::get());
66 pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
68 pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
69 pub RelayTreasuryLocation: Location =
70 (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
71}
72
73pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
74 FeeAssetId,
75 BaseDeliveryFee,
76 TransactionByteFee,
77 ParachainSystem,
78>;
79
80pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
81 FeeAssetId,
82 BaseDeliveryFee,
83 TransactionByteFee,
84 XcmpQueue,
85>;
86
87pub type LocationToAccountId = (
91 ParentIsPreset<AccountId>,
93 SiblingParachainConvertsVia<Sibling, AccountId>,
95 AccountId32Aliases<RelayNetwork, AccountId>,
97 HashedDescription<AccountId, DescribeTerminus>,
99 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
101);
102
103pub type FungibleTransactor = FungibleAdapter<
105 Balances,
107 IsConcrete<RelayLocation>,
109 LocationToAccountId,
112 AccountId,
114 (),
116>;
117
118pub type XcmOriginToTransactDispatchOrigin = (
122 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
126 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
129 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
132 ParentAsSuperuser<RuntimeOrigin>,
135 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
138 XcmPassthrough<RuntimeOrigin>,
140);
141
142pub struct LocalPlurality;
143impl Contains<Location> for LocalPlurality {
144 fn contains(location: &Location) -> bool {
145 matches!(location.unpack(), (0, [Plurality { .. }]))
146 }
147}
148
149pub struct ParentOrParentsPlurality;
150impl Contains<Location> for ParentOrParentsPlurality {
151 fn contains(location: &Location) -> bool {
152 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
153 }
154}
155
156pub type Barrier = TrailingSetTopicAsId<
157 DenyThenTry<
158 DenyRecursively<DenyReserveTransferToRelayChain>,
159 (
160 TakeWeightCredit,
162 AllowKnownQueryResponses<PolkadotXcm>,
164 WithComputedOrigin<
165 (
166 AllowTopLevelPaidExecutionFrom<Everything>,
169 AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
171 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
173 AllowHrmpNotificationsFromRelayChain,
175 ),
176 UniversalLocation,
177 ConstU32<8>,
178 >,
179 ),
180 >,
181>;
182
183pub type WaivedLocations = (
186 RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
187 Equals<RelayTreasuryLocation>,
188 Equals<RootLocation>,
189 LocalPlurality,
190);
191
192pub struct XcmConfig;
193impl xcm_executor::Config for XcmConfig {
194 type RuntimeCall = RuntimeCall;
195 type XcmSender = XcmRouter;
196 type XcmEventEmitter = PolkadotXcm;
197 type AssetTransactor = FungibleTransactor;
198 type OriginConverter = XcmOriginToTransactDispatchOrigin;
199 type IsReserve = ();
202 type IsTeleporter = ConcreteAssetFromSystem<RelayLocation>;
204 type UniversalLocation = UniversalLocation;
205 type Barrier = Barrier;
206 type Weigher = WeightInfoBounds<
207 crate::weights::xcm::PeopleRococoXcmWeight<RuntimeCall>,
208 RuntimeCall,
209 MaxInstructions,
210 >;
211 type Trader = UsingComponents<
212 WeightToFee,
213 RelayLocation,
214 AccountId,
215 Balances,
216 ResolveTo<StakingPotAccountId<Runtime>, Balances>,
217 >;
218 type ResponseHandler = PolkadotXcm;
219 type AssetTrap = PolkadotXcm;
220 type AssetClaims = PolkadotXcm;
221 type SubscriptionService = PolkadotXcm;
222 type PalletInstancesInfo = AllPalletsWithSystem;
223 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
224 type AssetLocker = ();
225 type AssetExchanger = ();
226 type FeeManager = XcmFeeManagerFromComponents<
227 WaivedLocations,
228 SendXcmFeeToAccount<Self::AssetTransactor, TreasuryAccount>,
229 >;
230 type MessageExporter = ();
231 type UniversalAliases = Nothing;
232 type CallDispatcher = RuntimeCall;
233 type SafeCallFilter = Everything;
234 type Aliasers = Nothing;
235 type TransactionalProcessor = FrameTransactionalProcessor;
236 type HrmpNewChannelOpenRequestHandler = ();
237 type HrmpChannelAcceptedHandler = ();
238 type HrmpChannelClosingHandler = ();
239 type XcmRecorder = PolkadotXcm;
240}
241
242pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
245
246pub type XcmRouter = WithUniqueTopic<(
249 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
251 XcmpQueue,
253)>;
254
255impl pallet_xcm::Config for Runtime {
256 type RuntimeEvent = RuntimeEvent;
257 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
259 type XcmRouter = XcmRouter;
260 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
262 type XcmExecuteFilter = Everything;
263 type XcmExecutor = XcmExecutor<XcmConfig>;
264 type XcmTeleportFilter = Everything;
265 type XcmReserveTransferFilter = Nothing; type Weigher = WeightInfoBounds<
267 crate::weights::xcm::PeopleRococoXcmWeight<RuntimeCall>,
268 RuntimeCall,
269 MaxInstructions,
270 >;
271 type UniversalLocation = UniversalLocation;
272 type RuntimeOrigin = RuntimeOrigin;
273 type RuntimeCall = RuntimeCall;
274 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
275 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
276 type Currency = Balances;
277 type CurrencyMatcher = ();
278 type TrustedLockers = ();
279 type SovereignAccountOf = LocationToAccountId;
280 type MaxLockers = ConstU32<8>;
281 type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
282 type AdminOrigin = EnsureRoot<AccountId>;
283 type MaxRemoteLockConsumers = ConstU32<0>;
284 type RemoteLockConsumerIdentifier = ();
285 type AuthorizedAliasConsideration = Disabled;
287}
288
289impl cumulus_pallet_xcm::Config for Runtime {
290 type RuntimeEvent = RuntimeEvent;
291 type XcmExecutor = XcmExecutor<XcmConfig>;
292}