1use super::{
20 AccountId, AllPalletsWithSystem, AssetId, Assets, Balance, Balances, DealWithFees,
21 MessageQueue, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent,
22 RuntimeOrigin, ShibuyaAssetLocationIdConverter, TreasuryAccountId, XcAssetConfig,
23 XcmWeightToFee, XcmpQueue,
24};
25use crate::weights;
26use frame_support::{
27 parameter_types,
28 traits::{ConstU32, Contains, Everything, Nothing},
29 weights::Weight,
30};
31use frame_system::EnsureRoot;
32
33use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
35use frame_support::traits::{Disabled, TransformOrigin};
36use parachains_common::{
37 message_queue::ParaIdToSibling, xcm_config::ParentRelayOrSiblingParachains,
38};
39use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
40use xcm::{latest::prelude::*, v5::ROCOCO_GENESIS_HASH};
41use xcm_builder::{
42 AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
43 AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId,
44 DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
45 FungibleAdapter, FungiblesAdapter, HashedDescription, IsConcrete, NoChecking,
46 ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
47 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
48 SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
49 WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
50};
51use xcm_executor::{traits::JustTry, XcmExecutor};
52
53use astar_primitives::xcm::{
55 FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, MAX_ASSETS,
56};
57
58parameter_types! {
59 pub 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 const ShibuyaLocation: Location = Here.into_location();
64 pub DummyCheckingAccount: AccountId = PolkadotXcm::check_account();
65}
66
67pub type LocationToAccountId = (
71 ParentIsPreset<AccountId>,
73 SiblingParachainConvertsVia<polkadot_parachain::primitives::Sibling, AccountId>,
75 AccountId32Aliases<RelayNetwork, AccountId>,
77 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
80);
81
82pub type CurrencyTransactor = FungibleAdapter<
84 Balances,
86 IsConcrete<ShibuyaLocation>,
88 LocationToAccountId,
90 AccountId,
92 (),
94>;
95
96pub type FungiblesTransactor = FungiblesAdapter<
98 Assets,
100 ConvertedConcreteId<AssetId, Balance, ShibuyaAssetLocationIdConverter, JustTry>,
102 LocationToAccountId,
104 AccountId,
106 NoChecking,
108 DummyCheckingAccount,
110>;
111
112pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor);
114
115pub type XcmOriginToTransactDispatchOrigin = (
119 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
123 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
126 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
129 ParentAsSuperuser<RuntimeOrigin>,
132 pallet_xcm::XcmPassthrough<RuntimeOrigin>,
134 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
137);
138
139parameter_types! {
140 pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 4 * 1024);
143 pub const MaxInstructions: u32 = 100;
144 pub const MaxAssetsIntoHolding: u32 = MAX_ASSETS as u32;
145}
146
147pub struct ParentOrParentsPlurality;
148impl Contains<Location> for ParentOrParentsPlurality {
149 fn contains(location: &Location) -> bool {
150 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
151 }
152}
153
154pub type XcmBarrier = TrailingSetTopicAsId<(
155 TakeWeightCredit,
156 AllowKnownQueryResponses<PolkadotXcm>,
158 WithComputedOrigin<
160 (
161 AllowTopLevelPaidExecutionFrom<Everything>,
163 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
165 ),
166 UniversalLocation,
167 ConstU32<8>,
168 >,
169 AllowUnpaidExecutionFrom<ParentOrParentsPlurality>,
171)>;
172
173pub type ShibuyaXcmFungibleFeeHandler = XcmFungibleFeeHandler<
175 AccountId,
176 ConvertedConcreteId<AssetId, Balance, ShibuyaAssetLocationIdConverter, JustTry>,
177 Assets,
178 TreasuryAccountId,
179>;
180
181pub type Weigher =
182 WeightInfoBounds<weights::xcm::XcmWeight<Runtime, RuntimeCall>, RuntimeCall, MaxInstructions>;
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 = ReserveAssetFilter;
191 type IsTeleporter = ();
192 type UniversalLocation = UniversalLocation;
193 type Barrier = XcmBarrier;
194 type Weigher = Weigher;
195 type Trader = (
196 UsingComponents<XcmWeightToFee, ShibuyaLocation, AccountId, Balances, DealWithFees>,
197 FixedRateOfForeignAsset<XcAssetConfig, ShibuyaXcmFungibleFeeHandler>,
198 );
199 type ResponseHandler = PolkadotXcm;
200 type AssetTrap = PolkadotXcm;
201 type AssetClaims = PolkadotXcm;
202 type SubscriptionService = PolkadotXcm;
203
204 type PalletInstancesInfo = AllPalletsWithSystem;
205 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
206 type AssetLocker = ();
207 type AssetExchanger = ();
208 type FeeManager = ();
209 type MessageExporter = ();
210 type UniversalAliases = Nothing;
211 type CallDispatcher = RuntimeCall;
212 type SafeCallFilter = Everything;
213 type Aliasers = Nothing;
214 type TransactionalProcessor = FrameTransactionalProcessor;
215
216 type HrmpNewChannelOpenRequestHandler = ();
217 type HrmpChannelAcceptedHandler = ();
218 type HrmpChannelClosingHandler = ();
219 type XcmRecorder = PolkadotXcm;
220 type XcmEventEmitter = PolkadotXcm;
221}
222
223pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
225
226pub type XcmRouter = WithUniqueTopic<(
229 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
231 XcmpQueue,
233)>;
234
235impl pallet_xcm::Config for Runtime {
236 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
237
238 type RuntimeEvent = RuntimeEvent;
239 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
240 type XcmRouter = XcmRouter;
241 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
242 type XcmExecuteFilter = Nothing;
243 type XcmExecutor = XcmExecutor<XcmConfig>;
244 type XcmTeleportFilter = Nothing;
245 type XcmReserveTransferFilter = Everything;
246 type Weigher = Weigher;
247 type UniversalLocation = UniversalLocation;
248 type RuntimeOrigin = RuntimeOrigin;
249 type RuntimeCall = RuntimeCall;
250 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
251 type Currency = Balances;
252 type CurrencyMatcher = ();
253 type TrustedLockers = ();
254 type SovereignAccountOf = LocationToAccountId;
255 type MaxLockers = ConstU32<0>;
256 type WeightInfo = weights::pallet_xcm::SubstrateWeight<Runtime>;
257 type MaxRemoteLockConsumers = ConstU32<0>;
258 type RemoteLockConsumerIdentifier = ();
259 type AdminOrigin = EnsureRoot<AccountId>;
260 type AuthorizedAliasConsideration = Disabled;
261}
262
263impl cumulus_pallet_xcm::Config for Runtime {
264 type RuntimeEvent = RuntimeEvent;
265 type XcmExecutor = XcmExecutor<XcmConfig>;
266}
267
268impl cumulus_pallet_xcmp_queue::Config for Runtime {
269 type RuntimeEvent = RuntimeEvent;
270 type ChannelInfo = ParachainSystem;
271 type VersionWrapper = PolkadotXcm;
272 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
273 type MaxInboundSuspended = ConstU32<1_000>;
274 type MaxActiveOutboundChannels = ConstU32<128>;
275 type MaxPageSize = ConstU32<{ 128 * 1024 }>;
276 type ControllerOrigin = EnsureRoot<AccountId>;
277 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
278 type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
279 type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
280}