Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
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>>;
Comment thread
ghzlatarev marked this conversation as resolved.

/// 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
MinXcmFeeNotDefined,
}

#[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>::MinXcmFeeNotDefined)?;

// min xcm fee should less than user fee
let fee_to_dest: MultiAsset = (fee.id.clone(), min_xcm_fee).into();
Expand Down
6 changes: 3 additions & 3 deletions xtokens/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ match_types! {
}

parameter_type_with_key! {
pub ParachainMinFee: |location: MultiLocation| -> u128 {
pub ParachainMinFee: |location: MultiLocation| -> Option<u128> {
#[allow(clippy::match_ref_pats)] // false positive
match (location.parents, location.first_interior()) {
(1, Some(Parachain(2))) => 40,
_ => u128::MAX,
(1, Some(Parachain(2))) => Some(40),
_ => None,
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions xtokens/src/mock/para_relative_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ match_types! {
}

parameter_type_with_key! {
pub ParachainMinFee: |location: MultiLocation| -> u128 {
pub ParachainMinFee: |location: MultiLocation| -> Option<u128> {
#[allow(clippy::match_ref_pats)] // false positive
match (location.parents, location.first_interior()) {
(1, Some(Parachain(2))) => 40,
_ => u128::MAX,
(1, Some(Parachain(2))) => Some(40),
_ => None,
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion xtokens/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ fn transfer_asset_with_relay_fee_failed() {
),
40,
),
Error::<para::Runtime>::FeeNotEnough
Error::<para::Runtime>::MinXcmFeeNotDefined
);
});
}
Expand Down