Skip to content

Commit

Permalink
remove unused struct in payment and add impl for FeeMultiplierUpdate (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
atenjin authored Jul 2, 2020
1 parent a27bf19 commit 71481da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
21 changes: 13 additions & 8 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ use static_assertions::const_assert;
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, DispatchInfoOf, IdentityLookup, NumberFor, Saturating,
SignedExtension,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
BlakeTwo256, Block as BlockT, DispatchInfoOf, IdentityLookup, NumberFor, Saturating,
SignedExtension,
},
transaction_validity::{
InvalidTransaction, TransactionSource, TransactionValidity, TransactionValidityError,
ValidTransaction,
},
ApplyExtrinsicResult,
ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill,
};
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
#[cfg(feature = "std")]
Expand All @@ -32,7 +32,7 @@ use sp_version::RuntimeVersion;

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};

// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
Expand Down Expand Up @@ -65,6 +65,7 @@ pub use xpallet_bridge_bitcoin::{
pub use xpallet_contracts::Schedule as ContractsSchedule;
pub use xpallet_contracts_primitives::XRC20Selector;
pub use xpallet_protocol::*;
pub use xpallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};

impl_opaque_keys! {
pub struct SessionKeys {
Expand Down Expand Up @@ -300,13 +301,17 @@ impl xpallet_contracts::Trait for Runtime {
}

parameter_types! {
pub const TransactionByteFee: Balance = 1;
pub const TransactionByteFee: Balance = 1; // TODO change in future
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
}

impl xpallet_transaction_payment::Trait for Runtime {
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
type FeeMultiplierUpdate =
TargetedFeeAdjustment<Self, TargetBlockFullness, AdjustmentVariable, MinimumMultiplier>;
}

construct_runtime!(
Expand Down
19 changes: 1 addition & 18 deletions xpallets/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use sp_runtime::{
InvalidTransaction, TransactionPriority, TransactionValidity, TransactionValidityError,
ValidTransaction,
},
FixedPointNumber, FixedPointOperand, FixedU128, Perquintill, RuntimeDebug,
FixedPointNumber, FixedPointOperand, FixedU128, Perquintill,
};
use sp_std::prelude::*;
use xpallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
Expand Down Expand Up @@ -169,21 +169,6 @@ where
}
}

/// Storage releases of the module.
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug)]
enum Releases {
/// Original version of the module.
V1Ancient,
/// One that bumps the usage to FixedU128 from FixedI128.
V2,
}

impl Default for Releases {
fn default() -> Self {
Releases::V1Ancient
}
}

pub trait Trait: frame_system::Trait + xpallet_assets::Trait {
// /// The currency type in which fees will be paid.
// type Currency: Currency<Self::AccountId> + Send + Sync;
Expand All @@ -206,8 +191,6 @@ pub trait Trait: frame_system::Trait + xpallet_assets::Trait {
decl_storage! {
trait Store for Module<T: Trait> as TransactionPayment {
pub NextFeeMultiplier get(fn next_fee_multiplier): Multiplier = Multiplier::saturating_from_integer(1);

StorageVersion build(|_: &GenesisConfig| Releases::V2): Releases;
}
}

Expand Down

0 comments on commit 71481da

Please sign in to comment.