pub trait ApplyCustomFees<Call: Dispatchable, AccountId> {
    type FeeDetails;

    // Required methods
    fn should_be_postponed(
        who: &AccountId,
        fee_source: &AccountId,
        call: &Call,
        fee: Balance
    ) -> bool;
    fn should_be_paid(who: &AccountId, call: &Call) -> bool;
    fn get_fee_source(who: &AccountId, call: &Call, fee: Balance) -> AccountId;
    fn compute_fee(call: &Call) -> Option<(Balance, Self::FeeDetails)>;
    fn compute_actual_fee(
        post_info: &PostDispatchInfoOf<Call>,
        info: &DispatchInfoOf<Call>,
        result: &DispatchResult,
        fee_details: Option<Self::FeeDetails>
    ) -> Option<Balance>;
}
Expand description

Trait whose implementation allows to redefine extrinsics fees based on the extrinsic’s Call variant and dispatch result

Required Associated Types§

source

type FeeDetails

Additinal information to be passed between Self::compute_fee and Self::compute_actual_fee

Required Methods§

source

fn should_be_postponed( who: &AccountId, fee_source: &AccountId, call: &Call, fee: Balance ) -> bool

Check if the fee payment should be postponed

Parameters: who is the caller of the extrinsic fee_source is the account which will pay fees call is the Call extracted from the extrinsic fee is the pre dispatch fee

Returns: true then fee payment should be postponed to the post dispatch phase false then fee should be paid at pre dispatch phase and corrected at post dispatch phase

This call should check if fee_source will have enough funds to pay the fee after call dispatch and if not then it should return false

source

fn should_be_paid(who: &AccountId, call: &Call) -> bool

Check if the fee should be paid for this extrinsic

Parameters: who is the caller of the extrinsic call is the Call extracted from the extrinsic

Returns: true then fee should be paid false then fee should not be paid

source

fn get_fee_source(who: &AccountId, call: &Call, fee: Balance) -> AccountId

Get the account which will pay fees

Parameters: who is the caller of the extrinsic call is the Call extracted from the extrinsic fee is the pre dispatch fee

Returns account which will pay fees

source

fn compute_fee(call: &Call) -> Option<(Balance, Self::FeeDetails)>

Compute custom fees for this call

Parameters: call is the Call extracted from the extrinsic

Returns: Some(..) if custom fees should be applied. Then Balance value is used as fee and Self::FeeDetails is passed to Self::compute_actual_fee at post dispatch phase None if default transaction payment pallet fees should be used

source

fn compute_actual_fee( post_info: &PostDispatchInfoOf<Call>, info: &DispatchInfoOf<Call>, result: &DispatchResult, fee_details: Option<Self::FeeDetails> ) -> Option<Balance>

Compute actual fees for this call

Parameters: post_info is the PostDispatchInfo returned from the call info is the DispatchInfo for the call result is the DispatchResult returned from the call fee_details is the Self::FeeDetails returned from the previous Self::compute_fee call

Returns: Some(..) if custom post dispatch fees should be applied None if transaction payment pallet post dispatch fees should be used

Implementations on Foreign Types§

source§

impl<Call: Dispatchable, AccountId: Clone> ApplyCustomFees<Call, AccountId> for ()

§

type FeeDetails = ()

source§

fn should_be_postponed( _who: &AccountId, _fee_source: &AccountId, _call: &Call, _fee: Balance ) -> bool

source§

fn should_be_paid(_who: &AccountId, _call: &Call) -> bool

source§

fn compute_fee(_call: &Call) -> Option<(Balance, Self::FeeDetails)>

source§

fn compute_actual_fee( _post_info: &PostDispatchInfoOf<Call>, _info: &DispatchInfoOf<Call>, _result: &DispatchResult, _fee_details: Option<Self::FeeDetails> ) -> Option<Balance>

source§

fn get_fee_source(who: &AccountId, _call: &Call, _fee: Balance) -> AccountId

Implementors§