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 AssetClaims = ();
108 type SubscriptionService = ();
109 type PalletInstancesInfo = ();
110 type FeeManager = ();
111 type MaxAssetsIntoHolding = frame::traits::ConstU32<1>;
112 type MessageExporter = ();
113 type UniversalAliases = Nothing;
114 type CallDispatcher = RuntimeCall;
115 type SafeCallFilter = Everything;
116 type Aliasers = Nothing;
117 type TransactionalProcessor = FrameTransactionalProcessor;
118 type HrmpNewChannelOpenRequestHandler = ();
119 type HrmpChannelAcceptedHandler = ();
120 type HrmpChannelClosingHandler = ();
121 type XcmRecorder = ();
122}
123
124pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>;
127
128impl pallet_xcm::Config for Runtime {
129 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
131 type XcmRouter = super::super::network::RelayChainXcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
134 type XcmExecuteFilter = Everything;
136 type XcmExecutor = XcmExecutor<XcmConfig>;
138 type XcmTeleportFilter = Nothing;
140 type XcmReserveTransferFilter = Everything;
143 type Weigher = weigher::Weigher;
145 type UniversalLocation = UniversalLocation;
147 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
149 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
150 type AdminOrigin = frame_system::EnsureRoot<AccountId>;
151 type TrustedLockers = ();
153 type MaxLockers = frame::traits::ConstU32<0>;
154 type MaxRemoteLockConsumers = frame::traits::ConstU32<0>;
155 type RemoteLockConsumerIdentifier = ();
156 type SovereignAccountOf = LocationToAccountId;
158 type Currency = Balances;
160 type CurrencyMatcher = IsConcrete<HereLocation>;
161 type WeightInfo = pallet_xcm::TestWeightInfo;
163 type RuntimeOrigin = RuntimeOrigin;
165 type RuntimeCall = RuntimeCall;
166 type RuntimeEvent = RuntimeEvent;
167 type AuthorizedAliasConsideration = Disabled;
169}