@@ -9,7 +9,7 @@ use codec::{Decode, Encode, MaxEncodedLen};
9
9
use cumulus_primitives_core:: { AggregateMessageOrigin , ParaId } ;
10
10
use frame_support:: {
11
11
parameter_types,
12
- traits:: { Everything , Nothing , TransformOrigin } ,
12
+ traits:: { ContainsPair , Everything , Get , Nothing , TransformOrigin } ,
13
13
} ;
14
14
use frame_system:: EnsureRoot ;
15
15
use orml_traits2:: {
@@ -31,7 +31,7 @@ use sp_runtime::{
31
31
traits:: { Convert , MaybeEquivalence } ,
32
32
Perbill ,
33
33
} ;
34
- use sp_std:: sync:: Arc ;
34
+ use sp_std:: { marker :: PhantomData , sync:: Arc } ;
35
35
use xcm:: { v3:: MultiLocation , v4:: prelude:: * } ;
36
36
use xcm_builder:: {
37
37
AccountId32Aliases , AllowKnownQueryResponses , AllowSubscriptionsFrom ,
@@ -43,6 +43,8 @@ use xcm_builder::{
43
43
} ;
44
44
use xcm_executor:: XcmExecutor ;
45
45
46
+ const ASSET_HUB_PARA_ID : u32 = 1000 ;
47
+
46
48
parameter_types ! {
47
49
pub const RelayLocation : Location = Location :: parent( ) ;
48
50
pub const RelayNetwork : NetworkId = NetworkId :: Polkadot ;
@@ -52,6 +54,8 @@ parameter_types! {
52
54
pub const RelayAggregate : CustomAggregateMessageOrigin <AggregateMessageOrigin > = CustomAggregateMessageOrigin :: Aggregate ( AggregateMessageOrigin :: Parent ) ;
53
55
pub SelfLocation : Location = Location :: new( 1 , cumulus_primitives_core:: Junctions :: X1 ( Arc :: new( [ Parachain ( ParachainInfo :: parachain_id( ) . into( ) ) ; 1 ] ) ) ) ;
54
56
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( ) ;
55
59
}
56
60
57
61
/// Type for specifying how a `Location` can be converted into an `AccountId`.
@@ -170,14 +174,40 @@ impl FixedConversionRateProvider for MyFixedConversionRateProvider {
170
174
}
171
175
}
172
176
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
+
173
203
pub struct XcmConfig ;
174
204
impl xcm_executor:: Config for XcmConfig {
175
205
type RuntimeCall = RuntimeCall ;
176
206
type XcmSender = XcmRouter ;
177
207
// How to withdraw and deposit an asset.
178
208
type AssetTransactor = NewLocalAssetTransactor ;
179
209
type OriginConverter = XcmOriginToTransactDispatchOrigin ;
180
- type IsReserve = MultiNativeAsset < AbsoluteReserveProvider > ;
210
+ type IsReserve = Reserves ;
181
211
type IsTeleporter = ( ) ; // Teleporting is disabled.
182
212
type Barrier = Barrier ;
183
213
type Weigher = FixedWeightBounds < BaseXcmWeight , RuntimeCall , MaxInstructions > ;
@@ -338,8 +368,6 @@ impl Convert<AccountId, Location> for AccountIdToMultiLocation {
338
368
}
339
369
}
340
370
341
- const ASSET_HUB_PARA_ID : u32 = 1000 ;
342
-
343
371
parameter_type_with_key ! {
344
372
pub ParachainMinFee : |location: Location | -> Option <u128 > {
345
373
#[ allow( clippy:: match_ref_pats) ] // false positive
0 commit comments