Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make xcm min fee return option
Signed-off-by: Georgi Zlatarev <[email protected]>
  • Loading branch information
ghzlatarev committed May 26, 2022
commit 92e83dcbeda0cd690ac6e8c151efc77911c6cd2d
6 changes: 4 additions & 2 deletions xtokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub mod module {
type SelfLocation: Get<MultiLocation>;

/// Minimum xcm execution fee paid on destination chain.
type MinXcmFee: GetByKey<MultiLocation, u128>;
type MinXcmFee: GetByKey<MultiLocation, Option<u128>>;

/// XCM executor.
type XcmExecutor: ExecuteXcm<Self::Call>;
Expand Down Expand Up @@ -173,6 +173,8 @@ pub mod module {
FeeNotEnough,
/// Not supported MultiLocation
NotSupportedMultiLocation,
/// MinXcmFee not registered for certain reserve location
MinXcmFeeNotRegistered,
}

#[pallet::hooks]
Expand Down Expand Up @@ -538,7 +540,7 @@ pub mod module {
ensure!(non_fee_reserve == dest.chain_part(), Error::<T>::InvalidAsset);

let reserve_location = non_fee_reserve.clone().ok_or(Error::<T>::AssetHasNoReserve)?;
let min_xcm_fee = T::MinXcmFee::get(&reserve_location);
let min_xcm_fee = T::MinXcmFee::get(&reserve_location).ok_or(Error::<T>::MinXcmFeeNotRegistered)?;

// min xcm fee should less than user fee
let fee_to_dest: MultiAsset = (fee.id.clone(), min_xcm_fee).into();
Expand Down