Trait pallet_asset_tx_payment::OnChargeAssetTransaction [−][src]
pub trait OnChargeAssetTransaction<T: Config> {
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + TypeInfo;
type AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo;
type LiquidityInfo;
fn withdraw_fee(
who: &T::AccountId,
call: &T::Call,
dispatch_info: &DispatchInfoOf<T::Call>,
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::Call>,
post_info: &PostDispatchInfoOf<T::Call>,
corrected_fee: Self::Balance,
tip: Self::Balance,
already_withdrawn: Self::LiquidityInfo
) -> Result<(), TransactionValidityError>;
}
Expand description
Handle withdrawing, refunding and depositing of transaction fees.
Associated Types
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + TypeInfo
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + TypeInfo
The underlying integer type in which fees are calculated.
The type used to identify the assets used for transaction payment.
type LiquidityInfo
type LiquidityInfo
The type used to store the intermediate values between pre- and post-dispatch.
Required methods
fn withdraw_fee(
who: &T::AccountId,
call: &T::Call,
dispatch_info: &DispatchInfoOf<T::Call>,
asset_id: Self::AssetId,
fee: Self::Balance,
tip: Self::Balance
) -> Result<Self::LiquidityInfo, TransactionValidityError>
fn withdraw_fee(
who: &T::AccountId,
call: &T::Call,
dispatch_info: &DispatchInfoOf<T::Call>,
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
.
fn correct_and_deposit_fee(
who: &T::AccountId,
dispatch_info: &DispatchInfoOf<T::Call>,
post_info: &PostDispatchInfoOf<T::Call>,
corrected_fee: Self::Balance,
tip: Self::Balance,
already_withdrawn: Self::LiquidityInfo
) -> Result<(), TransactionValidityError>
fn correct_and_deposit_fee(
who: &T::AccountId,
dispatch_info: &DispatchInfoOf<T::Call>,
post_info: &PostDispatchInfoOf<T::Call>,
corrected_fee: Self::Balance,
tip: Self::Balance,
already_withdrawn: 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
.
Implementors
impl<T, CON, HC> OnChargeAssetTransaction<T> for FungiblesAdapter<CON, HC> where
T: Config,
CON: BalanceConversion<<<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,
impl<T, CON, HC> OnChargeAssetTransaction<T> for FungiblesAdapter<CON, HC> where
T: Config,
CON: BalanceConversion<<<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.