referrerpolicy=no-referrer-when-downgrade
pallet_asset_conversion_tx_payment

Trait OnChargeAssetTransaction

Source
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.

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.

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,

Source§

type AssetId = <T as Config>::AssetId

Source§

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

Source§

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)