@@ -9,7 +9,7 @@ use codec::{Decode, Encode, MaxEncodedLen};
99use cumulus_primitives_core:: { AggregateMessageOrigin , ParaId } ;
1010use frame_support:: {
1111 parameter_types,
12- traits:: { Everything , Nothing , TransformOrigin } ,
12+ traits:: { ContainsPair , Everything , Get , Nothing , TransformOrigin } ,
1313} ;
1414use frame_system:: EnsureRoot ;
1515use 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 } ;
3535use xcm:: { v3:: MultiLocation , v4:: prelude:: * } ;
3636use xcm_builder:: {
3737 AccountId32Aliases , AllowKnownQueryResponses , AllowSubscriptionsFrom ,
@@ -43,6 +43,8 @@ use xcm_builder::{
4343} ;
4444use xcm_executor:: XcmExecutor ;
4545
46+ const ASSET_HUB_PARA_ID : u32 = 1000 ;
47+
4648parameter_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+
173203pub struct XcmConfig ;
174204impl 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-
343371parameter_type_with_key ! {
344372 pub ParachainMinFee : |location: Location | -> Option <u128 > {
345373 #[ allow( clippy:: match_ref_pats) ] // false positive
0 commit comments