Trait OnChargeEVMTransaction

Source
pub trait OnChargeEVMTransaction<T: Config> {
    type LiquidityInfo: Default;

    // Required methods
    fn withdraw_fee(
        who: &H160,
        fee: U256,
    ) -> Result<Self::LiquidityInfo, Error<T>>;
    fn correct_and_deposit_fee(
        who: &H160,
        corrected_fee: U256,
        base_fee: U256,
        already_withdrawn: Self::LiquidityInfo,
    ) -> Self::LiquidityInfo;
    fn pay_priority_fee(tip: Self::LiquidityInfo);
}
Expand description

Handle withdrawing, refunding and depositing of transaction fees. Similar to OnChargeTransaction of pallet_transaction_payment

Required Associated Types§

Required Methods§

Source

fn withdraw_fee(who: &H160, fee: U256) -> Result<Self::LiquidityInfo, Error<T>>

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

Source

fn correct_and_deposit_fee( who: &H160, corrected_fee: U256, base_fee: U256, already_withdrawn: Self::LiquidityInfo, ) -> Self::LiquidityInfo

After the transaction was executed the actual fee can be calculated. This function should refund any overpaid fees and optionally deposit the corrected amount, and handles the base fee rationing using the provided OnUnbalanced implementation. Returns the NegativeImbalance - if any - produced by the priority fee.

Source

fn pay_priority_fee(tip: Self::LiquidityInfo)

Introduced in EIP1559 to handle the priority tip.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> OnChargeEVMTransaction<T> for ()
where T: Config, T::Currency: Balanced<AccountIdOf<T>>, U256: UniqueSaturatedInto<<<T as Config>::Currency as Inspect<AccountIdOf<T>>>::Balance>,

Implementation for () does not specify what to do with imbalance

Source§

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

Source§

fn withdraw_fee(who: &H160, fee: U256) -> Result<Self::LiquidityInfo, Error<T>>

Source§

fn correct_and_deposit_fee( who: &H160, corrected_fee: U256, base_fee: U256, already_withdrawn: Self::LiquidityInfo, ) -> Self::LiquidityInfo

Source§

fn pay_priority_fee(tip: Self::LiquidityInfo)

Implementors§

Source§

impl<T, C, OU> OnChargeEVMTransaction<T> for EVMCurrencyAdapter<C, OU>
where T: Config, C: Currency<AccountIdOf<T>>, C::PositiveImbalance: Imbalance<<C as Currency<AccountIdOf<T>>>::Balance, Opposite = C::NegativeImbalance>, C::NegativeImbalance: Imbalance<<C as Currency<AccountIdOf<T>>>::Balance, Opposite = C::PositiveImbalance>, OU: OnUnbalanced<<C as Currency<AccountIdOf<T>>>::NegativeImbalance>, U256: UniqueSaturatedInto<<C as Currency<AccountIdOf<T>>>::Balance>,

Source§

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

Source§

impl<T, F, OU> OnChargeEVMTransaction<T> for EVMFungibleAdapter<F, OU>
where T: Config, F: Balanced<AccountIdOf<T>>, OU: OnUnbalanced<Credit<AccountIdOf<T>, F>>, U256: UniqueSaturatedInto<<F as Inspect<AccountIdOf<T>>>::Balance>,

Source§

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