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 all commits
Commits
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
42 changes: 19 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame_support::{
weights::{GetDispatchInfo, constants::ExtrinsicBaseWeight, IdentityFee, WeightToFeePolynomial},
};
use sp_core::NeverNativeValue;
use sp_runtime::{Perbill, FixedPointNumber};
use sp_runtime::{Perbill, traits::One};
use node_runtime::{
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment, Multiplier,
TransactionByteFee,
Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl OnUnbalanced<NegativeImbalance> for Author {

#[cfg(test)]
mod multiplier_tests {
use sp_runtime::{assert_eq_error_rate, FixedPointNumber, traits::Convert};
use sp_runtime::{assert_eq_error_rate, FixedPointNumber, traits::{Convert, One, Zero}};
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion frame/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ mod tests {
use sp_core::H256;
use sp_runtime::{
testing::{Header, TestXt},
traits::{BlakeTwo256, IdentityLookup},
traits::{BlakeTwo256, IdentityLookup, One},
transaction_validity::InvalidTransaction,
Perbill,
};
Expand Down
33 changes: 17 additions & 16 deletions primitives/arithmetic/src/fixed_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub trait FixedPointNumber:
+ Saturating + Bounded
+ Eq + PartialEq + Ord + PartialOrd
+ CheckedSub + CheckedAdd + CheckedMul + CheckedDiv
+ Add + Sub + Div + Mul
+ Add + Sub + Div + Mul + Zero + One
{
/// The underlying data type used for this fixed point number.
type Inner: Debug + One + CheckedMul + CheckedDiv + FixedPointOperand;
Expand Down Expand Up @@ -195,21 +195,6 @@ pub trait FixedPointNumber:
Self::one().checked_div(&self)
}

/// Returns zero.
fn zero() -> Self {
Self::from_inner(Self::Inner::zero())
}

/// Checks if the number is zero.
fn is_zero(&self) -> bool {
self.into_inner() == Self::Inner::zero()
}

/// Returns one.
fn one() -> Self {
Self::from_inner(Self::DIV)
}

/// Checks if the number is one.
fn is_one(&self) -> bool {
self.into_inner() == Self::Inner::one()
Expand Down Expand Up @@ -514,6 +499,22 @@ macro_rules! implement_fixed {
}
}

impl Zero for $name {
fn zero() -> Self {
Self::from_inner(<Self as FixedPointNumber>::Inner::zero())
}

fn is_zero(&self) -> bool {
self.into_inner() == <Self as FixedPointNumber>::Inner::zero()
}
}

impl One for $name {
fn one() -> Self {
Self::from_inner(Self::DIV)
}
}

impl sp_std::fmt::Debug for $name {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
Expand Down