mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 23:31:07 +00:00
refactor: Transaction-Payment module (#3816)
* Initial draft that compiles * Extract payment stuff from balances * Extract multiplier update stuff from system * Some fixes. * Update len-fee as well * some review comments. * Remove todo * bump
This commit is contained in:
@@ -24,6 +24,7 @@ randomness-collective-flip = { package = "srml-randomness-collective-flip", path
|
||||
system = { package = "srml-system", path = "../../srml/system", default_features = false }
|
||||
timestamp = { package = "srml-timestamp", path = "../../srml/timestamp", default_features = false }
|
||||
sudo = { package = "srml-sudo", path = "../../srml/sudo", default_features = false }
|
||||
transaction-payment = { package = "srml-transaction-payment", path = "../../srml/transaction-payment", default_features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default_features = false }
|
||||
client = { package = "substrate-client", path = "../../core/client", default_features = false }
|
||||
offchain-primitives = { package = "substrate-offchain-primitives", path = "../../core/offchain/primitives", default-features = false }
|
||||
@@ -51,6 +52,7 @@ std = [
|
||||
"system/std",
|
||||
"timestamp/std",
|
||||
"sudo/std",
|
||||
"transaction-payment/std",
|
||||
"version/std",
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
|
||||
@@ -166,18 +166,17 @@ impl system::Trait for Runtime {
|
||||
type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
/// Update weight (to fee) multiplier per-block.
|
||||
type WeightMultiplierUpdate = ();
|
||||
/// The ubiquitous origin type.
|
||||
type Origin = Origin;
|
||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
type BlockHashCount = BlockHashCount;
|
||||
/// Maximum weight of each block. With a default weight system of 1byte == 1weight, 4mb is ok.
|
||||
/// Maximum weight of each block.
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
/// Portion of the block weight that is available to all normal transactions.
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
/// Version of the runtime.
|
||||
type Version = Version;
|
||||
}
|
||||
|
||||
@@ -223,8 +222,6 @@ parameter_types! {
|
||||
pub const ExistentialDeposit: u128 = 500;
|
||||
pub const TransferFee: u128 = 0;
|
||||
pub const CreationFee: u128 = 0;
|
||||
pub const TransactionBaseFee: u128 = 0;
|
||||
pub const TransactionByteFee: u128 = 1;
|
||||
}
|
||||
|
||||
impl balances::Trait for Runtime {
|
||||
@@ -236,15 +233,25 @@ impl balances::Trait for Runtime {
|
||||
type OnNewAccount = Indices;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type TransferFee = TransferFee;
|
||||
type CreationFee = CreationFee;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TransactionBaseFee: Balance = 0;
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl transaction_payment::Trait for Runtime {
|
||||
type Currency = balances::Module<Runtime>;
|
||||
type OnTransactionPayment = ();
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = ConvertInto;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl sudo::Trait for Runtime {
|
||||
@@ -269,6 +276,7 @@ construct_runtime!(
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
|
||||
Indices: indices::{default, Config<T>},
|
||||
Balances: balances::{default, Error},
|
||||
TransactionPayment: transaction_payment::{Module, Storage},
|
||||
Sudo: sudo,
|
||||
// Used for the module template in `./template.rs`
|
||||
TemplateModule: template::{Module, Call, Storage, Event<T>},
|
||||
@@ -293,7 +301,7 @@ pub type SignedExtra = (
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
balances::TakeFees<Runtime>
|
||||
transaction_payment::ChargeTransactionPayment<Runtime>
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
|
||||
@@ -100,7 +100,6 @@ mod tests {
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type WeightMultiplierUpdate = ();
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
|
||||
Reference in New Issue
Block a user