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
@@ -192,13 +192,10 @@ fn decl_store_extra_genesis(
is_trait_needed = true;
has_trait_field = true;
}
for t in ext::get_non_bound_serde_derive_types(type_infos.value_type, &traitinstance) {
serde_complete_bound.insert(t);
}
serde_complete_bound.insert(type_infos.value_type);
if let DeclStorageTypeInfosKind::Map { key_type, .. } = type_infos.kind {
for t in ext::get_non_bound_serde_derive_types(key_type, &traitinstance) {
serde_complete_bound.insert(t);
}
serde_complete_bound.insert(key_type);
}
let storage_type = type_infos.typ.clone();
config_field.extend(match type_infos.kind {
@@ -285,9 +282,7 @@ fn decl_store_extra_genesis(
has_trait_field = true;
}
for t in ext::get_non_bound_serde_derive_types(extra_type, &traitinstance).into_iter() {
serde_complete_bound.insert(t);
}
serde_complete_bound.insert(extra_type);
let extrafield = &extra_field.content;
genesis_extrafields.extend(quote!{
@@ -315,6 +310,7 @@ fn decl_store_extra_genesis(
let serde_bug_bound = if !serde_complete_bound.is_empty() {
let mut b_ser = String::new();
let mut b_dser = String::new();
// panic!("{:#?}", serde_complete_bound);
serde_complete_bound.into_iter().for_each(|bound| {
let stype = quote!(#bound);
b_ser.push_str(&format!("{} : {}::serde::Serialize, ", stype, scrate));