From 8806c418b263273637100888b02a01ea595dd838 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Tue, 22 Aug 2023 08:32:27 +0300 Subject: [PATCH 1/2] Move native-barrier traits to own file Signed-off-by: Georgi Zlatarev --- traits/src/lib.rs | 1 + traits/src/native_barrier.rs | 8 ++++++++ traits/src/xcm_transfer.rs | 8 -------- xtokens/src/lib.rs | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 traits/src/native_barrier.rs diff --git a/traits/src/lib.rs b/traits/src/lib.rs index ea5231dd9..1e24f08db 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -38,6 +38,7 @@ pub mod nft; pub mod price; pub mod rewards; pub mod xcm_transfer; +pub mod native_barrier; /// New data handler #[impl_trait_for_tuples::impl_for_tuples(30)] diff --git a/traits/src/native_barrier.rs b/traits/src/native_barrier.rs new file mode 100644 index 000000000..19212f07f --- /dev/null +++ b/traits/src/native_barrier.rs @@ -0,0 +1,8 @@ +use frame_support::dispatch::DispatchResult; +pub trait NativeBarrier { + fn update_native_barrier(account_id: &AccountId, amount: Balance); + fn ensure_limit_not_exceeded(account_id: &AccountId, amount: Balance) -> DispatchResult; +} +pub trait NativeChecker { + fn is_native(currency_id: &CurrencyId) -> bool; +} diff --git a/traits/src/xcm_transfer.rs b/traits/src/xcm_transfer.rs index 85abf4cc8..e094c4b60 100644 --- a/traits/src/xcm_transfer.rs +++ b/traits/src/xcm_transfer.rs @@ -30,11 +30,3 @@ pub trait XcmTransfer { ) -> DispatchResult; } -pub trait NativeBarrier { - fn update_xcm_native_transfers(account_id: &AccountId, amount: Balance); - fn ensure_xcm_transfer_limit_not_exceeded(account_id: &AccountId, amount: Balance) -> DispatchResult; -} - -pub trait NativeChecker { - fn is_native(currency_id: &CurrencyId) -> bool; -} diff --git a/xtokens/src/lib.rs b/xtokens/src/lib.rs index 2d74cd62b..2df3718e1 100644 --- a/xtokens/src/lib.rs +++ b/xtokens/src/lib.rs @@ -44,7 +44,7 @@ use xcm_executor::traits::{InvertLocation, WeightBounds}; pub use module::*; use orml_traits::{ location::{Parse, Reserve}, - xcm_transfer::{NativeBarrier, NativeChecker}, + native_barrier::{NativeBarrier, NativeChecker}, GetByKey, XcmTransfer, }; @@ -402,7 +402,7 @@ pub mod module { ); if ::is_native(¤cy_id) { - ::ensure_xcm_transfer_limit_not_exceeded(&who, amount)?; + ::ensure_limit_not_exceeded(&who, amount)?; } let location: MultiLocation = @@ -432,7 +432,7 @@ pub mod module { ); if ::is_native(¤cy_id) { - ::ensure_xcm_transfer_limit_not_exceeded(&who, amount)?; + ::ensure_limit_not_exceeded(&who, amount)?; } let location: MultiLocation = @@ -516,7 +516,7 @@ pub mod module { ); if ::is_native(¤cy_id) { - ::ensure_xcm_transfer_limit_not_exceeded(&who, *amount)?; + ::ensure_limit_not_exceeded(&who, *amount)?; } let location: MultiLocation = T::CurrencyIdConvert::convert(currency_id.clone()) From 00e9590afdefe603dc2ba2757316759622122096 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Thu, 31 Aug 2023 08:58:47 +0300 Subject: [PATCH 2/2] Fix xtokens commit Signed-off-by: Georgi Zlatarev --- xtokens/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xtokens/src/lib.rs b/xtokens/src/lib.rs index 08bbc4e84..8c57c26ee 100644 --- a/xtokens/src/lib.rs +++ b/xtokens/src/lib.rs @@ -103,6 +103,9 @@ pub mod module { /// Asset locations filter for outgoing transfers type OutgoingAssetsFilter: Contains; + /// + type NativeBarrierType: NativeBarrier + NativeChecker; + /// Means of measuring the weight consumed by an XCM message locally. type Weigher: WeightBounds; @@ -401,7 +404,6 @@ pub mod module { if ::is_native(¤cy_id) { ::ensure_limit_not_exceeded(&who, amount)?; } - let location: MultiLocation = T::CurrencyIdConvert::convert(currency_id).ok_or(Error::::NotCrossChainTransferableCurrency)?;