referrerpolicy=no-referrer-when-downgrade
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<Self::LiquidityInfo, TransactionValidityError>;
    fn can_withdraw_fee(
        who: &T::AccountId,
        asset_id: Self::AssetId,
        fee: Self::Balance,
    ) -> Result<(), 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,
        asset_id: Self::AssetId,
        already_withdraw: Self::LiquidityInfo,
    ) -> Result<<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::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<Self::LiquidityInfo, TransactionValidityError>

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

Note: The fee already includes the tip.

source

fn can_withdraw_fee( who: &T::AccountId, asset_id: Self::AssetId, fee: Self::Balance, ) -> Result<(), TransactionValidityError>

Ensure payment of the transaction fees can be withdrawn.

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, asset_id: Self::AssetId, already_withdraw: Self::LiquidityInfo, ) -> Result<<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::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 amount of asset_id that was used for the payment.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<A, F, S, OU, T> OnChargeAssetTransaction<T> for SwapAssetAdapter<A, F, S, OU>
where A: Get<T::AssetId>, F: Balanced<T::AccountId, Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, AssetId = T::AssetId>, S: SwapCredit<T::AccountId, Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, AssetKind = T::AssetId, Credit = Credit<T::AccountId, F>> + QuotePrice<Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, AssetKind = T::AssetId>, OU: OnUnbalanced<Credit<T::AccountId, F>>, T: Config,

§

type AssetId = <T as Config>::AssetId

§

type Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance

§

type LiquidityInfo = (Imbalance<<F as Inspect<<T as Config>::AccountId>>::AssetId, <F as Inspect<<T as Config>::AccountId>>::Balance, <F as Balanced<<T as Config>::AccountId>>::OnDropCredit, <F as Balanced<<T as Config>::AccountId>>::OnDropDebt>, <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance)