git.delta.rocks / unique-network / refs/commits / ecb82c0bbb4a

difftreelog

fix get rid of unneeded comments in xcm configs

Daniel Shiposha2022-09-05parent: #f8304b7.patch.diff
in: master

2 files changed

modifiedruntime/opal/src/xcm_config.rsdiffbeforeafterboth
65// Signed version of balance65// Signed version of balance
66pub type Amount = i128;66pub type Amount = i128;
67
68/*
69parameter_types! {
70 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
71 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
72}
73
74impl cumulus_pallet_parachain_system::Config for Runtime {
75 type Event = Event;
76 type SelfParaId = parachain_info::Pallet<Self>;
77 type OnSystemEvent = ();
78 type OutboundXcmpMessageSource = XcmpQueue;
79 type DmpMessageHandler = DmpQueue;
80 type ReservedDmpWeight = ReservedDmpWeight;
81 type ReservedXcmpWeight = ReservedXcmpWeight;
82 type XcmpMessageHandler = XcmpQueue;
83}
84
85impl parachain_info::Config for Runtime {}
86
87impl cumulus_pallet_aura_ext::Config for Runtime {}
88 */
8967
90parameter_types! {68parameter_types! {
91 pub const RelayLocation: MultiLocation = MultiLocation::parent();69 pub const RelayLocation: MultiLocation = MultiLocation::parent();
95 pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));73 pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));
96}74}
97
98/*
99/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
100/// when determining ownership of accounts for asset transacting and when attempting to use XCM
101/// `Transact` in order to determine the dispatch Origin.
102pub type LocationToAccountId = (
103 // The parent (Relay-chain) origin converts to the default `AccountId`.
104 ParentIsPreset<AccountId>,
105 // Sibling parachain origins convert to AccountId via the `ParaId::into`.
106 SiblingParachainConvertsVia<Sibling, AccountId>,
107 // Straight up local `AccountId32` origins just alias directly to `AccountId`.
108 AccountId32Aliases<RelayNetwork, AccountId>,
109);
110
111pub struct OnlySelfCurrency;
112
113impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
114 fn matches_fungible(a: &MultiAsset) -> Option<B> {
115 match (&a.id, &a.fun) {
116 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
117 _ => None,
118 }
119 }
120}
121
122/// Means for transacting assets on this chain.
123pub type LocalAssetTransactor = CurrencyAdapter<
124 // Use this currency:
125 Balances,
126 // Use this currency when it is a fungible asset matching the given location or name:
127 OnlySelfCurrency,
128 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
129 LocationToAccountId,
130 // Our chain's account ID type (we can't get away without mentioning it explicitly):
131 AccountId,
132 // We don't track any teleports.
133 (),
134>;
135
136 */
137
138/*
139parameter_types! {
140 pub CheckingAccount: AccountId = PolkadotXcm::check_account();
141}
142
143/// Allow checking in assets that have issuance > 0.
144pub struct NonZeroIssuance<AccountId, ForeingAssets>(PhantomData<(AccountId, ForeingAssets)>);
145impl<AccountId, ForeingAssets> Contains<<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId>
146 for NonZeroIssuance<AccountId, ForeingAssets>
147where
148 ForeingAssets: fungibles::Inspect<AccountId>,
149{
150 fn contains(id: &<ForeingAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
151 !ForeingAssets::total_issuance(*id).is_zero()
152 }
153}
154
155pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);
156impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>
157 ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>
158where
159 AssetId: Borrow<AssetId>,
160 AssetId: TryAsForeing<AssetId, ForeignAssetId>,
161 AssetIds: Borrow<AssetId>,
162{
163 fn convert_ref(id: impl Borrow<MultiLocation>) -> Result<AssetId, ()> {
164 let id = id.borrow();
165
166 log::trace!(
167 target: "xcm::AsInnerId::Convert",
168 "AsInnerId {:?}",
169 id
170 );
171
172 let parent = MultiLocation::parent();
173 let here = MultiLocation::here();
174 let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));
175
176 if *id == parent {
177 return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent));
178 }
179
180 if *id == here || *id == self_location {
181 return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here));
182 }
183
184 match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(id.clone()) {
185 Some(AssetIds::ForeignAssetId(foreign_asset_id)) => {
186 ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id))
187 }
188 _ => ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(0)),
189 }
190 }
191
192 fn reverse_ref(what: impl Borrow<AssetId>) -> Result<MultiLocation, ()> {
193 log::trace!(
194 target: "xcm::AsInnerId::Reverse",
195 "AsInnerId",
196 );
197
198 let asset_id = what.borrow();
199
200 let parent_id =
201 ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap();
202 let here_id =
203 ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap();
204
205 if asset_id.clone() == parent_id {
206 return Ok(MultiLocation::parent());
207 }
208
209 if asset_id.clone() == here_id {
210 return Ok(MultiLocation::new(
211 1,
212 X1(Parachain(ParachainInfo::get().into())),
213 ));
214 }
215
216 match <AssetId as TryAsForeing<AssetId, ForeignAssetId>>::try_as_foreing(asset_id.clone()) {
217 Some(fid) => match XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid) {
218 Some(location) => Ok(location),
219 None => Err(()),
220 },
221 None => Err(()),
222 }
223 }
224}
225
226/// Means for transacting assets besides the native currency on this chain.
227pub type FungiblesTransactor = FungiblesAdapter<
228 // Use this fungibles implementation:
229 ForeingAssets,
230 // Use this currency when it is a fungible asset matching the given location or name:
231 ConvertedConcreteAssetId<AssetIds, Balance, AsInnerId<AssetIds, JustTry>, JustTry>,
232 // Convert an XCM MultiLocation into a local account id:
233 LocationToAccountId,
234 // Our chain's account ID type (we can't get away without mentioning it explicitly):
235 AccountId,
236 // We only want to allow teleports of known assets. We use non-zero issuance as an indication
237 // that this asset is known.
238 NonZeroIssuance<AccountId, ForeingAssets>,
239 // The account to use for tracking teleports.
240 CheckingAccount,
241>;
242
243/// Means for transacting assets on this chain.
244pub type AssetTransactors = FungiblesTransactor;
245 */
24675
247/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,76/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
248/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can77/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
319 }148 }
320}149}
321
322/* /// CHANGEME!!!
323pub struct XcmConfig;
324impl Config for XcmConfig {
325 type Call = Call;
326 type XcmSender = XcmRouter;
327 // How to withdraw and deposit an asset.
328 type AssetTransactor = AssetTransactors;
329 type OriginConverter = XcmOriginToTransactDispatchOrigin;
330 type IsReserve = AllAsset; //NativeAsset;
331 type IsTeleporter = (); // Teleportation is disabled
332 type LocationInverter = LocationInverter<Ancestry>;
333 type Barrier = Barrier;
334 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
335 type Trader =
336 FreeForAll<LinearFee<Balance>, RelayLocation, AccountId, Balances, ()>;
337 type ResponseHandler = (); // Don't handle responses for now.
338 type SubscriptionService = PolkadotXcm;
339 type AssetTrap = PolkadotXcm;
340 type AssetClaims = PolkadotXcm;
341}
342 */
343
344/*
345/// No local origins on this chain are allowed to dispatch XCM sends/executions.
346pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);
347
348/// The means for routing XCM messages which are not for local execution into the right message
349/// queues.
350pub type XcmRouter = (
351 // Two routers - use UMP to communicate with the relay chain:
352 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
353 // ..and XCMP to communicate with the sibling chains.
354 XcmpQueue,
355);
356 */
357
358/*
359impl pallet_xcm::Config for Runtime {
360 type Event = Event;
361 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
362 type XcmRouter = XcmRouter;
363 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
364 type XcmExecuteFilter = Everything;
365 type XcmExecutor = XcmExecutor<XcmConfig<Self>>;
366 type XcmTeleportFilter = Everything;
367 type XcmReserveTransferFilter = Everything;
368 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
369 type LocationInverter = LocationInverter<Ancestry>;
370 type Origin = Origin;
371 type Call = Call;
372 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
373 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
374}
375 */
376
377/*
378impl cumulus_pallet_xcm::Config for Runtime {
379 type Event = Event;
380 type XcmExecutor = XcmExecutor<XcmConfig>;
381}
382
383impl cumulus_pallet_xcmp_queue::Config for Runtime {
384 type WeightInfo = ();
385 type Event = Event;
386 type XcmExecutor = XcmExecutor<XcmConfig>;
387 type ChannelInfo = ParachainSystem;
388 type VersionWrapper = ();
389 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
390 type ControllerOrigin = EnsureRoot<AccountId>;
391 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
392}
393
394impl cumulus_pallet_dmp_queue::Config for Runtime {
395 type Event = Event;
396 type XcmExecutor = XcmExecutor<XcmConfig>;
397 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
398}
399 */
400150
401pub struct CurrencyIdConvert;151pub struct CurrencyIdConvert;
402impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {152impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {
modifiedruntime/quartz/src/xcm_config.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_config.rs
+++ b/runtime/quartz/src/xcm_config.rs
@@ -175,7 +175,6 @@
     type ReserveProvider = AbsoluteReserveProvider;
 }
 
-
 parameter_type_with_key! {
 	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {
 		match currency_id {
@@ -194,7 +193,6 @@
         get_all_module_accounts().contains(a)
     }
 }
-
 
 pub struct CurrencyIdConvert;
 impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {
@@ -209,31 +207,6 @@
         }
     }
 }
-/*
-impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
-    fn convert(location: MultiLocation) -> Option<CurrencyId> {
-        if location == MultiLocation::here()
-            || location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))
-        {
-            return Some(AssetIds::NativeAssetId(NativeCurrency::Here));
-        }
-
-        if location == MultiLocation::parent() {
-            return Some(AssetIds::NativeAssetId(NativeCurrency::Parent));
-        }
-
-        if let Some(currency_id) =
-        XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location.clone())
-        {
-            return Some(currency_id);
-        }
-
-        None
-    }
-}
-
- */
-
 
 parameter_types! {
 	pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this