diff --git a/invarch/runtime/src/lib.rs b/invarch/runtime/src/lib.rs index 50eae79..9b240b2 100644 --- a/invarch/runtime/src/lib.rs +++ b/invarch/runtime/src/lib.rs @@ -165,7 +165,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("invarch"), impl_name: create_runtime_str!("invarch"), authoring_version: 1, - spec_version: 12, + spec_version: 13, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/invarch/runtime/src/xcm_config.rs b/invarch/runtime/src/xcm_config.rs index 52bceed..338aecc 100644 --- a/invarch/runtime/src/xcm_config.rs +++ b/invarch/runtime/src/xcm_config.rs @@ -9,7 +9,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ parameter_types, - traits::{Everything, Nothing, TransformOrigin}, + traits::{ContainsPair, Everything, Get, Nothing, TransformOrigin}, }; use frame_system::EnsureRoot; use orml_traits2::{ @@ -31,7 +31,7 @@ use sp_runtime::{ traits::{Convert, MaybeEquivalence}, Perbill, }; -use sp_std::sync::Arc; +use sp_std::{marker::PhantomData, sync::Arc}; use xcm::{v3::MultiLocation, v4::prelude::*}; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, @@ -43,6 +43,8 @@ use xcm_builder::{ }; use xcm_executor::XcmExecutor; +const ASSET_HUB_PARA_ID: u32 = 1000; + parameter_types! { pub const RelayLocation: Location = Location::parent(); pub const RelayNetwork: NetworkId = NetworkId::Polkadot; @@ -52,6 +54,8 @@ parameter_types! { pub const RelayAggregate: CustomAggregateMessageOrigin = CustomAggregateMessageOrigin::Aggregate(AggregateMessageOrigin::Parent); pub SelfLocation: Location = Location::new(1, cumulus_primitives_core::Junctions::X1(Arc::new([Parachain(ParachainInfo::parachain_id().into());1]))); pub LocalAssetLocation: Location = Location::new(0, Junctions::X1([Junction::GeneralIndex(VARCH_ASSET_ID.into())].into())); + + pub AssetHubLocation: Location = (Parent, Parachain(ASSET_HUB_PARA_ID)).into(); } /// Type for specifying how a `Location` can be converted into an `AccountId`. @@ -170,6 +174,32 @@ impl FixedConversionRateProvider for MyFixedConversionRateProvider { } } +pub struct IsDotFrom(PhantomData); +impl ContainsPair for IsDotFrom +where + Origin: Get, +{ + fn contains(asset: &Asset, origin: &Location) -> bool { + let loc = Origin::get(); + &loc == origin + && matches!( + asset, + Asset { + id: AssetId(Location { + parents: 1, + interior: Here + }), + fun: Fungible(_), + }, + ) + } +} + +pub type Reserves = ( + IsDotFrom, + MultiNativeAsset, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -177,7 +207,7 @@ impl xcm_executor::Config for XcmConfig { // How to withdraw and deposit an asset. type AssetTransactor = NewLocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = MultiNativeAsset; + type IsReserve = Reserves; type IsTeleporter = (); // Teleporting is disabled. type Barrier = Barrier; type Weigher = FixedWeightBounds; @@ -338,8 +368,6 @@ impl Convert for AccountIdToMultiLocation { } } -const ASSET_HUB_PARA_ID: u32 = 1000; - parameter_type_with_key! { pub ParachainMinFee: |location: Location| -> Option { #[allow(clippy::match_ref_pats)] // false positive