@@ -353,7 +353,7 @@ pub mod pallet {
353353 ) ;
354354 if let Some ( multi) = location. clone ( ) . into ( ) {
355355 ensure ! (
356- Self :: is_allowed_location_shape ( & multi) ,
356+ Self :: is_allowed_asset_location ( & multi) ,
357357 Error :: <T >:: LocationNotSupported
358358 ) ;
359359 }
@@ -410,7 +410,7 @@ pub mod pallet {
410410 ) ;
411411 if let Some ( multi) = location. clone ( ) . into ( ) {
412412 ensure ! (
413- Self :: is_allowed_location_shape ( & multi) ,
413+ Self :: is_allowed_asset_location ( & multi) ,
414414 Error :: <T >:: LocationNotSupported
415415 ) ;
416416 }
@@ -620,47 +620,51 @@ pub mod pallet {
620620 }
621621
622622 /// 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 {
624624 let p = location. parents ;
625625 if p > 1 {
626626 return false ;
627627 }
628628 match location. interior {
629- // Local transfers or relay asset
629+ // Local or relay asset
630630 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 ,
633633 // 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 ,
640641 _ => false ,
641642 }
642643 }
643644 }
644645
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
646647 impl < T > Contains < MultiLocation > for Pallet < T >
647648 where
648649 T : Config ,
649650 {
650651 #[ inline]
651652 fn contains ( location : & MultiLocation ) -> bool {
652- if !Self :: is_allowed_location_shape ( location) {
653- return false ;
654- }
655653 // 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 {
657656 return false ;
658657 }
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 ,
664668 }
665669 }
666670 }
0 commit comments