pub trait OnChargeTransaction<T: Config> {
    type Balance: Balance;
    type LiquidityInfo: Default;

    // Required methods
    fn withdraw_fee(
        who: &T::AccountId,
        call: &T::RuntimeCall,
        dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
        fee: Self::Balance,
        tip: Self::Balance
    ) -> Result<Self::LiquidityInfo, TransactionValidityError>;
    fn correct_and_deposit_fee(
        who: &T::AccountId,
        dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
        post_info: &PostDispatchInfoOf<T::RuntimeCall>,
        corrected_fee: Self::Balance,
        tip: Self::Balance,
        already_withdrawn: Self::LiquidityInfo
    ) -> Result<(), TransactionValidityError>;
}
Expand description

Handle withdrawing, refunding and depositing of transaction fees.

Required Associated Types§

source

type Balance: Balance

The underlying integer type in which fees are calculated.

source

type LiquidityInfo: Default

Required Methods§

source

fn withdraw_fee( who: &T::AccountId, call: &T::RuntimeCall, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, fee: Self::Balance, tip: Self::Balance ) -> Result<Self::LiquidityInfo, TransactionValidityError>

Before the transaction is executed the payment of the transaction fees need to be secured.

Note: The fee already includes the tip.

source

fn correct_and_deposit_fee( who: &T::AccountId, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, post_info: &PostDispatchInfoOf<T::RuntimeCall>, corrected_fee: Self::Balance, tip: Self::Balance, already_withdrawn: Self::LiquidityInfo ) -> Result<(), TransactionValidityError>

After the transaction was executed the actual fee can be calculated. This function should refund any overpaid fees and optionally deposit the corrected amount.

Note: The fee already includes the tip.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, C, OU> OnChargeTransaction<T> for CurrencyAdapter<C, OU>
where T: Config, C: Currency<<T as Config>::AccountId>, C::PositiveImbalance: Imbalance<<C as Currency<<T as Config>::AccountId>>::Balance, Opposite = C::NegativeImbalance>, C::NegativeImbalance: Imbalance<<C as Currency<<T as Config>::AccountId>>::Balance, Opposite = C::PositiveImbalance>, OU: OnUnbalanced<<C as Currency<<T as Config>::AccountId>>::NegativeImbalance>,

Default implementation for a Currency and an OnUnbalanced handler.

The unbalance handler is given 2 unbalanceds in [OnUnbalanced::on_unbalanceds]: fee and then tip.

§

type LiquidityInfo = Option<<C as Currency<<T as Config>::AccountId>>::NegativeImbalance>

§

type Balance = <C as Currency<<T as Config>::AccountId>>::Balance

source§

impl<T, F, OU> OnChargeTransaction<T> for FungibleAdapter<F, OU>
where T: Config, F: Balanced<T::AccountId>, OU: OnUnbalanced<Credit<T::AccountId, F>>,

§

type LiquidityInfo = Option<Imbalance<<F as Inspect<<T as Config>::AccountId>>::Balance, <F as Balanced<<T as Config>::AccountId>>::OnDropCredit, <F as Balanced<<T as Config>::AccountId>>::OnDropDebt>>

§

type Balance = <F as Inspect<<T as Config>::AccountId>>::Balance