staging_xcm_executor/config.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17use crate::traits::{
18 AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, EventEmitter,
19 ExportXcm, FeeManager, HandleHrmpChannelAccepted, HandleHrmpChannelClosing,
20 HandleHrmpNewChannelOpenRequest, OnResponse, ProcessTransaction, RecordXcm, ShouldExecute,
21 TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader,
22};
23use frame_support::{
24 dispatch::{GetDispatchInfo, Parameter, PostDispatchInfo},
25 traits::{Contains, ContainsPair, Get, PalletsInfoAccess},
26};
27use sp_runtime::traits::Dispatchable;
28use xcm::prelude::*;
29
30/// The trait to parameterize the `XcmExecutor`.
31pub trait Config {
32 /// The outer call dispatch type.
33 type RuntimeCall: Parameter + Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo;
34
35 /// How to send an onward XCM message.
36 ///
37 /// The sender is tasked with returning the assets it needs to pay for delivery fees.
38 /// Only one asset should be returned as delivery fees, any other will be ignored by
39 /// the executor.
40 type XcmSender: SendXcm;
41
42 /// How to emit XCM events.
43 type XcmEventEmitter: EventEmitter;
44
45 /// How to withdraw and deposit an asset.
46 type AssetTransactor: TransactAsset;
47
48 /// How to get a call origin from a `OriginKind` value.
49 type OriginConverter: ConvertOrigin<<Self::RuntimeCall as Dispatchable>::RuntimeOrigin>;
50
51 /// Combinations of (Asset, Location) pairs which we trust as reserves.
52 type IsReserve: ContainsPair<Asset, Location>;
53
54 /// Combinations of (Asset, Location) pairs which we trust as teleporters.
55 type IsTeleporter: ContainsPair<Asset, Location>;
56
57 /// A list of (Origin, Target) pairs allowing a given Origin to be substituted with its
58 /// corresponding Target pair.
59 type Aliasers: ContainsPair<Location, Location>;
60
61 /// This chain's Universal Location.
62 type UniversalLocation: Get<InteriorLocation>;
63
64 /// Whether we should execute the given XCM at all.
65 type Barrier: ShouldExecute;
66
67 /// The means of determining an XCM message's weight.
68 type Weigher: WeightBounds<Self::RuntimeCall>;
69
70 /// The means of purchasing weight credit for XCM execution.
71 type Trader: WeightTrader;
72
73 /// What to do when a response of a query is found.
74 type ResponseHandler: OnResponse;
75
76 /// The general asset trap - handler for when assets are left in the Holding Register at the
77 /// end of execution.
78 type AssetTrap: DropAssets;
79
80 /// Handler for asset locking.
81 type AssetLocker: AssetLock;
82
83 /// Handler for exchanging assets.
84 ///
85 /// This is used in the executor to swap the asset wanted for fees with the asset needed for
86 /// delivery fees.
87 type AssetExchanger: AssetExchange;
88
89 /// The handler for when there is an instruction to claim assets.
90 type AssetClaims: ClaimAssets;
91
92 /// How we handle version subscription requests.
93 type SubscriptionService: VersionChangeNotifier;
94
95 /// Information on all pallets.
96 type PalletInstancesInfo: PalletsInfoAccess;
97
98 /// The maximum number of assets we target to have in the Holding Register at any one time.
99 ///
100 /// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this
101 /// and any benchmarks should take that into account.
102 type MaxAssetsIntoHolding: Get<u32>;
103
104 /// Configure the fees.
105 type FeeManager: FeeManager;
106
107 /// The method of exporting a message.
108 type MessageExporter: ExportXcm;
109
110 /// The origin locations and specific universal junctions to which they are allowed to elevate
111 /// themselves.
112 type UniversalAliases: Contains<(Location, Junction)>;
113
114 /// The call dispatcher used by XCM.
115 ///
116 /// XCM will use this to dispatch any calls. When no special call dispatcher is required,
117 /// this can be set to the same type as `Self::Call`.
118 type CallDispatcher: CallDispatcher<Self::RuntimeCall>;
119
120 /// The safe call filter for `Transact`.
121 ///
122 /// Use this type to explicitly whitelist calls that cannot undergo recursion. This is a
123 /// temporary measure until we properly account for proof size weights for XCM instructions.
124 type SafeCallFilter: Contains<Self::RuntimeCall>;
125
126 /// Transactional processor for XCM instructions.
127 type TransactionalProcessor: ProcessTransaction;
128
129 /// Allows optional logic execution for the `HrmpNewChannelOpenRequest` XCM notification.
130 type HrmpNewChannelOpenRequestHandler: HandleHrmpNewChannelOpenRequest;
131 /// Allows optional logic execution for the `HrmpChannelAccepted` XCM notification.
132 type HrmpChannelAcceptedHandler: HandleHrmpChannelAccepted;
133 /// Allows optional logic execution for the `HrmpChannelClosing` XCM notification.
134 type HrmpChannelClosingHandler: HandleHrmpChannelClosing;
135 /// Allows recording the last executed XCM (used by dry-run runtime APIs).
136 type XcmRecorder: RecordXcm;
137}