1use super::{
18 AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo,
19 ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason,
20 RuntimeOrigin, TransactionByteFee, WeightToFee, XcmOverBridgeHubWestend, XcmOverRococoBulletin,
21 XcmpQueue,
22};
23
24use frame_support::{
25 parameter_types,
26 traits::{
27 fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals,
28 Everything, LinearStoragePrice, Nothing,
29 },
30};
31use frame_system::EnsureRoot;
32use pallet_collator_selection::StakingPotAccountId;
33use pallet_xcm::{AuthorizedAliasers, XcmPassthrough};
34use parachains_common::{
35 xcm_config::{
36 AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
37 RelayOrOtherSystemParachains,
38 },
39 TREASURY_PALLET_ID,
40};
41use polkadot_parachain_primitives::primitives::Sibling;
42use polkadot_runtime_common::xcm_sender::ExponentialPrice;
43use sp_runtime::traits::AccountIdConversion;
44use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
45use xcm_builder::{
46 AccountId32Aliases, AliasChildLocation, AllowExplicitUnpaidExecutionFrom,
47 AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
48 AllowTopLevelPaidExecutionFrom, DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry,
49 DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, ExternalConsensusLocationsConverterFor,
50 FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
51 ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative,
52 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
53 SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
54 WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
55};
56use xcm_executor::XcmExecutor;
57
58parameter_types! {
59 pub const RootLocation: Location = Location::here();
60 pub const TokenLocation: Location = Location::parent();
61 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
62 pub RelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
63 pub UniversalLocation: InteriorLocation =
64 [GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
65 pub const MaxInstructions: u32 = 100;
66 pub const MaxAssetsIntoHolding: u32 = 64;
67 pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
68 pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
69 pub SiblingPeople: Location = (Parent, Parachain(rococo_runtime_constants::system_parachain::PEOPLE_ID)).into();
70 pub AssetHubRococoLocation: Location = Location::new(1, [Parachain(bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID)]);
71}
72
73pub type LocationToAccountId = (
77 ParentIsPreset<AccountId>,
79 SiblingParachainConvertsVia<Sibling, AccountId>,
81 AccountId32Aliases<RelayNetwork, AccountId>,
83 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
85 ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>,
87);
88
89pub type FungibleTransactor = FungibleAdapter<
91 Balances,
93 IsConcrete<TokenLocation>,
95 LocationToAccountId,
97 AccountId,
99 (),
101>;
102
103pub type XcmOriginToTransactDispatchOrigin = (
107 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
111 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
114 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
117 ParentAsSuperuser<RuntimeOrigin>,
120 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
123 XcmPassthrough<RuntimeOrigin>,
125);
126
127pub struct ParentOrParentsPlurality;
128
129impl Contains<Location> for ParentOrParentsPlurality {
130 fn contains(location: &Location) -> bool {
131 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
132 }
133}
134
135pub type Barrier = TrailingSetTopicAsId<
136 DenyThenTry<
137 DenyRecursively<DenyReserveTransferToRelayChain>,
138 (
139 TakeWeightCredit,
141 AllowKnownQueryResponses<PolkadotXcm>,
143 WithComputedOrigin<
144 (
145 AllowTopLevelPaidExecutionFrom<Everything>,
148 AllowExplicitUnpaidExecutionFrom<(
151 ParentOrParentsPlurality,
152 Equals<RelayTreasuryLocation>,
153 Equals<SiblingPeople>,
154 Equals<AssetHubRococoLocation>,
155 )>,
156 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
158 AllowHrmpNotificationsFromRelayChain,
160 ),
161 UniversalLocation,
162 ConstU32<8>,
163 >,
164 ),
165 >,
166>;
167
168pub type WaivedLocations = (
172 Equals<RootLocation>,
173 RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
174 Equals<RelayTreasuryLocation>,
175);
176
177pub type TrustedTeleporters = ConcreteAssetFromSystem<TokenLocation>;
180
181pub type TrustedAliasers = (AliasChildLocation, AuthorizedAliasers<Runtime>);
186
187pub struct XcmConfig;
188
189impl xcm_executor::Config for XcmConfig {
190 type RuntimeCall = RuntimeCall;
191 type XcmSender = XcmRouter;
192 type XcmEventEmitter = PolkadotXcm;
193 type AssetTransactor = FungibleTransactor;
194 type OriginConverter = XcmOriginToTransactDispatchOrigin;
195 type IsReserve = ();
198 type IsTeleporter = TrustedTeleporters;
199 type UniversalLocation = UniversalLocation;
200 type Barrier = Barrier;
201 type Weigher = WeightInfoBounds<
202 crate::weights::xcm::BridgeHubRococoXcmWeight<RuntimeCall>,
203 RuntimeCall,
204 MaxInstructions,
205 >;
206 type Trader = UsingComponents<
207 WeightToFee,
208 TokenLocation,
209 AccountId,
210 Balances,
211 ResolveTo<StakingPotAccountId<Runtime>, Balances>,
212 >;
213 type ResponseHandler = PolkadotXcm;
214 type AssetTrap = PolkadotXcm;
215 type AssetLocker = ();
216 type AssetExchanger = ();
217 type SubscriptionService = PolkadotXcm;
218 type PalletInstancesInfo = AllPalletsWithSystem;
219 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
220 type FeeManager = XcmFeeManagerFromComponents<
221 WaivedLocations,
222 SendXcmFeeToAccount<Self::AssetTransactor, TreasuryAccount>,
223 >;
224 type MessageExporter = (
225 XcmOverBridgeHubWestend,
226 XcmOverRococoBulletin,
227 crate::bridge_to_ethereum_config::SnowbridgeExporter,
228 );
229 type UniversalAliases = Nothing;
230 type CallDispatcher = RuntimeCall;
231 type SafeCallFilter = Everything;
232 type Aliasers = TrustedAliasers;
233 type TransactionalProcessor = FrameTransactionalProcessor;
234 type HrmpNewChannelOpenRequestHandler = ();
235 type HrmpChannelAcceptedHandler = ();
236 type HrmpChannelClosingHandler = ();
237 type XcmRecorder = PolkadotXcm;
238}
239
240pub type PriceForParentDelivery =
241 ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
242
243pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
246
247pub type XcmRouter = WithUniqueTopic<(
250 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, PriceForParentDelivery>,
252 XcmpQueue,
254)>;
255
256parameter_types! {
257 pub const DepositPerItem: Balance = crate::deposit(1, 0);
258 pub const DepositPerByte: Balance = crate::deposit(0, 1);
259 pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias);
260}
261
262impl pallet_xcm::Config for Runtime {
263 type RuntimeEvent = RuntimeEvent;
264 type XcmRouter = XcmRouter;
265 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
267 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
269 type XcmExecuteFilter = Everything;
270 type XcmExecutor = XcmExecutor<XcmConfig>;
271 type XcmTeleportFilter = Everything;
272 type XcmReserveTransferFilter = Nothing;
274 type Weigher = WeightInfoBounds<
275 crate::weights::xcm::BridgeHubRococoXcmWeight<RuntimeCall>,
276 RuntimeCall,
277 MaxInstructions,
278 >;
279 type UniversalLocation = UniversalLocation;
280 type RuntimeOrigin = RuntimeOrigin;
281 type RuntimeCall = RuntimeCall;
282 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
283 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
284 type Currency = Balances;
285 type CurrencyMatcher = ();
286 type TrustedLockers = ();
287 type SovereignAccountOf = LocationToAccountId;
288 type MaxLockers = ConstU32<8>;
289 type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
290 type AdminOrigin = EnsureRoot<AccountId>;
291 type MaxRemoteLockConsumers = ConstU32<0>;
292 type RemoteLockConsumerIdentifier = ();
293 type AuthorizedAliasConsideration = HoldConsideration<
295 AccountId,
296 Balances,
297 AuthorizeAliasHoldReason,
298 LinearStoragePrice<DepositPerItem, DepositPerByte, Balance>,
299 >;
300}
301
302impl cumulus_pallet_xcm::Config for Runtime {
303 type RuntimeEvent = RuntimeEvent;
304 type XcmExecutor = XcmExecutor<XcmConfig>;
305}