xcm_docs/cookbook/relay_token_transactor/parachain/
xcm_config.rs1use frame::{
21 deps::frame_system,
22 runtime::prelude::*,
23 traits::{Disabled, Everything, Nothing},
24};
25use xcm::latest::prelude::*;
26use xcm_builder::{
27 AccountId32Aliases, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin,
28 FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
29 SignedToAccountId32,
30};
31use xcm_executor::XcmExecutor;
32
33use super::{AccountId, Balances, MessageQueue, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
34
35parameter_types! {
36 pub RelayLocation: Location = Location::parent();
37 pub ThisNetwork: NetworkId = NetworkId::Polkadot;
38}
39
40pub type LocationToAccountId = (
41 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
42 AccountId32Aliases<ThisNetwork, AccountId>,
43);
44
45#[docify::export]
47mod asset_transactor {
48 use super::*;
49
50 parameter_types! {
51 pub ParentRelayLocation: Location = Location::parent();
52 }
53
54 pub type FungibleTransactor = FungibleAdapter<
56 Balances,
60 IsConcrete<ParentRelayLocation>,
64 LocationToAccountId,
67 AccountId,
69 (),
72 >;
73
74 pub type AssetTransactor = FungibleTransactor;
79}
80
81#[docify::export]
83mod is_reserve {
84 use super::*;
85
86 parameter_types! {
87 pub RelayTokenForRelay: (AssetFilter, Location) =
91 (Wild(AllOf { id: AssetId(Parent.into()), fun: WildFungible }), Parent.into());
92 }
93
94 pub type IsReserve = xcm_builder::Case<RelayTokenForRelay>;
96}
97
98mod weigher {
99 use super::*;
100 use xcm_builder::FixedWeightBounds;
101
102 parameter_types! {
103 pub const WeightPerInstruction: Weight = Weight::from_parts(1, 1);
104 pub const MaxInstructions: u32 = 100;
105 }
106
107 pub type Weigher = FixedWeightBounds<WeightPerInstruction, RuntimeCall, MaxInstructions>;
108}
109
110parameter_types! {
111 pub UniversalLocation: InteriorLocation = [GlobalConsensus(NetworkId::Polkadot), Parachain(2222)].into();
112}
113
114pub struct XcmConfig;
115impl xcm_executor::Config for XcmConfig {
116 type RuntimeCall = RuntimeCall;
117 type XcmSender = ();
118 type XcmEventEmitter = ();
119 type AssetTransactor = asset_transactor::AssetTransactor;
120 type OriginConverter = ();
121 type IsReserve = is_reserve::IsReserve;
123 type IsTeleporter = ();
124 type UniversalLocation = UniversalLocation;
125 type Barrier = xcm_builder::AllowUnpaidExecutionFrom<Everything>;
128 type Weigher = weigher::Weigher;
129 type Trader = ();
130 type ResponseHandler = ();
131 type AssetTrap = ();
132 type AssetLocker = ();
133 type AssetExchanger = ();
134 type AssetClaims = ();
135 type SubscriptionService = ();
136 type PalletInstancesInfo = ();
137 type FeeManager = ();
138 type MaxAssetsIntoHolding = frame::traits::ConstU32<1>;
139 type MessageExporter = ();
140 type UniversalAliases = Nothing;
141 type CallDispatcher = RuntimeCall;
142 type SafeCallFilter = Everything;
143 type Aliasers = Nothing;
144 type TransactionalProcessor = FrameTransactionalProcessor;
145 type HrmpNewChannelOpenRequestHandler = ();
146 type HrmpChannelAcceptedHandler = ();
147 type HrmpChannelClosingHandler = ();
148 type XcmRecorder = ();
149}
150
151pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>;
154
155impl pallet_xcm::Config for Runtime {
156 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
158 type XcmRouter = super::super::network::ParachainXcmRouter<MessageQueue>; type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
161 type XcmExecuteFilter = Everything;
163 type XcmExecutor = XcmExecutor<XcmConfig>;
165 type XcmTeleportFilter = Nothing;
167 type XcmReserveTransferFilter = Everything;
169 type Weigher = weigher::Weigher;
171 type UniversalLocation = UniversalLocation;
173 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
175 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
176 type AdminOrigin = frame_system::EnsureRoot<AccountId>;
177 type TrustedLockers = ();
179 type MaxLockers = frame::traits::ConstU32<0>;
180 type MaxRemoteLockConsumers = frame::traits::ConstU32<0>;
181 type RemoteLockConsumerIdentifier = ();
182 type SovereignAccountOf = LocationToAccountId;
184 type Currency = Balances;
186 type CurrencyMatcher = IsConcrete<RelayLocation>;
187 type WeightInfo = pallet_xcm::TestWeightInfo;
189 type RuntimeOrigin = RuntimeOrigin;
191 type RuntimeCall = RuntimeCall;
192 type RuntimeEvent = RuntimeEvent;
193 type AuthorizedAliasConsideration = Disabled;
195}