Use the balance trait as we have one (#13136)

This commit is contained in:
Squirrel
2023-01-13 13:47:18 +00:00
committed by GitHub
parent 8ac1de8f04
commit deeaa1c8fd
2 changed files with 7 additions and 24 deletions
@@ -21,15 +21,13 @@ use codec::FullCodec;
use frame_support::{ use frame_support::{
traits::{ traits::{
fungibles::{Balanced, CreditOf, Inspect}, fungibles::{Balanced, CreditOf, Inspect},
tokens::BalanceConversion, tokens::{Balance, BalanceConversion},
}, },
unsigned::TransactionValidityError, unsigned::TransactionValidityError,
}; };
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_runtime::{ use sp_runtime::{
traits::{ traits::{DispatchInfoOf, MaybeSerializeDeserialize, One, PostDispatchInfoOf},
AtLeast32BitUnsigned, DispatchInfoOf, MaybeSerializeDeserialize, One, PostDispatchInfoOf,
},
transaction_validity::InvalidTransaction, transaction_validity::InvalidTransaction,
}; };
use sp_std::{fmt::Debug, marker::PhantomData}; use sp_std::{fmt::Debug, marker::PhantomData};
@@ -37,13 +35,7 @@ use sp_std::{fmt::Debug, marker::PhantomData};
/// Handle withdrawing, refunding and depositing of transaction fees. /// Handle withdrawing, refunding and depositing of transaction fees.
pub trait OnChargeAssetTransaction<T: Config> { pub trait OnChargeAssetTransaction<T: Config> {
/// The underlying integer type in which fees are calculated. /// The underlying integer type in which fees are calculated.
type Balance: AtLeast32BitUnsigned type Balance: Balance;
+ FullCodec
+ Copy
+ MaybeSerializeDeserialize
+ Debug
+ Default
+ TypeInfo;
/// The type used to identify the assets used for transaction payment. /// The type used to identify the assets used for transaction payment.
type AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo; type AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo;
/// The type used to store the intermediate values between pre- and post-dispatch. /// The type used to store the intermediate values between pre- and post-dispatch.
@@ -1,15 +1,11 @@
/// ! Traits and default implementation for paying transaction fees. /// ! Traits and default implementation for paying transaction fees.
use crate::Config; use crate::Config;
use codec::FullCodec;
use sp_runtime::{ use sp_runtime::{
traits::{ traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating, Zero},
AtLeast32BitUnsigned, DispatchInfoOf, MaybeSerializeDeserialize, PostDispatchInfoOf,
Saturating, Zero,
},
transaction_validity::InvalidTransaction, transaction_validity::InvalidTransaction,
}; };
use sp_std::{fmt::Debug, marker::PhantomData}; use sp_std::marker::PhantomData;
use frame_support::{ use frame_support::{
traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReasons}, traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReasons},
@@ -22,13 +18,8 @@ type NegativeImbalanceOf<C, T> =
/// Handle withdrawing, refunding and depositing of transaction fees. /// Handle withdrawing, refunding and depositing of transaction fees.
pub trait OnChargeTransaction<T: Config> { pub trait OnChargeTransaction<T: Config> {
/// The underlying integer type in which fees are calculated. /// The underlying integer type in which fees are calculated.
type Balance: AtLeast32BitUnsigned type Balance: frame_support::traits::tokens::Balance;
+ FullCodec
+ Copy
+ MaybeSerializeDeserialize
+ Debug
+ Default
+ scale_info::TypeInfo;
type LiquidityInfo: Default; type LiquidityInfo: Default;
/// Before the transaction is executed the payment of the transaction fees /// Before the transaction is executed the payment of the transaction fees