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§
Sourcetype LiquidityInfo
type LiquidityInfo
The type used to store the intermediate values between pre- and post-dispatch.
Required Methods§
Sourcefn 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 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
.
Sourcefn can_withdraw_fee(
who: &T::AccountId,
asset_id: Self::AssetId,
fee: Self::Balance,
) -> Result<(), TransactionValidityError>
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.
Sourcefn 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>
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.