Remove As trait bound from Currency::Balance (#2205)

* remove As<64> bond

* Currency trait refactor

* bump spec version
This commit is contained in:
Xiliang Chen
2019-05-09 19:40:28 +12:00
committed by Gavin Wood
parent c3f20bf226
commit 57164aa747
4 changed files with 11 additions and 9 deletions
+2 -2
View File
@@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node"),
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 72,
impl_version: 74,
spec_version: 73,
impl_version: 73,
apis: RUNTIME_API_VERSIONS,
};
+2 -2
View File
@@ -167,7 +167,7 @@ pub use self::imbalances::{PositiveImbalance, NegativeImbalance};
pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
/// The balance of an account.
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug;
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + MaybeSerializeDebug;
/// A function that is invoked when the free-balance has fallen below the existential deposit and
/// has been reduced to zero.
@@ -181,7 +181,7 @@ pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
pub trait Trait<I: Instance = DefaultInstance>: system::Trait {
/// The balance of an account.
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug;
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + MaybeSerializeDebug;
/// A function that is invoked when the free-balance has fallen below the existential deposit and
/// has been reduced to zero.
+4 -2
View File
@@ -894,8 +894,10 @@ impl<T: Trait> Module<T> {
Self::reward_validator(v, reward);
}
Self::deposit_event(RawEvent::Reward(reward));
let total_minted = reward * <BalanceOf<T> as As<usize>>::sa(validators.len());
let total_rewarded_stake = Self::slot_stake() * <BalanceOf<T> as As<usize>>::sa(validators.len());
let len = validators.len() as u64; // validators length can never overflow u64
let len = BalanceOf::<T>::sa(len);
let total_minted = reward * len;
let total_rewarded_stake = Self::slot_stake() * len;
T::OnRewardMinted::on_dilution(total_minted, total_rewarded_stake);
}
+3 -3
View File
@@ -19,7 +19,7 @@
use crate::rstd::result;
use crate::codec::{Codec, Encode, Decode};
use crate::runtime_primitives::traits::{
MaybeSerializeDebug, SimpleArithmetic, As
MaybeSerializeDebug, SimpleArithmetic
};
/// The account with the given id was killed.
@@ -195,7 +195,7 @@ pub enum SignedImbalance<B, P: Imbalance<B>>{
impl<
P: Imbalance<B, Opposite=N>,
N: Imbalance<B, Opposite=P>,
B: SimpleArithmetic + As<usize> + As<u64> + Codec + Copy + MaybeSerializeDebug + Default,
B: SimpleArithmetic + Codec + Copy + MaybeSerializeDebug + Default,
> SignedImbalance<B, P> {
pub fn zero() -> Self {
SignedImbalance::Positive(P::zero())
@@ -230,7 +230,7 @@ impl<
/// Abstraction over a fungible assets system.
pub trait Currency<AccountId> {
/// The balance of an account.
type Balance: SimpleArithmetic + As<usize> + As<u64> + Codec + Copy + MaybeSerializeDebug + Default;
type Balance: SimpleArithmetic + Codec + Copy + MaybeSerializeDebug + Default;
/// The opaque token type for an imbalance. This is returned by unbalanced operations
/// and must be dealt with. It may be dropped but cannot be cloned.