@@ -144,7 +144,8 @@ pub mod module {
144
144
type CurrencyId : Parameter + Member + Clone ;
145
145
146
146
/// Convert `T::CurrencyId` to `Location`.
147
- type CurrencyIdConvert : Convert < Self :: CurrencyId , Option < Location > > ;
147
+ type CurrencyIdConvert : Convert < Self :: CurrencyId , Option < Location > >
148
+ + Convert < Location , Option < Self :: CurrencyId > > ;
148
149
149
150
/// Convert `T::AccountId` to `Location`.
150
151
type AccountIdToLocation : Convert < Self :: AccountId , Location > ;
@@ -468,25 +469,27 @@ pub mod module {
468
469
for i in 0 ..asset_len {
469
470
let asset = assets. get ( i) . ok_or ( Error :: < T > :: AssetIndexNonExistent ) ?;
470
471
471
- // per asset check
472
- let amount = match asset. fun {
473
- Fungibility :: Fungible ( amount) => amount,
474
- Fungibility :: NonFungible ( _) => 1 ,
475
- } ;
476
-
477
- // try consume quota of the rate limiter.
478
- // NOTE: use AssetId as the key, use AccountId as whitelist filter key.
479
- match T :: RateLimiter :: try_consume ( rate_limiter_id, asset. id . clone ( ) , amount, Some ( who) ) {
480
- Ok ( _) => { }
481
- Err ( _e @ RateLimiterError :: Deny ) => {
482
- return Err ( Error :: < T > :: RateLimiterDeny . into ( ) ) ;
483
- }
484
- Err ( ref _e @ RateLimiterError :: Delay { duration } ) => {
485
- if duration > need_delay. unwrap_or_default ( ) {
486
- need_delay = Some ( duration) ;
472
+ if let Some ( currency_id) = T :: CurrencyIdConvert :: convert ( asset. id . 0 . clone ( ) ) {
473
+ // per asset check
474
+ let amount = match asset. fun {
475
+ Fungibility :: Fungible ( amount) => amount,
476
+ Fungibility :: NonFungible ( _) => 1 ,
477
+ } ;
478
+
479
+ // try consume quota of the rate limiter.
480
+ // NOTE: use CurrencyId as the key, use AccountId as whitelist filter key.
481
+ match T :: RateLimiter :: try_consume ( rate_limiter_id, currency_id, amount, Some ( who) ) {
482
+ Ok ( _) => { }
483
+ Err ( _e @ RateLimiterError :: Deny ) => {
484
+ return Err ( Error :: < T > :: RateLimiterDeny . into ( ) ) ;
487
485
}
488
- }
489
- } ;
486
+ Err ( ref _e @ RateLimiterError :: Delay { duration } ) => {
487
+ if duration > need_delay. unwrap_or_default ( ) {
488
+ need_delay = Some ( duration) ;
489
+ }
490
+ }
491
+ } ;
492
+ }
490
493
}
491
494
492
495
Ok ( need_delay)
0 commit comments