Skip to content

Commit 23ef6f6

Browse files
authored
Merge pull request #188 from AbstractedCo/gabriel-asset_hub_reserve_dot
Add Asset Hub as reserve for DOT
2 parents 26790ab + c3d3f89 commit 23ef6f6

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

invarch/runtime/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
165165
spec_name: create_runtime_str!("invarch"),
166166
impl_name: create_runtime_str!("invarch"),
167167
authoring_version: 1,
168-
spec_version: 12,
168+
spec_version: 13,
169169
impl_version: 0,
170170
apis: RUNTIME_API_VERSIONS,
171171
transaction_version: 1,

invarch/runtime/src/xcm_config.rs

+33-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use codec::{Decode, Encode, MaxEncodedLen};
99
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
1010
use frame_support::{
1111
parameter_types,
12-
traits::{Everything, Nothing, TransformOrigin},
12+
traits::{ContainsPair, Everything, Get, Nothing, TransformOrigin},
1313
};
1414
use frame_system::EnsureRoot;
1515
use orml_traits2::{
@@ -31,7 +31,7 @@ use sp_runtime::{
3131
traits::{Convert, MaybeEquivalence},
3232
Perbill,
3333
};
34-
use sp_std::sync::Arc;
34+
use sp_std::{marker::PhantomData, sync::Arc};
3535
use xcm::{v3::MultiLocation, v4::prelude::*};
3636
use xcm_builder::{
3737
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
@@ -43,6 +43,8 @@ use xcm_builder::{
4343
};
4444
use xcm_executor::XcmExecutor;
4545

46+
const ASSET_HUB_PARA_ID: u32 = 1000;
47+
4648
parameter_types! {
4749
pub const RelayLocation: Location = Location::parent();
4850
pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
@@ -52,6 +54,8 @@ parameter_types! {
5254
pub const RelayAggregate: CustomAggregateMessageOrigin<AggregateMessageOrigin> = CustomAggregateMessageOrigin::Aggregate(AggregateMessageOrigin::Parent);
5355
pub SelfLocation: Location = Location::new(1, cumulus_primitives_core::Junctions::X1(Arc::new([Parachain(ParachainInfo::parachain_id().into());1])));
5456
pub LocalAssetLocation: Location = Location::new(0, Junctions::X1([Junction::GeneralIndex(VARCH_ASSET_ID.into())].into()));
57+
58+
pub AssetHubLocation: Location = (Parent, Parachain(ASSET_HUB_PARA_ID)).into();
5559
}
5660

5761
/// Type for specifying how a `Location` can be converted into an `AccountId`.
@@ -170,14 +174,40 @@ impl FixedConversionRateProvider for MyFixedConversionRateProvider {
170174
}
171175
}
172176

177+
pub struct IsDotFrom<Origin>(PhantomData<Origin>);
178+
impl<Origin> ContainsPair<Asset, Location> for IsDotFrom<Origin>
179+
where
180+
Origin: Get<Location>,
181+
{
182+
fn contains(asset: &Asset, origin: &Location) -> bool {
183+
let loc = Origin::get();
184+
&loc == origin
185+
&& matches!(
186+
asset,
187+
Asset {
188+
id: AssetId(Location {
189+
parents: 1,
190+
interior: Here
191+
}),
192+
fun: Fungible(_),
193+
},
194+
)
195+
}
196+
}
197+
198+
pub type Reserves = (
199+
IsDotFrom<AssetHubLocation>,
200+
MultiNativeAsset<AbsoluteReserveProvider>,
201+
);
202+
173203
pub struct XcmConfig;
174204
impl xcm_executor::Config for XcmConfig {
175205
type RuntimeCall = RuntimeCall;
176206
type XcmSender = XcmRouter;
177207
// How to withdraw and deposit an asset.
178208
type AssetTransactor = NewLocalAssetTransactor;
179209
type OriginConverter = XcmOriginToTransactDispatchOrigin;
180-
type IsReserve = MultiNativeAsset<AbsoluteReserveProvider>;
210+
type IsReserve = Reserves;
181211
type IsTeleporter = (); // Teleporting is disabled.
182212
type Barrier = Barrier;
183213
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
@@ -338,8 +368,6 @@ impl Convert<AccountId, Location> for AccountIdToMultiLocation {
338368
}
339369
}
340370

341-
const ASSET_HUB_PARA_ID: u32 = 1000;
342-
343371
parameter_type_with_key! {
344372
pub ParachainMinFee: |location: Location| -> Option<u128> {
345373
#[allow(clippy::match_ref_pats)] // false positive

0 commit comments

Comments
 (0)