Skip to content

Commit

Permalink
Fix ensure_supported_execution_fee_location function
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Nov 10, 2023
1 parent 5f9d150 commit 2d8387c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
11 changes: 4 additions & 7 deletions pallets/automation-time/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ where

/// Withdraw the fee.
fn withdraw_fee(&self) -> Result<(), DispatchError> {
log::debug!(target: "FeeHandler", "FeeHandler::withdraw_fee, self.schedule_fee.asset_location: {:?}, self.schedule_fee.amount: {:?}",
self.schedule_fee.asset_location, self.schedule_fee.amount);
// Withdraw schedule fee
if !self.schedule_fee.amount.is_zero() {
let currency_id = T::CurrencyIdConvert::convert(self.schedule_fee.asset_location)
Expand All @@ -143,18 +145,13 @@ where
// Withdraw execution fee
if let Some(execution_fee) = &self.execution_fee {
if execution_fee.is_local {
log::debug!(target: "FeeHandler", "FeeHandler::withdraw_fee, self.execution_fee.asset_location: {:?}, self.execution_fee.amount: {:?}",
execution_fee.asset_location, execution_fee.amount);
let currency_id = T::CurrencyIdConvert::convert(execution_fee.asset_location)
.ok_or("InconvertibleMultilocation")?;

let execution_fee_amount = execution_fee.amount;
if !execution_fee_amount.is_zero() {
// T::MultiCurrency::withdraw(
// currency_id.into(),
// &self.owner,
// execution_fee_amount,
// )
// .map_err(|_| DispatchError::Token(BelowMinimum))?;

T::XcmpTransactor::pay_xcm_fee(
currency_id,
self.owner.clone(),
Expand Down
9 changes: 6 additions & 3 deletions pallets/automation-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ pub mod pallet {
/// The version of the `VersionedMultiLocation` value used is not able
/// to be interpreted.
BadVersion,
// The fee payment asset location is not supported.
UnsupportedFeePayment,
// Mulilocation cannot be reanchored.
CannotReanchor,
/// Invalid asset location.
InvalidAssetLocation,
Expand Down Expand Up @@ -1562,12 +1564,13 @@ pub mod pallet {
exeuction_fee_location: &MultiLocation,
destination: &MultiLocation,
) -> Result<(), DispatchError> {
if exeuction_fee_location.chain_part().is_none() {
let reserve = exeuction_fee_location.chain_part();
if reserve.is_none() {
return Err(Error::<T>::InvalidAssetLocation.into())
}

let reserve = reserve.unwrap();
let self_location = T::SelfLocation::get();
if exeuction_fee_location != &self_location && exeuction_fee_location != destination {
if reserve != self_location && &reserve != destination {
return Err(Error::<T>::UnsupportedFeePayment.into())
}

Expand Down
3 changes: 2 additions & 1 deletion pallets/xcmp-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use xcm::latest::prelude::*;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::traits::Currency;
use orml_traits::{location::Reserve, MultiCurrency};
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::{AccountIdConversion, Convert, SaturatedConversion};
Expand Down Expand Up @@ -167,7 +166,9 @@ pub mod pallet {
BadVersion,
// Asset not found
TransactInfoNotFound,
// Invalid asset location.
InvalidAssetLocation,
// The fee payment asset location is not supported.
UnsupportedFeePayment,
}

Expand Down

0 comments on commit 2d8387c

Please sign in to comment.