mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
Transaction Fee Module (#1648)
* wip * Split bytes fee charging and charging by amount into different traits. * Move to edition 2018. * Implemented charge fee traits for fees module. * Implemented 'on_finalise' for fee module. * Updated fees finalize impl. * Renaming and documentation update. * Added overflow & underflow check for fee calculation. * Added mock and unit tests for fee module. * More unit tests for fees module. * Fixed srml-executive unit tests. * Remove transaction base/bytes fee from balances module, fix unit tests. * fix compile error * Fixed unit test. * Minor fixes. * Bump spec version. * Bump spec version. * Updated fees module and runtime wasm. * Fees module code style improvement; updated runtime wasm. * Bump spec and impl version.
This commit is contained in:
committed by
Bastian Köcher
parent
6a6c3155a6
commit
fafffdb771
@@ -78,6 +78,7 @@ use srml_support::traits::OnFreeBalanceZero;
|
||||
use system::{ensure_signed, RawOrigin};
|
||||
use runtime_io::{blake2_256, twox_128};
|
||||
use timestamp;
|
||||
use fees;
|
||||
|
||||
pub type CodeHash<T> = <T as system::Trait>::Hash;
|
||||
|
||||
@@ -91,7 +92,7 @@ pub trait ComputeDispatchFee<Call, Balance> {
|
||||
fn compute_dispatch_fee(call: &Call) -> Balance;
|
||||
}
|
||||
|
||||
pub trait Trait: balances::Trait + timestamp::Trait {
|
||||
pub trait Trait: fees::Trait + balances::Trait + timestamp::Trait {
|
||||
/// The outer call dispatch type.
|
||||
type Call: Parameter + Dispatchable<Origin=<Self as system::Trait>::Origin>;
|
||||
|
||||
@@ -135,14 +136,14 @@ where
|
||||
}
|
||||
|
||||
/// The default dispatch fee computor computes the fee in the same way that
|
||||
/// implementation of `MakePayment` for balances module does.
|
||||
/// implementation of `ChargeBytesFee` for fees module does.
|
||||
pub struct DefaultDispatchFeeComputor<T: Trait>(PhantomData<T>);
|
||||
impl<T: Trait> ComputeDispatchFee<T::Call, T::Balance> for DefaultDispatchFeeComputor<T> {
|
||||
fn compute_dispatch_fee(call: &T::Call) -> T::Balance {
|
||||
let encoded_len = parity_codec::Encode::encode(&call).len();
|
||||
let base_fee = <balances::Module<T>>::transaction_base_fee();
|
||||
let byte_fee = <balances::Module<T>>::transaction_byte_fee();
|
||||
base_fee + byte_fee * <T::Balance as As<u64>>::sa(encoded_len as u64)
|
||||
let base_fee = <fees::Module<T>>::transaction_base_fee();
|
||||
let byte_fee = <fees::Module<T>>::transaction_byte_fee();
|
||||
<T::Balance as As<u64>>::sa(base_fee.as_() + byte_fee.as_() * encoded_len as u64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user