pub trait OnChargeAssetTransaction<T: Config> {
    type Balance: Balance;
    type AssetId: AssetId;
    type LiquidityInfo;

    // Required methods
    fn withdraw_fee(
        who: &T::AccountId,
        call: &T::RuntimeCall,
        dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
        asset_id: Self::AssetId,
        fee: Self::Balance,
        tip: Self::Balance
    ) -> Result<(<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, Self::LiquidityInfo, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance), 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,
        fee_paid: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo,
        received_exchanged: Self::LiquidityInfo,
        asset_id: Self::AssetId,
        initial_asset_consumed: <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance
    ) -> Result<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance, 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 AssetId: AssetId

The type used to identify the assets used for transaction payment.

source

type LiquidityInfo

The type used to store the intermediate values between pre- and post-dispatch.

Required Methods§

source

fn withdraw_fee( who: &T::AccountId, call: &T::RuntimeCall, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, asset_id: Self::AssetId, fee: Self::Balance, tip: Self::Balance ) -> Result<(<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, Self::LiquidityInfo, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance), TransactionValidityError>

Secure the payment of the transaction fees before the transaction is executed.

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, fee_paid: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, received_exchanged: Self::LiquidityInfo, asset_id: Self::AssetId, initial_asset_consumed: <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance ) -> Result<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance, TransactionValidityError>

Refund any overpaid fees and deposit the corrected amount. The actual fee gets calculated once the transaction is executed.

Note: The fee already includes the tip.

Returns the fee and tip in the asset used for payment as (fee, tip).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, C, CON, N> OnChargeAssetTransaction<T> for AssetConversionAdapter<C, CON, N>
where N: Get<CON::AssetKind>, T: Config, C: Inspect<<T as Config>::AccountId>, CON: Swap<T::AccountId, Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, AssetKind = T::AssetKind>, <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Into<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance> + IsType<<C as Inspect<<T as Config>::AccountId>>::Balance>, T::AssetKind: From<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId>,

Default implementation for a runtime instantiating this pallet, an asset to native swapper.