mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Introduce WeightToFee trait instead of WeightToFeePolynomial and make WeightToFeePolynomial implement it instead (#11415)
* Introduce `WeightToFee` trait instead of `WeightToFeePolynomial` and make `WeightToFeePolynomial` implement it instead * Rename `WeightToFee::calc()` to `WeightToFee::wight_to_fee()` * Fix typo
This commit is contained in:
@@ -29,7 +29,6 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive"
|
||||
serde = { version = "1.0.136", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
smallvec = "1.8.0"
|
||||
serde_json = "1.0.79"
|
||||
|
||||
sp-storage = { version = "6.0.0", default-features = false, path = "../../../primitives/storage" }
|
||||
|
||||
@@ -21,22 +21,17 @@ use frame_support::{
|
||||
pallet_prelude::*,
|
||||
parameter_types,
|
||||
traits::{fungibles::Mutate, ConstU32, ConstU64, ConstU8, FindAuthor},
|
||||
weights::{
|
||||
DispatchClass, DispatchInfo, PostDispatchInfo, Weight, WeightToFeeCoefficient,
|
||||
WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||
},
|
||||
weights::{DispatchClass, DispatchInfo, PostDispatchInfo, Weight, WeightToFee as WeightToFeeT},
|
||||
ConsensusEngineId,
|
||||
};
|
||||
use frame_system as system;
|
||||
use frame_system::EnsureRoot;
|
||||
use pallet_balances::Call as BalancesCall;
|
||||
use pallet_transaction_payment::CurrencyAdapter;
|
||||
use smallvec::smallvec;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, ConvertInto, IdentityLookup, StaticLookup},
|
||||
Perbill,
|
||||
traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion, StaticLookup},
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
|
||||
@@ -83,8 +78,8 @@ impl Get<frame_system::limits::BlockWeights> for BlockWeights {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static TransactionByteFee: u64 = 1;
|
||||
pub static WeightToFee: u64 = 1;
|
||||
pub static TransactionByteFee: u64 = 1;
|
||||
}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
@@ -130,23 +125,27 @@ impl pallet_balances::Config for Runtime {
|
||||
type ReserveIdentifier = [u8; 8];
|
||||
}
|
||||
|
||||
impl WeightToFeePolynomial for WeightToFee {
|
||||
impl WeightToFeeT for WeightToFee {
|
||||
type Balance = u64;
|
||||
|
||||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
||||
smallvec![WeightToFeeCoefficient {
|
||||
degree: 1,
|
||||
coeff_frac: Perbill::zero(),
|
||||
coeff_integer: WEIGHT_TO_FEE.with(|v| *v.borrow()),
|
||||
negative: false,
|
||||
}]
|
||||
fn weight_to_fee(weight: &Weight) -> Self::Balance {
|
||||
Self::Balance::saturated_from(*weight).saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow()))
|
||||
}
|
||||
}
|
||||
|
||||
impl WeightToFeeT for TransactionByteFee {
|
||||
type Balance = u64;
|
||||
|
||||
fn weight_to_fee(weight: &Weight) -> Self::Balance {
|
||||
Self::Balance::saturated_from(*weight)
|
||||
.saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow()))
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
|
||||
type WeightToFee = WeightToFee;
|
||||
type LengthToFee = WeightToFee;
|
||||
type LengthToFee = TransactionByteFee;
|
||||
type FeeMultiplierUpdate = ();
|
||||
type OperationalFeeMultiplier = ConstU8<5>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user