From 7126b6622e4c695be16322f24b6fe3d810887e91 Mon Sep 17 00:00:00 2001 From: imstar15 Date: Sat, 10 Jun 2023 00:29:22 +0800 Subject: [PATCH] Add Convert> to automationTime --- pallets/automation-time/src/fees.rs | 35 +++++++++++++++++++---------- pallets/automation-time/src/lib.rs | 2 +- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/pallets/automation-time/src/fees.rs b/pallets/automation-time/src/fees.rs index 8c300e1bb..f5f32cc4e 100644 --- a/pallets/automation-time/src/fees.rs +++ b/pallets/automation-time/src/fees.rs @@ -42,6 +42,7 @@ pub trait HandleFees { pub struct FeeHandler { owner: T::AccountId, pub currency_id: MultiCurrencyId, + pub xcmp_fee_currency_id: MultiCurrencyId, pub execution_fee: MultiBalanceOf, pub xcmp_fee: MultiBalanceOf, _phantom_data: PhantomData, @@ -73,20 +74,27 @@ where { /// Ensure the fee can be paid. fn can_pay_fee(&self) -> Result<(), DispatchError> { - let fee = self.execution_fee.saturating_add(self.xcmp_fee); + // let fee = self.execution_fee.saturating_add(self.xcmp_fee); - if fee.is_zero() { - return Ok(()) - } + // if fee.is_zero() { + // return Ok(()) + // } - // Manually check for ExistenceRequirement since MultiCurrency doesn't currently support it - let free_balance = T::MultiCurrency::free_balance(self.currency_id, &self.owner); - free_balance - .checked_sub(&fee) - .ok_or(DispatchError::Token(BelowMinimum))? - .checked_sub(&T::MultiCurrency::minimum_balance(self.currency_id)) - .ok_or(DispatchError::Token(BelowMinimum))?; - T::MultiCurrency::ensure_can_withdraw(self.currency_id.into(), &self.owner, fee)?; + // // Manually check for ExistenceRequirement since MultiCurrency doesn't currently support it + // let free_balance = T::MultiCurrency::free_balance(self.currency_id, &self.owner); + // free_balance + // .checked_sub(&fee) + // .ok_or(DispatchError::Token(BelowMinimum))? + // .checked_sub(&T::MultiCurrency::minimum_balance(self.currency_id)) + // .ok_or(DispatchError::Token(BelowMinimum))?; + // T::MultiCurrency::ensure_can_withdraw(self.currency_id.into(), &self.owner, fee)?; + // Ok(()) + + + + + + Ok(()) } @@ -145,9 +153,12 @@ where _ => 0u32.saturated_into(), }; + let xcmp_fee_currency_id: MultiCurrencyId = T::CurrencyIdConvert::convert(xcm_asset_location).ok_or("IncoveribleLocation")?; + Ok(Self { owner: owner.clone(), currency_id, + xcmp_fee_currency_id, execution_fee: execution_fee.saturated_into(), xcmp_fee, _phantom_data: Default::default(), diff --git a/pallets/automation-time/src/lib.rs b/pallets/automation-time/src/lib.rs index 5d30dd420..d3b14b7f6 100644 --- a/pallets/automation-time/src/lib.rs +++ b/pallets/automation-time/src/lib.rs @@ -158,7 +158,7 @@ pub mod pallet { type XcmpTransactor: XcmpTransactor; /// Converts CurrencyId to Multiloc - type CurrencyIdConvert: Convert>; + type CurrencyIdConvert: Convert> + Convert>; /// Converts between comparable currencies type FeeConversionRateProvider: FixedConversionRateProvider;