1use super::{
18 AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, Broker, FeeAssetId, ParachainInfo,
19 ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
20 TransactionByteFee, WeightToFee, XcmpQueue,
21};
22use frame_support::{
23 pallet_prelude::PalletInfoAccess,
24 parameter_types,
25 traits::{
26 tokens::imbalance::ResolveTo, ConstU32, Contains, Disabled, Equals, Everything, Nothing,
27 },
28};
29use frame_system::EnsureRoot;
30use pallet_collator_selection::StakingPotAccountId;
31use pallet_xcm::XcmPassthrough;
32use parachains_common::{
33 xcm_config::{
34 AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
35 RelayOrOtherSystemParachains,
36 },
37 TREASURY_PALLET_ID,
38};
39use polkadot_parachain_primitives::primitives::Sibling;
40use polkadot_runtime_common::xcm_sender::ExponentialPrice;
41use sp_runtime::traits::AccountIdConversion;
42use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
43use xcm_builder::{
44 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
45 AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
46 DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal,
47 DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
48 HashedDescription, IsConcrete, NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset,
49 RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
50 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
51 TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
52 XcmFeeManagerFromComponents,
53};
54use xcm_executor::XcmExecutor;
55
56parameter_types! {
57 pub const RootLocation: Location = Location::here();
58 pub const RocRelayLocation: Location = Location::parent();
59 pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH));
60 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
61 pub UniversalLocation: InteriorLocation =
62 [GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
63 pub BrokerPalletLocation: Location =
64 PalletInstance(<Broker as PalletInfoAccess>::index() as u8).into();
65 pub const MaxInstructions: u32 = 100;
66 pub const MaxAssetsIntoHolding: u32 = 64;
67 pub const GovernanceLocation: Location = Location::parent();
68 pub const FellowshipLocation: Location = Location::parent();
69}
70
71pub type LocationToAccountId = (
75 ParentIsPreset<AccountId>,
77 SiblingParachainConvertsVia<Sibling, AccountId>,
79 AccountId32Aliases<RelayNetwork, AccountId>,
81 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
83);
84
85pub type FungibleTransactor = FungibleAdapter<
87 Balances,
89 IsConcrete<RocRelayLocation>,
91 LocationToAccountId,
94 AccountId,
96 (),
98>;
99
100pub type RegionTransactor = NonFungibleAdapter<
102 Broker,
104 IsConcrete<BrokerPalletLocation>,
106 LocationToAccountId,
108 AccountId,
110 (),
112>;
113
114pub type AssetTransactors = (FungibleTransactor, RegionTransactor);
116
117pub type XcmOriginToTransactDispatchOrigin = (
121 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
125 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
128 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
131 ParentAsSuperuser<RuntimeOrigin>,
134 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
137 XcmPassthrough<RuntimeOrigin>,
139);
140
141pub struct ParentOrParentsPlurality;
142impl Contains<Location> for ParentOrParentsPlurality {
143 fn contains(location: &Location) -> bool {
144 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
145 }
146}
147
148pub type Barrier = TrailingSetTopicAsId<
149 DenyThenTry<
150 DenyRecursively<DenyReserveTransferToRelayChain>,
151 (
152 TakeWeightCredit,
154 AllowKnownQueryResponses<PolkadotXcm>,
156 WithComputedOrigin<
157 (
158 AllowTopLevelPaidExecutionFrom<Everything>,
161 AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
163 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
165 AllowHrmpNotificationsFromRelayChain,
167 ),
168 UniversalLocation,
169 ConstU32<8>,
170 >,
171 ),
172 >,
173>;
174
175parameter_types! {
176 pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
177 pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
178}
179
180pub type WaivedLocations = (
183 Equals<RootLocation>,
184 RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
185 Equals<RelayTreasuryLocation>,
186);
187
188pub type TrustedTeleporters = ConcreteAssetFromSystem<RocRelayLocation>;
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 = AssetTransactors;
198 type OriginConverter = XcmOriginToTransactDispatchOrigin;
199 type IsReserve = ();
202 type IsTeleporter = TrustedTeleporters;
203 type UniversalLocation = UniversalLocation;
204 type Barrier = Barrier;
205 type Weigher = WeightInfoBounds<
206 crate::weights::xcm::CoretimeRococoXcmWeight<RuntimeCall>,
207 RuntimeCall,
208 MaxInstructions,
209 >;
210 type Trader = UsingComponents<
211 WeightToFee,
212 RocRelayLocation,
213 AccountId,
214 Balances,
215 ResolveTo<StakingPotAccountId<Runtime>, Balances>,
216 >;
217 type ResponseHandler = PolkadotXcm;
218 type AssetTrap = PolkadotXcm;
219 type AssetClaims = PolkadotXcm;
220 type SubscriptionService = PolkadotXcm;
221 type PalletInstancesInfo = AllPalletsWithSystem;
222 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
223 type AssetLocker = ();
224 type AssetExchanger = ();
225 type FeeManager = XcmFeeManagerFromComponents<
226 WaivedLocations,
227 SendXcmFeeToAccount<Self::AssetTransactor, TreasuryAccount>,
228 >;
229 type MessageExporter = ();
230 type UniversalAliases = Nothing;
231 type CallDispatcher = RuntimeCall;
232 type SafeCallFilter = Everything;
233 type Aliasers = Nothing;
234 type TransactionalProcessor = FrameTransactionalProcessor;
235 type HrmpNewChannelOpenRequestHandler = ();
236 type HrmpChannelAcceptedHandler = ();
237 type HrmpChannelClosingHandler = ();
238 type XcmRecorder = PolkadotXcm;
239}
240
241pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
244
245pub type PriceForParentDelivery =
246 ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
247
248pub type XcmRouter = WithUniqueTopic<(
251 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
253 XcmpQueue,
255)>;
256
257impl pallet_xcm::Config for Runtime {
258 type RuntimeEvent = RuntimeEvent;
259 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
261 type XcmRouter = XcmRouter;
262 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
264 type XcmExecuteFilter = Everything;
265 type XcmExecutor = XcmExecutor<XcmConfig>;
266 type XcmTeleportFilter = Everything;
267 type XcmReserveTransferFilter = Everything;
268 type Weigher = WeightInfoBounds<
269 crate::weights::xcm::CoretimeRococoXcmWeight<RuntimeCall>,
270 RuntimeCall,
271 MaxInstructions,
272 >;
273 type UniversalLocation = UniversalLocation;
274 type RuntimeOrigin = RuntimeOrigin;
275 type RuntimeCall = RuntimeCall;
276 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
277 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
278 type Currency = Balances;
279 type CurrencyMatcher = ();
280 type TrustedLockers = ();
281 type SovereignAccountOf = LocationToAccountId;
282 type MaxLockers = ConstU32<8>;
283 type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
284 type AdminOrigin = EnsureRoot<AccountId>;
285 type MaxRemoteLockConsumers = ConstU32<0>;
286 type RemoteLockConsumerIdentifier = ();
287 type AuthorizedAliasConsideration = Disabled;
289}
290
291impl cumulus_pallet_xcm::Config for Runtime {
292 type RuntimeEvent = RuntimeEvent;
293 type XcmExecutor = XcmExecutor<XcmConfig>;
294}