Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
85a1953
wip
xlc Jan 31, 2019
274801f
Split bytes fee charging and charging by amount into different traits.
shaunxw Jan 31, 2019
eccd12c
Move to edition 2018.
shaunxw Feb 1, 2019
81a3929
Implemented charge fee traits for fees module.
shaunxw Feb 1, 2019
5923d01
Implemented 'on_finalise' for fee module.
shaunxw Feb 4, 2019
dd504f8
Merge branch 'master' into fee
shaunxw Feb 4, 2019
50f2cd5
Updated fees finalize impl.
shaunxw Feb 6, 2019
d9b951a
Renaming and documentation update.
shaunxw Feb 6, 2019
02f6358
Added overflow & underflow check for fee calculation.
shaunxw Feb 7, 2019
25cbd29
Added mock and unit tests for fee module.
shaunxw Feb 7, 2019
13c31be
More unit tests for fees module.
shaunxw Feb 8, 2019
df8d4d1
Fixed srml-executive unit tests.
shaunxw Feb 8, 2019
f4ef7b5
Merge branch 'master' into fee
shaunxw Feb 8, 2019
ba58808
Remove transaction base/bytes fee from balances module, fix unit tests.
shaunxw Feb 9, 2019
b12405a
Merge remote-tracking branch 'upstream/master' into fee
xlc Feb 11, 2019
b23cd67
fix compile error
xlc Feb 11, 2019
544e18c
Merge branch 'fee' of github.com:xlc/substrate into fee
shaunxw Feb 11, 2019
670f431
Fixed unit test.
shaunxw Feb 12, 2019
a9a948a
Minor fixes.
shaunxw Feb 12, 2019
3b9faa4
Bump spec version.
shaunxw Feb 12, 2019
b420972
Merge branch 'master' into fee
shaunxw Feb 12, 2019
857d3dc
Bump spec version.
shaunxw Feb 12, 2019
d84c199
Updated fees module and runtime wasm.
shaunxw Feb 12, 2019
4908fbb
Fees module code style improvement; updated runtime wasm.
shaunxw Feb 13, 2019
a0af48d
Merge branch 'master' into fee
shaunxw Feb 13, 2019
70a14dc
Bump spec and impl version.
shaunxw Feb 13, 2019
4e6c4f8
Merge branch 'master' into fee
shaunxw Feb 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor fixes.
  • Loading branch information
shaunxw committed Feb 12, 2019
commit a9a948adbdfc04bc176e4869c664c0232a2b521e
Binary file not shown.
8 changes: 0 additions & 8 deletions srml/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,6 @@ decl_storage! {
/// `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
pub ReservedBalance get(reserved_balance): map T::AccountId => T::Balance;


// Payment stuff.

// /// The fee to be paid for making a transaction; the base.
// pub TransactionBaseFee get(transaction_base_fee) config(): T::Balance;
// /// The fee to be paid for making a transaction; the per-byte portion.
// pub TransactionByteFee get(transaction_byte_fee) config(): T::Balance;
}
add_extra_genesis {
config(balances): Vec<(T::AccountId, T::Balance)>;
Expand Down
14 changes: 8 additions & 6 deletions srml/fees/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern crate srml_support as runtime_support;

use runtime_support::{Parameter, dispatch::Result, StorageMap};
use runtime_primitives::traits::{As, Member, SimpleArithmetic, ChargeBytesFee, ChargeFee,
TransferAsset, CheckedAdd, CheckedSub, CheckedMul};
TransferAsset, CheckedAdd, CheckedSub, CheckedMul, Zero};
use system;

mod mock;
Expand All @@ -50,7 +50,7 @@ decl_module! {
(0..extrinsic_count).for_each(|index| {
// Deposit `Charged` event if some amount of fee charged.
let fee = Self::current_transaction_fee(index.clone());
if fee.as_() != 0 {
if !fee.is_zero() {
Self::deposit_event(RawEvent::Charged(index.clone(), fee));
}
// Remove transaction fee records of current block.
Expand Down Expand Up @@ -102,8 +102,6 @@ impl<T: Trait> ChargeFee<T::AccountId> for Module<T> {
type Amount = T::Amount;

fn charge_fee(transactor: &T::AccountId, amount: T::Amount) -> Result {
T::TransferAsset::remove_from(transactor, amount)?;

let extrinsic_index = match <system::Module<T>>::extrinsic_index() {
Some(i) => i,
None => return Err("no extrinsic index found"),
Expand All @@ -113,13 +111,14 @@ impl<T: Trait> ChargeFee<T::AccountId> for Module<T> {
Some(f) => f,
None => return Err("fee got overflow after charge"),
};

T::TransferAsset::remove_from(transactor, amount)?;

<CurrentTransactionFee<T>>::insert(extrinsic_index, new_fee);
Ok(())
}

fn refund_fee(transactor: &T::AccountId, amount: T::Amount) -> Result {
T::TransferAsset::add_to(transactor, amount)?;

let extrinsic_index = match <system::Module<T>>::extrinsic_index() {
Some(i) => i,
None => return Err("no extrinsic index found"),
Expand All @@ -129,6 +128,9 @@ impl<T: Trait> ChargeFee<T::AccountId> for Module<T> {
Some(f) => f,
None => return Err("fee got underflow after refund"),
};

T::TransferAsset::add_to(transactor, amount)?;

<CurrentTransactionFee<T>>::insert(extrinsic_index, new_fee);
Ok(())
}
Expand Down