Add FixedPointOperand blanket implementation (#14634)

* bound `Balance` to `FixedPointOperand`

* ".git/.scripts/commands/fmt/fmt.sh"

* clean up code

* Apply suggestions from code review

Co-authored-by: Gavin Wood <gavin@parity.io>

* wip

* add blanket `FixedPointOperand` impl

* update nis CurrencyBalance

* remove CheckedNeg bound

---------

Co-authored-by: command-bot <>
Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
Juan
2023-08-02 09:54:11 +02:00
committed by GitHub
parent 77321288c3
commit 85f9931e4f
11 changed files with 35 additions and 63 deletions
+3 -10
View File
@@ -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<Self::RuntimeOrigin>;
/// The units in which we record balances.
type Balance: Balance + FixedPointOperand;
/// The currency mechanism for this pallet.
type Currency: Inspect<Self::AccountId, Balance = Self::Balance>;
type Currency: Inspect<Self::AccountId>;
/// 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<T> ConversionFromAssetBalance<BalanceOf<T>, AssetKindOf<T>, BalanceOf<T>> for Pallet<T>
where
T: Config,
BalanceOf<T>: FixedPointOperand + Zero,
{
type Error = pallet::Error<T>;
-1
View File
@@ -84,7 +84,6 @@ impl pallet_asset_rate::Config for Test {
type CreateOrigin = frame_system::EnsureRoot<u64>;
type RemoveOrigin = frame_system::EnsureRoot<u64>;
type UpdateOrigin = frame_system::EnsureRoot<u64>;
type Balance = u64;
type Currency = Balances;
type AssetKind = u32;
#[cfg(feature = "runtime-benchmarks")]