yet_another_teyrchain_runtime/
xcm_config.rs1use super::{
18 AccountId, AllPalletsWithSystem, Balances, PezkuwiXcm, Runtime, RuntimeCall, RuntimeEvent,
19 RuntimeOrigin, TeyrchainInfo, TeyrchainSystem, WeightToFee, XcmpQueue,
20};
21
22use pezkuwi_sdk::{xcm, xcm_builder, xcm_executor, *};
23
24use pezframe_support::{
25 parameter_types,
26 traits::{ConstU32, Contains, Everything, Nothing},
27 weights::Weight,
28};
29use pezframe_system::EnsureRoot;
30use pezkuwi_runtime_common::impls::ToAuthor;
31use pezkuwi_teyrchain_primitives::primitives::Sibling;
32use pezpallet_xcm::XcmPassthrough;
33use xcm::latest::prelude::*;
34use xcm_builder::{
35 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
36 DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds,
37 FrameTransactionalProcessor, FungibleAdapter, IsConcrete, NativeAsset, ParentIsPreset,
38 RelayChainAsNative, SiblingTeyrchainAsNative, SiblingTeyrchainConvertsVia,
39 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
40 TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
41};
42use xcm_executor::XcmExecutor;
43
44parameter_types! {
45 pub const RelayLocation: Location = Location::parent();
46 pub const RelayNetwork: Option<NetworkId> = None;
47 pub RelayChainOrigin: RuntimeOrigin = pezcumulus_pezpallet_xcm::Origin::Relay.into();
48 pub UniversalLocation: InteriorLocation = Teyrchain(TeyrchainInfo::teyrchain_id().into()).into();
51}
52
53pub type LocationToAccountId = (
57 ParentIsPreset<AccountId>,
59 SiblingTeyrchainConvertsVia<Sibling, AccountId>,
61 AccountId32Aliases<RelayNetwork, AccountId>,
63);
64
65pub type LocalAssetTransactor = FungibleAdapter<
67 Balances,
69 IsConcrete<RelayLocation>,
71 LocationToAccountId,
73 AccountId,
75 (),
77>;
78
79pub type XcmOriginToTransactDispatchOrigin = (
83 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
87 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
90 SiblingTeyrchainAsNative<pezcumulus_pezpallet_xcm::Origin, RuntimeOrigin>,
93 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
96 XcmPassthrough<RuntimeOrigin>,
98);
99
100parameter_types! {
101 pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
103 pub const MaxInstructions: u32 = 100;
104 pub const MaxAssetsIntoHolding: u32 = 64;
105}
106
107pub struct ParentOrParentsExecutivePlurality;
108impl Contains<Location> for ParentOrParentsExecutivePlurality {
109 fn contains(location: &Location) -> bool {
110 matches!(location.unpack(), (1, []) | (1, [Plurality { id: BodyId::Executive, .. }]))
111 }
112}
113
114pub type Barrier = TrailingSetTopicAsId<
115 DenyThenTry<
116 DenyReserveTransferToRelayChain,
117 (
118 TakeWeightCredit,
119 WithComputedOrigin<
120 (
121 AllowTopLevelPaidExecutionFrom<Everything>,
122 AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
123 ),
125 UniversalLocation,
126 ConstU32<8>,
127 >,
128 ),
129 >,
130>;
131
132pub struct XcmConfig;
133impl xcm_executor::Config for XcmConfig {
134 type RuntimeCall = RuntimeCall;
135 type XcmSender = XcmRouter;
136 type XcmEventEmitter = PezkuwiXcm;
137 type AssetTransactor = LocalAssetTransactor;
139 type OriginConverter = XcmOriginToTransactDispatchOrigin;
140 type IsReserve = NativeAsset;
141 type IsTeleporter = (); type UniversalLocation = UniversalLocation;
143 type Barrier = Barrier;
144 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
145 type Trader =
146 UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToAuthor<Runtime>>;
147 type ResponseHandler = PezkuwiXcm;
148 type AssetTrap = PezkuwiXcm;
149 type AssetClaims = PezkuwiXcm;
150 type SubscriptionService = PezkuwiXcm;
151 type PalletInstancesInfo = AllPalletsWithSystem;
152 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
153 type AssetLocker = ();
154 type AssetExchanger = ();
155 type FeeManager = ();
156 type MessageExporter = ();
157 type UniversalAliases = Nothing;
158 type CallDispatcher = RuntimeCall;
159 type SafeCallFilter = Everything;
160 type Aliasers = Nothing;
161 type TransactionalProcessor = FrameTransactionalProcessor;
162 type HrmpNewChannelOpenRequestHandler = ();
163 type HrmpChannelAcceptedHandler = ();
164 type HrmpChannelClosingHandler = ();
165 type XcmRecorder = PezkuwiXcm;
166}
167
168pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
170
171pub type XcmRouter = WithUniqueTopic<(
174 pezcumulus_primitives_utility::ParentAsUmp<TeyrchainSystem, (), ()>,
176 XcmpQueue,
178)>;
179
180impl pezpallet_xcm::Config for Runtime {
181 type RuntimeEvent = RuntimeEvent;
182 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
183 type XcmRouter = XcmRouter;
184 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
185 type XcmExecuteFilter = Nothing;
186 type XcmExecutor = XcmExecutor<XcmConfig>;
189 type XcmTeleportFilter = Everything;
190 type XcmReserveTransferFilter = Nothing;
191 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
192 type UniversalLocation = UniversalLocation;
193 type RuntimeOrigin = RuntimeOrigin;
194 type RuntimeCall = RuntimeCall;
195
196 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
197 type AdvertisedXcmVersion = pezpallet_xcm::CurrentXcmVersion;
199 type Currency = Balances;
200 type CurrencyMatcher = ();
201 type TrustedLockers = ();
202 type SovereignAccountOf = LocationToAccountId;
203 type MaxLockers = ConstU32<8>;
204 type WeightInfo = pezpallet_xcm::TestWeightInfo;
205 type AdminOrigin = EnsureRoot<AccountId>;
206 type MaxRemoteLockConsumers = ConstU32<0>;
207 type RemoteLockConsumerIdentifier = ();
208 type AuthorizedAliasConsideration = ();
209}
210
211impl pezcumulus_pezpallet_xcm::Config for Runtime {
212 type RuntimeEvent = RuntimeEvent;
213 type XcmExecutor = XcmExecutor<XcmConfig>;
214}