@@ -353,7 +353,7 @@ pub mod pallet {
353
353
) ;
354
354
if let Some ( multi) = location. clone ( ) . into ( ) {
355
355
ensure ! (
356
- Self :: is_allowed_location_shape ( & multi) ,
356
+ Self :: is_allowed_asset_location ( & multi) ,
357
357
Error :: <T >:: LocationNotSupported
358
358
) ;
359
359
}
@@ -410,7 +410,7 @@ pub mod pallet {
410
410
) ;
411
411
if let Some ( multi) = location. clone ( ) . into ( ) {
412
412
ensure ! (
413
- Self :: is_allowed_location_shape ( & multi) ,
413
+ Self :: is_allowed_asset_location ( & multi) ,
414
414
Error :: <T >:: LocationNotSupported
415
415
) ;
416
416
}
@@ -620,47 +620,51 @@ pub mod pallet {
620
620
}
621
621
622
622
/// defines what types of locations can be registered as assets
623
- fn is_allowed_location_shape ( location : & MultiLocation ) -> bool {
623
+ fn is_allowed_asset_location ( location : & MultiLocation ) -> bool {
624
624
let p = location. parents ;
625
625
if p > 1 {
626
626
return false ;
627
627
}
628
628
match location. interior {
629
- // Local transfers or relay asset
629
+ // Local or relay asset
630
630
Junctions :: Here => p == 0 || p == 1 ,
631
- // Send tokens to relaychain.
632
- Junctions :: X1 ( Junction :: AccountId32 { .. } ) => p == 1 ,
631
+ // A parachain native asset
632
+ Junctions :: X1 ( Junction :: Parachain { .. } ) => p == 1 ,
633
633
// Send tokens to sibling chain.
634
- Junctions :: X2 ( Junction :: Parachain { .. } , Junction :: AccountId32 { .. } )
635
- | Junctions :: X2 ( Junction :: Parachain { .. } , Junction :: PalletInstance { .. } )
636
- | Junctions :: X2 ( Junction :: Parachain { .. } , Junction :: AccountKey20 { .. } ) => {
637
- p == 1
638
- }
639
- // We don't support X3 or longer Junctions.
634
+ Junctions :: X2 ( Junction :: Parachain { .. } , Junction :: PalletInstance { .. } )
635
+ | Junctions :: X2 ( Junction :: Parachain { .. } , Junction :: GeneralKey { .. } ) => p == 1 ,
636
+ Junctions :: X3 (
637
+ Junction :: Parachain { .. } ,
638
+ Junction :: PalletInstance { .. } ,
639
+ Junction :: GeneralIndex { .. } ,
640
+ ) => p == 1 ,
640
641
_ => false ,
641
642
}
642
643
}
643
644
}
644
645
645
- /// impl used by xtokens as `MultiLocationsFilter`. Defines where we're allowed to send to
646
+ /// impl used by xtokens as `MultiLocationsFilter`. Defines where we're allowed to ** send** to
646
647
impl < T > Contains < MultiLocation > for Pallet < T >
647
648
where
648
649
T : Config ,
649
650
{
650
651
#[ inline]
651
652
fn contains ( location : & MultiLocation ) -> bool {
652
- if !Self :: is_allowed_location_shape ( location) {
653
- return false ;
654
- }
655
653
// xtokens / XCM must not be used to send transfers local to our parachain
656
- if location. parents == 0 {
654
+ // and we don't support nested chains
655
+ if location. parents != 1 {
657
656
return false ;
658
657
}
659
- // if sending to sibling, only siblings whose assets we registered are allowed
660
- if let Junctions :: X2 ( Junction :: Parachain ( para_id) , _) = location. interior {
661
- AllowedDestParaIds :: < T > :: contains_key ( para_id)
662
- } else {
663
- true
658
+ match location. interior {
659
+ // Send tokens to an account on the relaychain.
660
+ Junctions :: X1 ( Junction :: AccountId32 { .. } ) => true ,
661
+ // Send tokens to an account on a sibling chain.
662
+ Junctions :: X2 ( Junction :: Parachain ( para_id) , Junction :: AccountId32 { .. } )
663
+ | Junctions :: X2 ( Junction :: Parachain ( para_id) , Junction :: AccountKey20 { .. } ) => {
664
+ AllowedDestParaIds :: < T > :: contains_key ( para_id)
665
+ }
666
+ // We don't support X3 or longer Junctions.
667
+ _ => false ,
664
668
}
665
669
}
666
670
}
0 commit comments