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::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing},
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 polkadot_runtime_common::xcm_sender::ExponentialPrice;
39use sp_runtime::traits::AccountIdConversion;
40use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
41use xcm_builder::{
42 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
43 AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
44 DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
45 EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
46 NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
47 SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
48 SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
49 UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
50 XcmFeeManagerFromComponents,
51};
52use xcm_executor::XcmExecutor;
53
54parameter_types! {
55 pub const RocRelayLocation: 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 BrokerPalletLocation: Location =
61 PalletInstance(<Broker as PalletInfoAccess>::index() as u8).into();
62 pub const MaxInstructions: u32 = 100;
63 pub const MaxAssetsIntoHolding: u32 = 64;
64 pub const GovernanceLocation: Location = Location::parent();
65 pub const FellowshipLocation: Location = Location::parent();
66}
67
68pub type LocationToAccountId = (
72 ParentIsPreset<AccountId>,
74 SiblingParachainConvertsVia<Sibling, AccountId>,
76 AccountId32Aliases<RelayNetwork, AccountId>,
78 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
80);
81
82pub type FungibleTransactor = FungibleAdapter<
84 Balances,
86 IsConcrete<RocRelayLocation>,
88 LocationToAccountId,
91 AccountId,
93 (),
95>;
96
97pub type RegionTransactor = NonFungibleAdapter<
99 Broker,
101 IsConcrete<BrokerPalletLocation>,
103 LocationToAccountId,
105 AccountId,
107 (),
109>;
110
111pub type AssetTransactors = (FungibleTransactor, RegionTransactor);
113
114pub type XcmOriginToTransactDispatchOrigin = (
118 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
122 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
125 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
128 ParentAsSuperuser<RuntimeOrigin>,
131 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
134 XcmPassthrough<RuntimeOrigin>,
136);
137
138pub struct ParentOrParentsPlurality;
139impl Contains<Location> for ParentOrParentsPlurality {
140 fn contains(location: &Location) -> bool {
141 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
142 }
143}
144
145pub type Barrier = TrailingSetTopicAsId<
146 DenyThenTry<
147 DenyReserveTransferToRelayChain,
148 (
149 TakeWeightCredit,
151 AllowKnownQueryResponses<PolkadotXcm>,
153 WithComputedOrigin<
154 (
155 AllowTopLevelPaidExecutionFrom<Everything>,
158 AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
160 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
162 AllowHrmpNotificationsFromRelayChain,
164 ),
165 UniversalLocation,
166 ConstU32<8>,
167 >,
168 ),
169 >,
170>;
171
172parameter_types! {
173 pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
174 pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
175}
176
177pub type WaivedLocations = (
180 RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
181 Equals<RelayTreasuryLocation>,
182);
183
184pub struct XcmConfig;
185impl xcm_executor::Config for XcmConfig {
186 type RuntimeCall = RuntimeCall;
187 type XcmSender = XcmRouter;
188 type AssetTransactor = AssetTransactors;
189 type OriginConverter = XcmOriginToTransactDispatchOrigin;
190 type IsReserve = ();
193 type IsTeleporter = ConcreteAssetFromSystem<RocRelayLocation>;
195 type UniversalLocation = UniversalLocation;
196 type Barrier = Barrier;
197 type Weigher = WeightInfoBounds<
198 crate::weights::xcm::CoretimeRococoXcmWeight<RuntimeCall>,
199 RuntimeCall,
200 MaxInstructions,
201 >;
202 type Trader = UsingComponents<
203 WeightToFee,
204 RocRelayLocation,
205 AccountId,
206 Balances,
207 ResolveTo<StakingPotAccountId<Runtime>, Balances>,
208 >;
209 type ResponseHandler = PolkadotXcm;
210 type AssetTrap = PolkadotXcm;
211 type AssetClaims = PolkadotXcm;
212 type SubscriptionService = PolkadotXcm;
213 type PalletInstancesInfo = AllPalletsWithSystem;
214 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
215 type AssetLocker = ();
216 type AssetExchanger = ();
217 type FeeManager = XcmFeeManagerFromComponents<
218 WaivedLocations,
219 SendXcmFeeToAccount<Self::AssetTransactor, TreasuryAccount>,
220 >;
221 type MessageExporter = ();
222 type UniversalAliases = Nothing;
223 type CallDispatcher = RuntimeCall;
224 type SafeCallFilter = Everything;
225 type Aliasers = Nothing;
226 type TransactionalProcessor = FrameTransactionalProcessor;
227 type HrmpNewChannelOpenRequestHandler = ();
228 type HrmpChannelAcceptedHandler = ();
229 type HrmpChannelClosingHandler = ();
230 type XcmRecorder = PolkadotXcm;
231}
232
233pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
236
237pub type PriceForParentDelivery =
238 ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
239
240pub type XcmRouter = WithUniqueTopic<(
243 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
245 XcmpQueue,
247)>;
248
249impl pallet_xcm::Config for Runtime {
250 type RuntimeEvent = RuntimeEvent;
251 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
253 type XcmRouter = XcmRouter;
254 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
256 type XcmExecuteFilter = Everything;
257 type XcmExecutor = XcmExecutor<XcmConfig>;
258 type XcmTeleportFilter = Everything;
259 type XcmReserveTransferFilter = Everything;
260 type Weigher = WeightInfoBounds<
261 crate::weights::xcm::CoretimeRococoXcmWeight<RuntimeCall>,
262 RuntimeCall,
263 MaxInstructions,
264 >;
265 type UniversalLocation = UniversalLocation;
266 type RuntimeOrigin = RuntimeOrigin;
267 type RuntimeCall = RuntimeCall;
268 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
269 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
270 type Currency = Balances;
271 type CurrencyMatcher = ();
272 type TrustedLockers = ();
273 type SovereignAccountOf = LocationToAccountId;
274 type MaxLockers = ConstU32<8>;
275 type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
276 type AdminOrigin = EnsureRoot<AccountId>;
277 type MaxRemoteLockConsumers = ConstU32<0>;
278 type RemoteLockConsumerIdentifier = ();
279}
280
281impl cumulus_pallet_xcm::Config for Runtime {
282 type RuntimeEvent = RuntimeEvent;
283 type XcmExecutor = XcmExecutor<XcmConfig>;
284}