xcm_docs/cookbook/relay_token_transactor/relay_chain/
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, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
34
35parameter_types! {
36 pub HereLocation: Location = Location::here();
37 pub ThisNetwork: NetworkId = NetworkId::Polkadot;
38}
39
40pub type LocationToAccountId = (
44 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
45 AccountId32Aliases<ThisNetwork, AccountId>,
46);
47
48mod asset_transactor {
49 use super::*;
50
51 pub type FungibleTransactor = FungibleAdapter<
53 Balances,
55 IsConcrete<HereLocation>,
57 LocationToAccountId,
61 AccountId,
63 (),
65 >;
66
67 pub type AssetTransactor = FungibleTransactor;
69}
70
71mod weigher {
72 use super::*;
73 use xcm_builder::FixedWeightBounds;
74
75 parameter_types! {
76 pub const WeightPerInstruction: Weight = Weight::from_parts(1, 1);
77 pub const MaxInstructions: u32 = 100;
78 }
79
80 pub type Weigher = FixedWeightBounds<WeightPerInstruction, RuntimeCall, MaxInstructions>;
81}
82
83parameter_types! {
84 pub UniversalLocation: InteriorLocation = [GlobalConsensus(NetworkId::Polkadot)].into();
85}
86
87pub struct XcmConfig;
88impl xcm_executor::Config for XcmConfig {
89 type RuntimeCall = RuntimeCall;
90 type XcmSender = ();
91 type XcmEventEmitter = ();
92 type AssetTransactor = asset_transactor::AssetTransactor;
93 type OriginConverter = ();
94 type IsReserve = ();
96 type IsTeleporter = ();
97 type UniversalLocation = UniversalLocation;
98 type Barrier = xcm_builder::AllowUnpaidExecutionFrom<Everything>;
101 type Weigher = weigher::Weigher;
102 type Trader = ();
103 type ResponseHandler = ();
104 type AssetTrap = ();
105 type AssetLocker = ();
106 type AssetExchanger = ();
107 type SubscriptionService = ();
108 type PalletInstancesInfo = ();
109 type FeeManager = ();
110 type MaxAssetsIntoHolding = frame::traits::ConstU32<1>;
111 type MessageExporter = ();
112 type UniversalAliases = Nothing;
113 type CallDispatcher = RuntimeCall;
114 type SafeCallFilter = Everything;
115 type Aliasers = Nothing;
116 type TransactionalProcessor = FrameTransactionalProcessor;
117 type HrmpNewChannelOpenRequestHandler = ();
118 type HrmpChannelAcceptedHandler = ();
119 type HrmpChannelClosingHandler = ();
120 type XcmRecorder = ();
121}
122
123pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>;
126
127impl pallet_xcm::Config for Runtime {
128 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
130 type XcmRouter = super::super::network::RelayChainXcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
133 type XcmExecuteFilter = Everything;
135 type XcmExecutor = XcmExecutor<XcmConfig>;
137 type XcmTeleportFilter = Nothing;
139 type XcmReserveTransferFilter = Everything;
142 type Weigher = weigher::Weigher;
144 type UniversalLocation = UniversalLocation;
146 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
148 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
149 type AdminOrigin = frame_system::EnsureRoot<AccountId>;
150 type TrustedLockers = ();
152 type MaxLockers = frame::traits::ConstU32<0>;
153 type MaxRemoteLockConsumers = frame::traits::ConstU32<0>;
154 type RemoteLockConsumerIdentifier = ();
155 type SovereignAccountOf = LocationToAccountId;
157 type Currency = Balances;
159 type CurrencyMatcher = IsConcrete<HereLocation>;
160 type WeightInfo = pallet_xcm::TestWeightInfo;
162 type RuntimeOrigin = RuntimeOrigin;
164 type RuntimeCall = RuntimeCall;
165 type RuntimeEvent = RuntimeEvent;
166 type AuthorizedAliasConsideration = Disabled;
168}