pub trait OnChargeAssetTransaction<T: Config> {
    type Balance: Balance;
    type AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo;
    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 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<(<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance, <<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: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo

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>

Before the transaction is executed the payment of the transaction fees needs 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<(<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance), 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.

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

Implementors§

source§

impl<T, CON, HC> OnChargeAssetTransaction<T> for FungiblesAdapter<CON, HC>where T: Config, CON: ConversionToAssetBalance<<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance>, HC: HandleCredit<T::AccountId, T::Fungibles>, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo,

Default implementation for a runtime instantiating this pallet, a balance to asset converter and a credit handler.

§

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

§

type AssetId = <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId

§

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