@@ -2,8 +2,8 @@ use super::{Amount, Balance, CurrencyId, CurrencyIdConvert, ParachainXcmRouter};
2
2
use crate as orml_xtokens;
3
3
4
4
use frame_support:: {
5
- construct_runtime, parameter_types,
6
- traits:: { Contains , Everything , Get , Nothing } ,
5
+ construct_runtime, match_type , parameter_types,
6
+ traits:: { Everything , Get , Nothing } ,
7
7
weights:: { constants:: WEIGHT_PER_SECOND , Weight } ,
8
8
} ;
9
9
use frame_system:: EnsureRoot ;
@@ -270,53 +270,17 @@ parameter_types! {
270
270
pub SelfLocation : MultiLocation = MultiLocation :: new( 1 , X1 ( Parachain ( ParachainInfo :: get( ) . into( ) ) ) ) ;
271
271
pub const BaseXcmWeight : Weight = 100_000_000 ;
272
272
pub const MaxAssetsForTransfer : usize = 3 ;
273
- pub SupportedMultiLocations : Vec <MultiLocation > = vec![
274
- MultiLocation :: new(
275
- 1 ,
276
- X1 ( Parachain ( 1 ) )
277
- ) ,
278
- MultiLocation :: new(
279
- 1 ,
280
- X1 ( Parachain ( 2 ) )
281
- ) ,
282
- MultiLocation :: new(
283
- 1 ,
284
- X1 ( Parachain ( 3 ) )
285
- ) ,
286
- // There's a test that uses para id = 100
287
- MultiLocation :: new(
288
- 1 ,
289
- X1 ( Parachain ( 100 ) )
290
- )
291
- ] ;
292
273
}
293
274
294
- pub struct WhiteListingMultiLocations ;
295
- impl Contains < MultiLocation > for WhiteListingMultiLocations {
296
- fn contains ( dest : & MultiLocation ) -> bool {
297
- // Consider children parachain, means parent = 0
298
- if dest. parent_count ( ) != 0 && dest. parent_count ( ) != 1 {
299
- return false ;
300
- }
301
-
302
- if let Junctions :: X1 ( Junction :: AccountId32 { .. } ) = dest. interior ( ) {
303
- // parent = 1 or 0, and the junctions is the variant X1
304
- // means the asset will be sent to relaychain.
305
- true
306
- } else {
307
- // if the asset is sent to parachain,
308
- // the junctions must have the variant Parachain
309
- dest. interior ( ) . iter ( ) . any ( |i| match i {
310
- Junction :: Parachain ( parachain_id) => SupportedMultiLocations :: get ( ) . iter ( ) . any ( |location| {
311
- location
312
- . interior
313
- . iter ( )
314
- . any ( |junc| * junc == Junction :: Parachain ( * parachain_id) )
315
- } ) ,
316
- _ => false , // No parachain id found.
317
- } )
318
- }
319
- }
275
+ match_type ! {
276
+ pub type ParentOrParachains : impl Contains <MultiLocation > = {
277
+ MultiLocation { parents: 0 , interior: X1 ( Junction :: AccountId32 { .. } ) } |
278
+ MultiLocation { parents: 1 , interior: X1 ( Junction :: AccountId32 { .. } ) } |
279
+ MultiLocation { parents: 1 , interior: X2 ( Parachain ( 1 ) , Junction :: AccountId32 { .. } ) } |
280
+ MultiLocation { parents: 1 , interior: X2 ( Parachain ( 2 ) , Junction :: AccountId32 { .. } ) } |
281
+ MultiLocation { parents: 1 , interior: X2 ( Parachain ( 3 ) , Junction :: AccountId32 { .. } ) } |
282
+ MultiLocation { parents: 1 , interior: X2 ( Parachain ( 100 ) , Junction :: AccountId32 { .. } ) }
283
+ } ;
320
284
}
321
285
322
286
parameter_type_with_key ! {
@@ -336,7 +300,7 @@ impl orml_xtokens::Config for Runtime {
336
300
type CurrencyIdConvert = CurrencyIdConvert ;
337
301
type AccountIdToMultiLocation = AccountIdToMultiLocation ;
338
302
type SelfLocation = SelfLocation ;
339
- type MultiLocationsFilter = WhiteListingMultiLocations ;
303
+ type MultiLocationsFilter = ParentOrParachains ;
340
304
type MinXcmFee = ParachainMinFee ;
341
305
type XcmExecutor = XcmExecutor < XcmConfig > ;
342
306
type Weigher = FixedWeightBounds < UnitWeightCost , Call , MaxInstructions > ;
0 commit comments