pub trait OnChargeTransaction<T: Config>: TxCreditHold<T> {
type Balance: Balance;
type LiquidityInfo: Default;
// Required methods
fn withdraw_fee(
who: &T::AccountId,
call: &T::RuntimeCall,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
fee_with_tip: Self::Balance,
tip: Self::Balance,
) -> Result<Self::LiquidityInfo, TransactionValidityError>;
fn can_withdraw_fee(
who: &T::AccountId,
call: &T::RuntimeCall,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
fee_with_tip: Self::Balance,
tip: Self::Balance,
) -> Result<(), TransactionValidityError>;
fn correct_and_deposit_fee(
who: &T::AccountId,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
corrected_fee_with_tip: Self::Balance,
tip: Self::Balance,
liquidity_info: Self::LiquidityInfo,
) -> Result<(), TransactionValidityError>;
fn endow_account(who: &T::AccountId, amount: Self::Balance);
fn minimum_balance() -> Self::Balance;
}Expand description
Handle withdrawing, refunding and depositing of transaction fees.
Required Associated Types§
type LiquidityInfo: Default
Required Methods§
Sourcefn withdraw_fee(
who: &T::AccountId,
call: &T::RuntimeCall,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
fee_with_tip: Self::Balance,
tip: Self::Balance,
) -> Result<Self::LiquidityInfo, TransactionValidityError>
fn withdraw_fee( who: &T::AccountId, call: &T::RuntimeCall, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, fee_with_tip: Self::Balance, tip: Self::Balance, ) -> Result<Self::LiquidityInfo, TransactionValidityError>
Before the transaction is executed the payment of the transaction fees need to be secured.
Returns the tip credit
Sourcefn can_withdraw_fee(
who: &T::AccountId,
call: &T::RuntimeCall,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
fee_with_tip: Self::Balance,
tip: Self::Balance,
) -> Result<(), TransactionValidityError>
fn can_withdraw_fee( who: &T::AccountId, call: &T::RuntimeCall, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, fee_with_tip: Self::Balance, tip: Self::Balance, ) -> Result<(), TransactionValidityError>
Check if the predicted fee from the transaction origin can be withdrawn.
Sourcefn correct_and_deposit_fee(
who: &T::AccountId,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
corrected_fee_with_tip: Self::Balance,
tip: Self::Balance,
liquidity_info: Self::LiquidityInfo,
) -> Result<(), TransactionValidityError>
fn correct_and_deposit_fee( who: &T::AccountId, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, post_info: &PostDispatchInfoOf<T::RuntimeCall>, corrected_fee_with_tip: Self::Balance, tip: Self::Balance, liquidity_info: Self::LiquidityInfo, ) -> Result<(), 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.
fn endow_account(who: &T::AccountId, amount: Self::Balance)
fn minimum_balance() -> Self::Balance
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.