diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index d5b3881eb4..6e07dcad53 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1141,7 +1141,6 @@ impl pallet_asset_rate::Config for Runtime { type CreateOrigin = EnsureRoot; type RemoveOrigin = EnsureRoot; type UpdateOrigin = EnsureRoot; - type Balance = Balance; type Currency = Balances; type AssetKind = u32; type RuntimeEvent = RuntimeEvent; diff --git a/substrate/frame/asset-rate/src/lib.rs b/substrate/frame/asset-rate/src/lib.rs index 94ee0565bc..8b55f3d1d4 100644 --- a/substrate/frame/asset-rate/src/lib.rs +++ b/substrate/frame/asset-rate/src/lib.rs @@ -59,11 +59,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::traits::{ - fungible::Inspect, - tokens::{Balance, ConversionFromAssetBalance}, -}; -use sp_runtime::{traits::Zero, FixedPointNumber, FixedPointOperand, FixedU128}; +use frame_support::traits::{fungible::Inspect, tokens::ConversionFromAssetBalance}; +use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128}; pub use pallet::*; pub use weights::WeightInfo; @@ -111,11 +108,8 @@ pub mod pallet { /// The origin permissioned to update an existiing conversion rate for an asset. type UpdateOrigin: EnsureOrigin; - /// The units in which we record balances. - type Balance: Balance + FixedPointOperand; - /// The currency mechanism for this pallet. - type Currency: Inspect; + type Currency: Inspect; /// The type for asset kinds for which the conversion rate to native balance is set. type AssetKind: Parameter + MaxEncodedLen; @@ -230,7 +224,6 @@ pub mod pallet { impl ConversionFromAssetBalance, AssetKindOf, BalanceOf> for Pallet where T: Config, - BalanceOf: FixedPointOperand + Zero, { type Error = pallet::Error; diff --git a/substrate/frame/asset-rate/src/mock.rs b/substrate/frame/asset-rate/src/mock.rs index 28b754f2f2..5fe0d4240a 100644 --- a/substrate/frame/asset-rate/src/mock.rs +++ b/substrate/frame/asset-rate/src/mock.rs @@ -84,7 +84,6 @@ impl pallet_asset_rate::Config for Test { type CreateOrigin = frame_system::EnsureRoot; type RemoveOrigin = frame_system::EnsureRoot; type UpdateOrigin = frame_system::EnsureRoot; - type Balance = u64; type Currency = Balances; type AssetKind = u32; #[cfg(feature = "runtime-benchmarks")] diff --git a/substrate/frame/assets/src/types.rs b/substrate/frame/assets/src/types.rs index 559afccb94..67f9bf07f5 100644 --- a/substrate/frame/assets/src/types.rs +++ b/substrate/frame/assets/src/types.rs @@ -22,7 +22,7 @@ use frame_support::{ pallet_prelude::*, traits::{fungible, tokens::ConversionToAssetBalance}, }; -use sp_runtime::{traits::Convert, FixedPointNumber, FixedPointOperand, FixedU128}; +use sp_runtime::{traits::Convert, FixedPointNumber, FixedU128}; pub(super) type DepositBalanceOf = <>::Currency as Currency<::AccountId>>::Balance; @@ -293,8 +293,6 @@ where T: Config, I: 'static, CON: Convert, AssetBalanceOf>, - BalanceOf: FixedPointOperand + Zero, - AssetBalanceOf: FixedPointOperand + Zero, { type Error = ConversionError; diff --git a/substrate/frame/nis/src/lib.rs b/substrate/frame/nis/src/lib.rs index 1bf052a39d..decebbd567 100644 --- a/substrate/frame/nis/src/lib.rs +++ b/substrate/frame/nis/src/lib.rs @@ -165,6 +165,7 @@ pub mod pallet { fungible::{self, hold::Mutate as FunHoldMutate, Balanced as FunBalanced}, nonfungible::{Inspect as NftInspect, Transfer as NftTransfer}, tokens::{ + Balance, Fortitude::Polite, Precision::{BestEffort, Exact}, Preservation::Expendable, @@ -214,17 +215,9 @@ pub mod pallet { /// Overarching hold reason. type RuntimeHoldReason: From; - /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to - /// `From`. - type CurrencyBalance: sp_runtime::traits::AtLeast32BitUnsigned - + codec::FullCodec - + Copy - + MaybeSerializeDeserialize - + sp_std::fmt::Debug - + Default - + From - + TypeInfo - + MaxEncodedLen; + /// Just the [`Balance`] type; we have this item to allow us to constrain it to + /// [`From`]. + type CurrencyBalance: Balance + From; /// Origin required for auto-funding the deficit. type FundOrigin: EnsureOrigin; diff --git a/substrate/frame/support/src/traits/tokens/currency.rs b/substrate/frame/support/src/traits/tokens/currency.rs index 1bc91b6ae5..e6a7284a74 100644 --- a/substrate/frame/support/src/traits/tokens/currency.rs +++ b/substrate/frame/support/src/traits/tokens/currency.rs @@ -25,9 +25,7 @@ use crate::{ dispatch::{DispatchError, DispatchResult}, traits::Get, }; -use codec::MaxEncodedLen; -use sp_runtime::{traits::MaybeSerializeDeserialize, FixedPointOperand}; -use sp_std::fmt::Debug; +use sp_runtime::traits::MaybeSerializeDeserialize; mod reservable; pub use reservable::{NamedReservableCurrency, ReservableCurrency}; @@ -37,7 +35,7 @@ pub use lockable::{LockIdentifier, LockableCurrency, VestingSchedule}; /// Abstraction over a fungible assets system. pub trait Currency { /// The balance of an account. - type Balance: Balance + MaybeSerializeDeserialize + Debug + MaxEncodedLen + FixedPointOperand; + type Balance: Balance + MaybeSerializeDeserialize; /// 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. diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs index efc7386ae8..c2d9ed56c7 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs @@ -60,7 +60,6 @@ use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, }, - FixedPointOperand, }; #[cfg(test)] @@ -165,12 +164,8 @@ pub struct ChargeAssetTxPayment { impl ChargeAssetTxPayment where T::RuntimeCall: Dispatchable, - AssetBalanceOf: Send + Sync + FixedPointOperand, - BalanceOf: Send - + Sync - + FixedPointOperand - + Into> - + From>, + AssetBalanceOf: Send + Sync, + BalanceOf: Send + Sync + Into> + From>, ChargeAssetIdOf: Send + Sync, { /// Utility constructor. Used only in client/factory code. @@ -234,11 +229,10 @@ impl sp_std::fmt::Debug for ChargeAssetTxPayment { impl SignedExtension for ChargeAssetTxPayment where T::RuntimeCall: Dispatchable, - AssetBalanceOf: Send + Sync + FixedPointOperand, + AssetBalanceOf: Send + Sync, BalanceOf: Send + Sync + From - + FixedPointOperand + Into> + Into> + From>, diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs index 86f3025cc3..753fae747a 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -56,7 +56,6 @@ use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, }, - FixedPointOperand, }; #[cfg(test)] @@ -156,8 +155,8 @@ pub struct ChargeAssetTxPayment { impl ChargeAssetTxPayment where T::RuntimeCall: Dispatchable, - AssetBalanceOf: Send + Sync + FixedPointOperand, - BalanceOf: Send + Sync + FixedPointOperand + IsType>, + AssetBalanceOf: Send + Sync, + BalanceOf: Send + Sync + IsType>, ChargeAssetIdOf: Send + Sync, Credit: IsType>, { @@ -213,8 +212,8 @@ impl sp_std::fmt::Debug for ChargeAssetTxPayment { impl SignedExtension for ChargeAssetTxPayment where T::RuntimeCall: Dispatchable, - AssetBalanceOf: Send + Sync + FixedPointOperand, - BalanceOf: Send + Sync + From + FixedPointOperand + IsType>, + AssetBalanceOf: Send + Sync, + BalanceOf: Send + Sync + From + IsType>, ChargeAssetIdOf: Send + Sync, Credit: IsType>, { diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index 0cc7bdad46..8160d72ad8 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -67,7 +67,7 @@ use sp_runtime::{ transaction_validity::{ TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransaction, }, - FixedPointNumber, FixedPointOperand, FixedU128, Perbill, Perquintill, RuntimeDebug, + FixedPointNumber, FixedU128, Perbill, Perquintill, RuntimeDebug, }; use sp_std::prelude::*; pub use types::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; @@ -461,10 +461,7 @@ pub mod pallet { } } -impl Pallet -where - BalanceOf: FixedPointOperand, -{ +impl Pallet { /// Query the data that we know about the fee of a given `call`. /// /// This pallet is not and cannot be aware of the internals of a signed extension, for example @@ -649,7 +646,6 @@ where impl Convert> for Pallet where T: Config, - BalanceOf: FixedPointOperand, { /// Compute the fee for the specified weight. /// @@ -678,7 +674,7 @@ pub struct ChargeTransactionPayment(#[codec(compact)] BalanceOf); impl ChargeTransactionPayment where T::RuntimeCall: Dispatchable, - BalanceOf: Send + Sync + FixedPointOperand, + BalanceOf: Send + Sync, { /// utility constructor. Used only in client/factory code. pub fn from(fee: BalanceOf) -> Self { @@ -800,7 +796,7 @@ impl sp_std::fmt::Debug for ChargeTransactionPayment { impl SignedExtension for ChargeTransactionPayment where - BalanceOf: Send + Sync + From + FixedPointOperand, + BalanceOf: Send + Sync + From, T::RuntimeCall: Dispatchable, { const IDENTIFIER: &'static str = "ChargeTransactionPayment"; @@ -866,7 +862,6 @@ where impl EstimateCallFee> for Pallet where - BalanceOf: FixedPointOperand, T::RuntimeCall: Dispatchable, { fn estimate_call_fee(call: &AnyCall, post_info: PostDispatchInfo) -> BalanceOf { diff --git a/substrate/primitives/arithmetic/src/fixed_point.rs b/substrate/primitives/arithmetic/src/fixed_point.rs index 08b788e9ab..d3e75f6f78 100644 --- a/substrate/primitives/arithmetic/src/fixed_point.rs +++ b/substrate/primitives/arithmetic/src/fixed_point.rs @@ -52,16 +52,18 @@ pub trait FixedPointOperand: { } -impl FixedPointOperand for i128 {} -impl FixedPointOperand for u128 {} -impl FixedPointOperand for i64 {} -impl FixedPointOperand for u64 {} -impl FixedPointOperand for i32 {} -impl FixedPointOperand for u32 {} -impl FixedPointOperand for i16 {} -impl FixedPointOperand for u16 {} -impl FixedPointOperand for i8 {} -impl FixedPointOperand for u8 {} +impl FixedPointOperand for T where + T: Copy + + Clone + + Bounded + + Zero + + Saturating + + PartialOrd + + UniqueSaturatedInto + + TryFrom + + CheckedNeg +{ +} /// Something that implements a decimal fixed point number. /// diff --git a/substrate/primitives/arithmetic/src/traits.rs b/substrate/primitives/arithmetic/src/traits.rs index 061b11b3e9..6fcc824853 100644 --- a/substrate/primitives/arithmetic/src/traits.rs +++ b/substrate/primitives/arithmetic/src/traits.rs @@ -59,6 +59,7 @@ pub trait BaseArithmetic: + CheckedMul + CheckedDiv + CheckedRem + + CheckedNeg + Ensure + Saturating + PartialOrd @@ -116,6 +117,7 @@ impl< + CheckedMul + CheckedDiv + CheckedRem + + CheckedNeg + Ensure + Saturating + PartialOrd