Improve fees module (#1821)

* remove amount associated
* make a new trait to bound some arithmetics to balances or assets:
  It also remove arithmetic bounds of srml-support::traits::Currency.

  To update your code then use srml_support::traits::ArithmeticType like:
  `type Currency: ArithmeticType + Currency<Self::AccountId, Balance=BalanceOf<Self>>; ` 
  with `type BalanceOf<T> = <<T as Trait>::Currency as ArithmeticType>::Type; `

* improve decl_storage when it explicit serde bound: basically don't try to be smarter than rust and just use where clause.
This commit is contained in:
thiolliere
2019-02-19 17:13:59 +01:00
committed by GitHub
parent 9a2f1b2007
commit 8065116ba5
16 changed files with 48 additions and 100 deletions
+6 -2
View File
@@ -29,7 +29,7 @@ use rstd::{cmp, result};
use parity_codec::Codec;
use parity_codec_derive::{Encode, Decode};
use srml_support::{StorageValue, StorageMap, Parameter, decl_event, decl_storage, decl_module, ensure};
use srml_support::traits::{UpdateBalanceOutcome, Currency, EnsureAccountLiquid, OnFreeBalanceZero};
use srml_support::traits::{UpdateBalanceOutcome, Currency, EnsureAccountLiquid, OnFreeBalanceZero, ArithmeticType};
use srml_support::dispatch::Result;
use primitives::traits::{Zero, SimpleArithmetic,
As, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug, TransferAsset};
@@ -40,7 +40,7 @@ mod tests;
pub trait Trait: system::Trait {
/// The balance of an account.
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64>;
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug;
/// A function which is invoked when the free-balance has fallen below the existential deposit and
/// has been reduced to zero.
@@ -58,6 +58,10 @@ pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
impl<T: Trait> ArithmeticType for Module<T> {
type Type = <T as Trait>::Balance;
}
decl_event!(
pub enum Event<T> where
<T as system::Trait>::AccountId,