fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
@@ -6,7 +6,7 @@ edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "FRAME pallet to manage transaction payments"
|
||||
description = "FRAME pezpallet to manage transaction payments"
|
||||
readme = "README.md"
|
||||
documentation = "https://docs.rs/pezpallet-transaction-payment"
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Transaction Payment Pallet
|
||||
# Transaction Payment Pezpallet
|
||||
|
||||
This pallet provides the basic logic needed to pay the absolute minimum amount needed for a
|
||||
This pezpallet provides the basic logic needed to pay the absolute minimum amount needed for a
|
||||
transaction to be included. This includes:
|
||||
- _weight fee_: A fee proportional to amount of weight a transaction consumes.
|
||||
- _length fee_: A fee proportional to the encoded length of the transaction.
|
||||
- _tip_: An optional tip. Tip increases the priority of the transaction, giving it a higher
|
||||
chance to be included by the transaction queue.
|
||||
|
||||
Additionally, this pallet allows one to configure:
|
||||
Additionally, this pezpallet allows one to configure:
|
||||
- The mapping between one unit of weight to one unit of fee via [`Config::WeightToFee`].
|
||||
- A means of updating the fee for the next block, via defining a multiplier, based on the
|
||||
final state of the chain at the end of the previous block. This can be configured via
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# pezpallet-asset-conversion-tx-payment
|
||||
|
||||
## Asset Conversion Transaction Payment Pallet
|
||||
## Asset Conversion Transaction Payment Pezpallet
|
||||
|
||||
This pallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
This pezpallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
native token of the chain.
|
||||
|
||||
### Overview
|
||||
@@ -14,8 +14,8 @@ amount by converting the fee calculated by [`pezpallet-transaction-payment`] int
|
||||
asset.
|
||||
|
||||
### Integration
|
||||
This pallet wraps FRAME's transaction payment pallet and functions as a replacement. This means
|
||||
This pezpallet wraps FRAME's transaction payment pezpallet and functions as a replacement. This means
|
||||
you should include both pallets in your `construct_runtime` macro, but only include this
|
||||
pallet's [`TransactionExtension`] ([`ChargeAssetTxPayment`]).
|
||||
pezpallet's [`TransactionExtension`] ([`ChargeAssetTxPayment`]).
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
+3
-3
@@ -15,12 +15,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Benchmarks for Asset Conversion Tx Payment Pallet's transaction extension
|
||||
//! Benchmarks for Asset Conversion Tx Payment Pezpallet's transaction extension
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet;
|
||||
use crate::Pezpallet;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::{
|
||||
dispatch::{DispatchInfo, PostDispatchInfo},
|
||||
@@ -121,5 +121,5 @@ mod benchmarks {
|
||||
}
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
}
|
||||
|
||||
@@ -13,32 +13,32 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! # Asset Conversion Transaction Payment Pallet
|
||||
//! # Asset Conversion Transaction Payment Pezpallet
|
||||
//!
|
||||
//! This pallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
//! This pezpallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
//! chain's native asset.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pallet provides a `TransactionExtension` with an optional `AssetId` that specifies the
|
||||
//! This pezpallet provides a `TransactionExtension` with an optional `AssetId` that specifies the
|
||||
//! asset to be used for payment (defaulting to the native token on `None`). It expects an
|
||||
//! [`OnChargeAssetTransaction`] implementation analogous to [`pezpallet-transaction-payment`]. The
|
||||
//! included [`SwapAssetAdapter`] (implementing [`OnChargeAssetTransaction`]) determines the
|
||||
//! fee amount by converting the fee calculated by [`pezpallet-transaction-payment`] in the native
|
||||
//! asset into the amount required of the specified asset.
|
||||
//!
|
||||
//! ## Pallet API
|
||||
//! ## Pezpallet API
|
||||
//!
|
||||
//! This pallet does not have any dispatchable calls or storage. It wraps FRAME's Transaction
|
||||
//! Payment pallet and functions as a replacement. This means you should include both pallets in
|
||||
//! your `construct_runtime` macro, but only include this pallet's [`TransactionExtension`]
|
||||
//! This pezpallet does not have any dispatchable calls or storage. It wraps FRAME's Transaction
|
||||
//! Payment pezpallet and functions as a replacement. This means you should include both pallets in
|
||||
//! your `construct_runtime` macro, but only include this pezpallet's [`TransactionExtension`]
|
||||
//! ([`ChargeAssetTxPayment`]).
|
||||
//!
|
||||
//! ## Terminology
|
||||
//!
|
||||
//! - Native Asset or Native Currency: The asset that a chain considers native, as in its default
|
||||
//! for transaction fee payment, deposits, inflation, etc.
|
||||
//! - Other assets: Other assets that may exist on chain, for example under the Assets pallet.
|
||||
//! - Other assets: Other assets that may exist on chain, for example under the Assets pezpallet.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -102,13 +102,13 @@ pub enum InitialPayment<T: Config> {
|
||||
Asset((T::AssetId, AssetLiquidityInfoOf<T>)),
|
||||
}
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config + pezpallet_transaction_payment::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
@@ -122,7 +122,7 @@ pub mod pallet {
|
||||
Balance = BalanceOf<Self>,
|
||||
AssetId = Self::AssetId,
|
||||
>;
|
||||
/// The weight information of this pallet.
|
||||
/// The weight information of this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
/// Benchmark helper
|
||||
@@ -133,8 +133,8 @@ pub mod pallet {
|
||||
>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
/// Helper trait to benchmark the `ChargeAssetTxPayment` transaction extension.
|
||||
@@ -146,8 +146,8 @@ pub mod pallet {
|
||||
fn setup_balances_and_pool(asset_id: FunAssetIdParameter, account: AccountId);
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
#[pezpallet::event]
|
||||
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
|
||||
/// has been paid by `who` in an asset `asset_id`.
|
||||
@@ -316,7 +316,7 @@ where
|
||||
return Ok((ValidTransaction::default(), Val::NoCharge, origin));
|
||||
};
|
||||
// Non-mutating call of `compute_fee` to calculate the fee used in the transaction priority.
|
||||
let fee = pezpallet_transaction_payment::Pallet::<T>::compute_fee(len as u32, info, self.tip);
|
||||
let fee = pezpallet_transaction_payment::Pezpallet::<T>::compute_fee(len as u32, info, self.tip);
|
||||
self.can_withdraw_fee(&who, call, info, fee)?;
|
||||
let priority = ChargeTransactionPayment::<T>::get_priority(info, len, self.tip, fee);
|
||||
let validity = ValidTransaction { priority, ..Default::default() };
|
||||
@@ -366,7 +366,7 @@ where
|
||||
let unspent_weight = extension_weight.saturating_sub(actual_ext_weight);
|
||||
let mut actual_post_info = *post_info;
|
||||
actual_post_info.refund(unspent_weight);
|
||||
let actual_fee = pezpallet_transaction_payment::Pallet::<T>::compute_actual_fee(
|
||||
let actual_fee = pezpallet_transaction_payment::Pezpallet::<T>::compute_actual_fee(
|
||||
len as u32,
|
||||
info,
|
||||
&actual_post_info,
|
||||
@@ -380,7 +380,7 @@ where
|
||||
tip,
|
||||
already_withdrawn,
|
||||
)?;
|
||||
pezpallet_transaction_payment::Pallet::<T>::deposit_fee_paid_event(
|
||||
pezpallet_transaction_payment::Pezpallet::<T>::deposit_fee_paid_event(
|
||||
who, actual_fee, tip,
|
||||
);
|
||||
Ok(unspent_weight)
|
||||
@@ -392,7 +392,7 @@ where
|
||||
let unspent_weight = extension_weight.saturating_sub(actual_ext_weight);
|
||||
let mut actual_post_info = *post_info;
|
||||
actual_post_info.refund(unspent_weight);
|
||||
let actual_fee = pezpallet_transaction_payment::Pallet::<T>::compute_actual_fee(
|
||||
let actual_fee = pezpallet_transaction_payment::Pezpallet::<T>::compute_actual_fee(
|
||||
len as u32,
|
||||
info,
|
||||
&actual_post_info,
|
||||
@@ -408,7 +408,7 @@ where
|
||||
already_withdrawn,
|
||||
)?;
|
||||
|
||||
Pallet::<T>::deposit_event(Event::<T>::AssetTxFeePaid {
|
||||
Pezpallet::<T>::deposit_event(Event::<T>::AssetTxFeePaid {
|
||||
who,
|
||||
actual_fee: converted_fee,
|
||||
tip,
|
||||
|
||||
@@ -93,7 +93,7 @@ pub trait OnChargeAssetTransaction<T: Config> {
|
||||
/// - `S`: The swap implementation that can swap assets provided by user for the `A` asset.
|
||||
/// - OU: The handler for withdrawn `fee` and `tip`, passed in the respective order to
|
||||
/// [OnUnbalanced::on_unbalanceds].
|
||||
/// - `T`: The pallet's configuration.
|
||||
/// - `T`: The pezpallet's configuration.
|
||||
pub struct SwapAssetAdapter<A, F, S, OU>(PhantomData<(A, F, S, OU)>);
|
||||
|
||||
impl<A, F, S, OU, T> OnChargeAssetTransaction<T> for SwapAssetAdapter<A, F, S, OU>
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
// frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --extrinsic=*
|
||||
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
|
||||
// --pallet=pezpallet_asset_conversion_tx_payment
|
||||
// --pezpallet=pezpallet_asset_conversion_tx_payment
|
||||
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
|
||||
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/transaction-payment/asset-conversion-tx-payment/src/weights.rs
|
||||
// --wasm-execution=compiled
|
||||
|
||||
@@ -6,7 +6,7 @@ edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "pallet to manage transaction payments in assets"
|
||||
description = "pezpallet to manage transaction payments in assets"
|
||||
readme = "README.md"
|
||||
documentation = "https://docs.rs/pezpallet-asset-tx-payment"
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# pezpallet-asset-tx-payment
|
||||
|
||||
## Asset Transaction Payment Pallet
|
||||
## Asset Transaction Payment Pezpallet
|
||||
|
||||
This pallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
This pezpallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
native token of the chain.
|
||||
|
||||
### Overview
|
||||
@@ -14,8 +14,8 @@ amount by converting the fee calculated by [`pezpallet-transaction-payment`] int
|
||||
asset.
|
||||
|
||||
### Integration
|
||||
This pallet wraps FRAME's transaction payment pallet and functions as a replacement. This means
|
||||
This pezpallet wraps FRAME's transaction payment pezpallet and functions as a replacement. This means
|
||||
you should include both pallets in your `construct_runtime` macro, but only include this
|
||||
pallet's [`TransactionExtension`] ([`ChargeAssetTxPayment`]).
|
||||
pezpallet's [`TransactionExtension`] ([`ChargeAssetTxPayment`]).
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Benchmarks for Asset Tx Payment Pallet's transaction extension
|
||||
//! Benchmarks for Asset Tx Payment Pezpallet's transaction extension
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet;
|
||||
use crate::Pezpallet;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::{
|
||||
dispatch::{DispatchInfo, PostDispatchInfo},
|
||||
@@ -127,5 +127,5 @@ mod benchmarks {
|
||||
}
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! # Asset Transaction Payment Pallet
|
||||
//! # Asset Transaction Payment Pezpallet
|
||||
//!
|
||||
//! This pallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
//! This pezpallet allows runtimes that include it to pay for transactions in assets other than the
|
||||
//! main token of the chain.
|
||||
//!
|
||||
//! ## Overview
|
||||
@@ -29,9 +29,9 @@
|
||||
//!
|
||||
//! ## Integration
|
||||
|
||||
//! This pallet wraps FRAME's transaction payment pallet and functions as a replacement. This means
|
||||
//! This pezpallet wraps FRAME's transaction payment pezpallet and functions as a replacement. This means
|
||||
//! you should include both pallets in your `construct_runtime` macro, but only include this
|
||||
//! pallet's [`TransactionExtension`] ([`ChargeAssetTxPayment`]).
|
||||
//! pezpallet's [`TransactionExtension`] ([`ChargeAssetTxPayment`]).
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -112,13 +112,13 @@ pub enum InitialPayment<T: Config> {
|
||||
Asset(Credit<T::AccountId, T::Fungibles>),
|
||||
}
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config + pezpallet_transaction_payment::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
@@ -127,7 +127,7 @@ pub mod pallet {
|
||||
type Fungibles: Balanced<Self::AccountId>;
|
||||
/// The actual transaction charging logic that charges the fees.
|
||||
type OnChargeAssetTransaction: OnChargeAssetTransaction<Self>;
|
||||
/// The weight information of this pallet.
|
||||
/// The weight information of this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
/// Benchmark helper
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -138,8 +138,8 @@ pub mod pallet {
|
||||
>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
/// Helper trait to benchmark the `ChargeAssetTxPayment` transaction extension.
|
||||
@@ -151,8 +151,8 @@ pub mod pallet {
|
||||
fn setup_balances_and_pool(asset_id: FunAssetIdParameter, account: AccountId);
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
#[pezpallet::event]
|
||||
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
|
||||
/// has been paid by `who` in an asset `asset_id`.
|
||||
@@ -335,7 +335,7 @@ where
|
||||
return Ok((ValidTransaction::default(), Val::NoCharge, origin));
|
||||
};
|
||||
// Non-mutating call of `compute_fee` to calculate the fee used in the transaction priority.
|
||||
let fee = pezpallet_transaction_payment::Pallet::<T>::compute_fee(len as u32, info, self.tip);
|
||||
let fee = pezpallet_transaction_payment::Pezpallet::<T>::compute_fee(len as u32, info, self.tip);
|
||||
self.can_withdraw_fee(&who, call, info, fee)?;
|
||||
let priority = ChargeTransactionPayment::<T>::get_priority(info, len, self.tip, fee);
|
||||
let val = Val::Charge { tip: self.tip, who: who.clone(), fee };
|
||||
@@ -405,7 +405,7 @@ where
|
||||
let unspent_weight = extension_weight.saturating_sub(actual_ext_weight);
|
||||
let mut actual_post_info = *post_info;
|
||||
actual_post_info.refund(unspent_weight);
|
||||
let actual_fee = pezpallet_transaction_payment::Pallet::<T>::compute_actual_fee(
|
||||
let actual_fee = pezpallet_transaction_payment::Pezpallet::<T>::compute_actual_fee(
|
||||
len as u32,
|
||||
info,
|
||||
&actual_post_info,
|
||||
@@ -421,7 +421,7 @@ where
|
||||
tip.into(),
|
||||
already_withdrawn.into(),
|
||||
)?;
|
||||
Pallet::<T>::deposit_event(Event::<T>::AssetTxFeePaid {
|
||||
Pezpallet::<T>::deposit_event(Event::<T>::AssetTxFeePaid {
|
||||
who,
|
||||
actual_fee: converted_fee,
|
||||
tip: converted_tip,
|
||||
|
||||
@@ -170,7 +170,7 @@ impl pezpallet_authorship::Config for Runtime {
|
||||
pub struct CreditToBlockAuthor;
|
||||
impl HandleCredit<AccountId, Assets> for CreditToBlockAuthor {
|
||||
fn handle_credit(credit: Credit<AccountId, Assets>) {
|
||||
if let Some(author) = pezpallet_authorship::Pallet::<Runtime>::author() {
|
||||
if let Some(author) = pezpallet_authorship::Pezpallet::<Runtime>::author() {
|
||||
// What to do in case paying the author fails (e.g. because `fee < min_balance`)
|
||||
// default: drop the result which will trigger the `OnDrop` of the imbalance.
|
||||
let _ = <Assets as Balanced<AccountId>>::resolve(&author, credit);
|
||||
|
||||
@@ -95,7 +95,7 @@ pub trait OnChargeAssetTransaction<T: Config> {
|
||||
/// Allows specifying what to do with the withdrawn asset fees.
|
||||
pub trait HandleCredit<AccountId, B: Balanced<AccountId>> {
|
||||
/// Implement to determine what to do with the withdrawn asset fees.
|
||||
/// Default for `CreditOf` from the assets pallet is to burn and
|
||||
/// Default for `CreditOf` from the assets pezpallet is to burn and
|
||||
/// decrease total issuance.
|
||||
fn handle_credit(credit: Credit<AccountId, B>);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ impl<A, B: Balanced<A>> HandleCredit<A, B> for () {
|
||||
/// The credit handler is given the complete fee in terms of the asset used for the transaction.
|
||||
pub struct FungiblesAdapter<CON, HC>(PhantomData<(CON, HC)>);
|
||||
|
||||
/// Default implementation for a runtime instantiating this pallet, a balance to asset converter and
|
||||
/// Default implementation for a runtime instantiating this pezpallet, a balance to asset converter and
|
||||
/// a credit handler.
|
||||
impl<T, CON, HC> OnChargeAssetTransaction<T> for FungiblesAdapter<CON, HC>
|
||||
where
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
// Executed Command:
|
||||
// ./target/production/bizinikiwi-node
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=pezpallet_asset_tx_payment
|
||||
// --pezpallet=pezpallet_asset_tx_payment
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
|
||||
@@ -6,7 +6,7 @@ edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "RPC interface for the transaction payment pallet."
|
||||
description = "RPC interface for the transaction payment pezpallet."
|
||||
readme = "README.md"
|
||||
documentation = "https://docs.rs/pezpallet-transaction-payment-rpc"
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
RPC interface for the transaction payment pallet.
|
||||
RPC interface for the transaction payment pezpallet.
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
@@ -6,7 +6,7 @@ edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "RPC runtime API for transaction payment FRAME pallet"
|
||||
description = "RPC runtime API for transaction payment FRAME pezpallet"
|
||||
readme = "README.md"
|
||||
documentation = "https://docs.rs/pezpallet-transaction-payment-rpc-runtime-api"
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Runtime API definition for transaction payment pallet.
|
||||
Runtime API definition for transaction payment pezpallet.
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Runtime API definition for transaction payment pallet.
|
||||
//! Runtime API definition for transaction payment pezpallet.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! RPC interface for the transaction payment pallet.
|
||||
//! RPC interface for the transaction payment pezpallet.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//! # Skip Feeless Payment Pallet
|
||||
//! # Skip Feeless Payment Pezpallet
|
||||
//!
|
||||
//! This pallet allows runtimes that include it to skip payment of transaction fees for
|
||||
//! This pezpallet allows runtimes that include it to skip payment of transaction fees for
|
||||
//! dispatchables marked by
|
||||
//! [`#[pallet::feeless_if]`](pezframe_support::pezpallet_prelude::feeless_if).
|
||||
//! [`#[pezpallet::feeless_if]`](pezframe_support::pezpallet_prelude::feeless_if).
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
@@ -29,9 +29,9 @@
|
||||
//!
|
||||
//! ## Integration
|
||||
//!
|
||||
//! This pallet wraps an existing transaction payment pallet. This means you should both pallets
|
||||
//! This pezpallet wraps an existing transaction payment pezpallet. This means you should both pallets
|
||||
//! in your [`construct_runtime`](pezframe_support::construct_runtime) macro and
|
||||
//! include this pallet's [`TransactionExtension`] ([`SkipCheckIfFeeless`]) that would accept the
|
||||
//! include this pezpallet's [`TransactionExtension`] ([`SkipCheckIfFeeless`]) that would accept the
|
||||
//! existing one as an argument.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
@@ -59,24 +59,24 @@ mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
#[pezpallet::event]
|
||||
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A transaction fee was skipped.
|
||||
FeeSkipped { origin: <T::RuntimeOrigin as OriginTrait>::PalletsOrigin },
|
||||
@@ -198,7 +198,7 @@ where
|
||||
match pre {
|
||||
Apply(pre) => S::post_dispatch_details(pre, info, post_info, len, result),
|
||||
Skip(origin) => {
|
||||
Pallet::<T>::deposit_event(Event::<T>::FeeSkipped { origin });
|
||||
Pezpallet::<T>::deposit_event(Event::<T>::FeeSkipped { origin });
|
||||
Ok(Weight::zero())
|
||||
},
|
||||
}
|
||||
|
||||
@@ -79,23 +79,23 @@ impl TransactionExtension<RuntimeCall> for DummyExtension {
|
||||
}
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet(dev_mode)]
|
||||
#[pezframe_support::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_dummy {
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::feeless_if(|_origin: &OriginFor<T>, data: &u32| -> bool {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
#[pezpallet::feeless_if(|_origin: &OriginFor<T>, data: &u32| -> bool {
|
||||
*data == 0
|
||||
})]
|
||||
pub fn aux(_origin: OriginFor<T>, #[pallet::compact] _data: u32) -> DispatchResult {
|
||||
pub fn aux(_origin: OriginFor<T>, #[pezpallet::compact] _data: u32) -> DispatchResult {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,19 +15,19 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Benchmarks for Transaction Payment Pallet's transaction extension
|
||||
//! Benchmarks for Transaction Payment Pezpallet's transaction extension
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet;
|
||||
use crate::Pezpallet;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::dispatch::{DispatchInfo, PostDispatchInfo};
|
||||
use pezframe_system::{EventRecord, RawOrigin};
|
||||
use pezsp_runtime::traits::{AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable};
|
||||
|
||||
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
|
||||
let events = pezframe_system::Pallet::<T>::events();
|
||||
let events = pezframe_system::Pezpallet::<T>::events();
|
||||
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
|
||||
// compare to the last event record
|
||||
let EventRecord { event, .. } = &events[events.len() - 1];
|
||||
@@ -49,7 +49,7 @@ mod benchmarks {
|
||||
<T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance();
|
||||
|
||||
let (amount_to_endow, tip) = if existential_deposit.is_zero() {
|
||||
let min_tip: <<T as pallet::Config>::OnChargeTransaction as payment::OnChargeTransaction<T>>::Balance = 1_000_000_000u32.into();
|
||||
let min_tip: <<T as pezpallet::Config>::OnChargeTransaction as payment::OnChargeTransaction<T>>::Balance = 1_000_000_000u32.into();
|
||||
(min_tip * 1000u32.into(), min_tip)
|
||||
} else {
|
||||
(existential_deposit * 1000u32.into(), existential_deposit)
|
||||
@@ -83,11 +83,11 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
post_info.actual_weight.as_mut().map(|w| w.saturating_accrue(extension_weight));
|
||||
let actual_fee = Pallet::<T>::compute_actual_fee(10, &info, &post_info, tip);
|
||||
let actual_fee = Pezpallet::<T>::compute_actual_fee(10, &info, &post_info, tip);
|
||||
assert_last_event::<T>(
|
||||
Event::<T>::TransactionFeePaid { who: caller, actual_fee, tip }.into(),
|
||||
);
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! # Transaction Payment Pallet
|
||||
//! # Transaction Payment Pezpallet
|
||||
//!
|
||||
//! This pallet provides the basic logic needed to pay the absolute minimum amount needed for a
|
||||
//! This pezpallet provides the basic logic needed to pay the absolute minimum amount needed for a
|
||||
//! transaction to be included. This includes:
|
||||
//! - _base fee_: This is the minimum amount a user pays for a transaction. It is declared
|
||||
//! as a base _weight_ in the runtime and converted to a fee using `WeightToFee`.
|
||||
@@ -38,7 +38,7 @@
|
||||
//! - `targeted_fee_adjustment`: This is a multiplier that can tune the final fee based on
|
||||
//! the congestion of the network.
|
||||
//!
|
||||
//! Additionally, this pallet allows one to configure:
|
||||
//! Additionally, this pezpallet allows one to configure:
|
||||
//! - The mapping between one unit of weight to one unit of fee via [`Config::WeightToFee`].
|
||||
//! - A means of updating the fee for the next block, via defining a multiplier, based on the
|
||||
//! final state of the chain at the end of the previous block. This can be configured via
|
||||
@@ -59,7 +59,7 @@ use pezframe_support::{
|
||||
weights::{Weight, WeightToFee},
|
||||
RuntimeDebugNoBound,
|
||||
};
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub use payment::*;
|
||||
use pezsp_runtime::{
|
||||
traits::{
|
||||
@@ -96,7 +96,7 @@ const LOG_TARGET: &str = "runtime::txpayment";
|
||||
/// A struct to update the weight multiplier per block. It implements `Convert<Multiplier,
|
||||
/// Multiplier>`, meaning that it can convert the previous multiplier to the next one. This should
|
||||
/// be called on `on_finalize` of a block, prior to potentially cleaning the weight data from the
|
||||
/// system pallet.
|
||||
/// system pezpallet.
|
||||
///
|
||||
/// given:
|
||||
/// s = previous block weight
|
||||
@@ -216,7 +216,7 @@ where
|
||||
// the computed ratio is only among the normal class.
|
||||
let normal_max_weight =
|
||||
weights.get(DispatchClass::Normal).max_total.unwrap_or(weights.max_block);
|
||||
let current_block_weight = pezframe_system::Pallet::<T>::block_weight();
|
||||
let current_block_weight = pezframe_system::Pezpallet::<T>::block_weight();
|
||||
let normal_block_weight =
|
||||
current_block_weight.get(DispatchClass::Normal).min(normal_max_weight);
|
||||
|
||||
@@ -298,10 +298,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Storage releases of the pallet.
|
||||
/// Storage releases of the pezpallet.
|
||||
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
pub enum Releases {
|
||||
/// Original version of the pallet.
|
||||
/// Original version of the pezpallet.
|
||||
V1Ancient,
|
||||
/// One that bumps the usage to FixedU128 from FixedI128.
|
||||
V2,
|
||||
@@ -317,15 +317,15 @@ impl Default for Releases {
|
||||
/// NextFeeMultiplierOnEmpty() to provide a value when none exists in storage.
|
||||
const MULTIPLIER_DEFAULT_VALUE: Multiplier = Multiplier::from_u32(1);
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
pub mod config_preludes {
|
||||
use super::*;
|
||||
@@ -347,10 +347,10 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::config(with_default)]
|
||||
#[pezpallet::config(with_default)]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[pallet::no_default_bounds]
|
||||
#[pezpallet::no_default_bounds]
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
@@ -360,15 +360,15 @@ pub mod pallet {
|
||||
/// adjusted, depending on the used resources by the transaction. If the
|
||||
/// transaction weight is lower than expected, parts of the transaction fee
|
||||
/// might be refunded. In the end the fees can be deposited.
|
||||
#[pallet::no_default]
|
||||
#[pezpallet::no_default]
|
||||
type OnChargeTransaction: OnChargeTransaction<Self>;
|
||||
|
||||
/// Convert a weight value into a deductible fee based on the currency type.
|
||||
#[pallet::no_default]
|
||||
#[pezpallet::no_default]
|
||||
type WeightToFee: WeightToFee<Balance = BalanceOf<Self>>;
|
||||
|
||||
/// Convert a length value into a deductible fee based on the currency type.
|
||||
#[pallet::no_default]
|
||||
#[pezpallet::no_default]
|
||||
type LengthToFee: WeightToFee<Balance = BalanceOf<Self>>;
|
||||
|
||||
/// Update the multiplier of the next block, based on the previous block's weight.
|
||||
@@ -395,34 +395,34 @@ pub mod pallet {
|
||||
/// sent with the transaction. So, not only does the transaction get a priority bump based
|
||||
/// on the `inclusion_fee`, but we also amplify the impact of tips applied to `Operational`
|
||||
/// transactions.
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type OperationalFeeMultiplier: Get<u8>;
|
||||
|
||||
/// The weight information of this pallet.
|
||||
/// The weight information of this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
#[pallet::type_value]
|
||||
#[pezpallet::type_value]
|
||||
pub fn NextFeeMultiplierOnEmpty() -> Multiplier {
|
||||
MULTIPLIER_DEFAULT_VALUE
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::whitelist_storage]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::whitelist_storage]
|
||||
pub type NextFeeMultiplier<T: Config> =
|
||||
StorageValue<_, Multiplier, ValueQuery, NextFeeMultiplierOnEmpty>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type StorageVersion<T: Config> = StorageValue<_, Releases, ValueQuery>;
|
||||
|
||||
/// The `OnChargeTransaction` stores the withdrawn tx fee here.
|
||||
///
|
||||
/// Use `withdraw_txfee` and `remaining_txfee` to access from outside the crate.
|
||||
#[pallet::storage]
|
||||
#[pallet::whitelist_storage]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::whitelist_storage]
|
||||
pub(crate) type TxPaymentCredit<T: Config> = StorageValue<_, StoredCreditOf<T>>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub multiplier: Multiplier,
|
||||
#[serde(skip)]
|
||||
@@ -435,7 +435,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
StorageVersion::<T>::put(Releases::V2);
|
||||
@@ -443,16 +443,16 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
#[pezpallet::event]
|
||||
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
|
||||
/// has been paid by `who`.
|
||||
TransactionFeePaid { who: T::AccountId, actual_fee: BalanceOf<T>, tip: BalanceOf<T> },
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
fn on_finalize(_: pezframe_system::pezpallet_prelude::BlockNumberFor<T>) {
|
||||
NextFeeMultiplier::<T>::mutate(|fm| {
|
||||
*fm = T::FeeMultiplierUpdate::convert(*fm);
|
||||
@@ -484,7 +484,7 @@ pub mod pallet {
|
||||
let target = T::FeeMultiplierUpdate::target() *
|
||||
T::BlockWeights::get().get(DispatchClass::Normal).max_total.expect(
|
||||
"Setting `max_total` for `Normal` dispatch class is not compatible with \
|
||||
`transaction-payment` pallet.",
|
||||
`transaction-payment` pezpallet.",
|
||||
);
|
||||
// add 1 percent;
|
||||
let addition = target / 100;
|
||||
@@ -501,7 +501,7 @@ pub mod pallet {
|
||||
let min_value = T::FeeMultiplierUpdate::min();
|
||||
let target = target + addition;
|
||||
|
||||
pezframe_system::Pallet::<T>::set_block_consumed_resources(target, 0);
|
||||
pezframe_system::Pezpallet::<T>::set_block_consumed_resources(target, 0);
|
||||
let next = T::FeeMultiplierUpdate::convert(min_value);
|
||||
assert!(
|
||||
next > min_value,
|
||||
@@ -513,7 +513,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Public function to access the next fee multiplier.
|
||||
pub fn next_fee_multiplier() -> Multiplier {
|
||||
NextFeeMultiplier::<T>::get()
|
||||
@@ -521,7 +521,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// Query the data that we know about the fee of a given `call`.
|
||||
///
|
||||
/// This pallet is not and cannot be aware of the internals of a signed extension, for example
|
||||
/// This pezpallet is not and cannot be aware of the internals of a signed extension, for example
|
||||
/// a tip. It only interprets the extrinsic as some encoded value and accounts for its weight
|
||||
/// and length, the runtime's extrinsic base weight, and the current fee multiplier.
|
||||
///
|
||||
@@ -715,12 +715,12 @@ impl<T: Config> Pallet<T> {
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This is only useful if a pallet knows that the pre-dispatch weight was vastly
|
||||
/// This is only useful if a pezpallet knows that the pre-dispatch weight was vastly
|
||||
/// overestimated. Pallets need to make sure to leave enough balance to pay for the
|
||||
/// transaction fees. They can do that by first drawing as much as they need and then
|
||||
/// at the end of the transaction (when they know the post dispatch fee) return an error
|
||||
/// in case not enough is left. The error will automatically roll back all the storage
|
||||
/// changes done by the pallet including the balance drawn by calling this function.
|
||||
/// changes done by the pezpallet including the balance drawn by calling this function.
|
||||
pub fn withdraw_txfee<Balance>(amount: Balance) -> Option<CreditOf<T>>
|
||||
where
|
||||
CreditOf<T>: Imbalance<Balance>,
|
||||
@@ -765,7 +765,7 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Convert<Weight, BalanceOf<T>> for Pallet<T>
|
||||
impl<T> Convert<Weight, BalanceOf<T>> for Pezpallet<T>
|
||||
where
|
||||
T: Config,
|
||||
{
|
||||
@@ -841,7 +841,7 @@ where
|
||||
len: usize,
|
||||
) -> Result<BalanceOf<T>, TransactionValidityError> {
|
||||
let tip = self.0;
|
||||
let fee_with_tip = Pallet::<T>::compute_fee(len as u32, info, tip);
|
||||
let fee_with_tip = Pezpallet::<T>::compute_fee(len as u32, info, tip);
|
||||
|
||||
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::can_withdraw_fee(
|
||||
who,
|
||||
@@ -1062,7 +1062,7 @@ where
|
||||
},
|
||||
};
|
||||
let actual_fee_with_tip =
|
||||
Pallet::<T>::compute_actual_fee(len as u32, info, &post_info, tip);
|
||||
Pezpallet::<T>::compute_actual_fee(len as u32, info, &post_info, tip);
|
||||
T::OnChargeTransaction::correct_and_deposit_fee(
|
||||
&who,
|
||||
info,
|
||||
@@ -1071,7 +1071,7 @@ where
|
||||
tip,
|
||||
liquidity_info,
|
||||
)?;
|
||||
Pallet::<T>::deposit_event(Event::<T>::TransactionFeePaid {
|
||||
Pezpallet::<T>::deposit_event(Event::<T>::TransactionFeePaid {
|
||||
who,
|
||||
actual_fee: actual_fee_with_tip,
|
||||
tip,
|
||||
@@ -1081,7 +1081,7 @@ where
|
||||
}
|
||||
|
||||
impl<T: Config, AnyCall: GetDispatchInfo + Encode> EstimateCallFee<AnyCall, BalanceOf<T>>
|
||||
for Pallet<T>
|
||||
for Pezpallet<T>
|
||||
where
|
||||
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ pezframe_support::construct_runtime!(
|
||||
{
|
||||
System: system,
|
||||
Balances: pezpallet_balances,
|
||||
TransactionPayment: pezpallet_transaction_payment::{Pallet, Storage, Event<T>},
|
||||
TransactionPayment: pezpallet_transaction_payment::{Pezpallet, Storage, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
/// ! Traits and default implementation for paying transaction fees.
|
||||
use crate::{Config, Pallet, TxPaymentCredit, LOG_TARGET};
|
||||
use crate::{Config, Pezpallet, TxPaymentCredit, LOG_TARGET};
|
||||
|
||||
use codec::{DecodeWithMemTracking, FullCodec, MaxEncodedLen};
|
||||
use core::marker::PhantomData;
|
||||
@@ -94,7 +94,7 @@ pub trait OnChargeTransaction<T: Config>: TxCreditHold<T> {
|
||||
pub trait TxCreditHold<T: Config> {
|
||||
/// The credit that is used to represent the withdrawn transaction fees.
|
||||
///
|
||||
/// The pallet will put this into a temporary storage item in order to
|
||||
/// The pezpallet will put this into a temporary storage item in order to
|
||||
/// make it available to other pallets during tx application.
|
||||
///
|
||||
/// Is only used within a transaction. Hence changes to the encoding of this
|
||||
@@ -104,7 +104,7 @@ pub trait TxCreditHold<T: Config> {
|
||||
type Credit: FullCodec + DecodeWithMemTracking + MaxEncodedLen + TypeInfo + SuppressedDrop;
|
||||
}
|
||||
|
||||
/// Implements transaction payment for a pallet implementing the [`pezframe_support::traits::fungible`]
|
||||
/// Implements transaction payment for a pezpallet implementing the [`pezframe_support::traits::fungible`]
|
||||
/// trait (eg. pezpallet_balances) using an unbalance handler (implementing
|
||||
/// [`OnUnbalanced`]).
|
||||
///
|
||||
@@ -144,7 +144,7 @@ where
|
||||
|
||||
let (tip_credit, inclusion_fee) = credit.split(tip);
|
||||
|
||||
<Pallet<T>>::deposit_txfee(inclusion_fee);
|
||||
<Pezpallet<T>>::deposit_txfee(inclusion_fee);
|
||||
|
||||
Ok(Some(tip_credit))
|
||||
}
|
||||
@@ -188,7 +188,7 @@ where
|
||||
}
|
||||
|
||||
// skip refund if account was killed by the tx
|
||||
let fee_credit = if pezframe_system::Pallet::<T>::account_exists(who) {
|
||||
let fee_credit = if pezframe_system::Pezpallet::<T>::account_exists(who) {
|
||||
let (mut fee_credit, refund_credit) = remaining_credit.split(corrected_fee);
|
||||
// resolve might fail if refund is below the ed and account
|
||||
// is kept alive by other providers
|
||||
@@ -226,7 +226,7 @@ where
|
||||
type Credit = NoDrop<Credit<<T as pezframe_system::Config>::AccountId, F>>;
|
||||
}
|
||||
|
||||
/// Implements the transaction payment for a pallet implementing the [`Currency`]
|
||||
/// Implements the transaction payment for a pezpallet implementing the [`Currency`]
|
||||
/// trait (eg. the pezpallet_balances) using an unbalance handler (implementing
|
||||
/// [`OnUnbalanced`]).
|
||||
///
|
||||
|
||||
@@ -105,7 +105,7 @@ impl ExtBuilder {
|
||||
.unwrap();
|
||||
|
||||
if let Some(multiplier) = self.initial_multiplier {
|
||||
pallet::GenesisConfig::<Runtime> { multiplier, ..Default::default() }
|
||||
pezpallet::GenesisConfig::<Runtime> { multiplier, ..Default::default() }
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
}
|
||||
@@ -401,7 +401,7 @@ fn compute_fee_works_without_multiplier() {
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::No,
|
||||
};
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(0, &dispatch_info, 10), 10);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(0, &dispatch_info, 10), 10);
|
||||
// No tip, only base fee works
|
||||
let dispatch_info = DispatchInfo {
|
||||
call_weight: Weight::from_parts(0, 0),
|
||||
@@ -409,11 +409,11 @@ fn compute_fee_works_without_multiplier() {
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::Yes,
|
||||
};
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 100);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 100);
|
||||
// Tip + base fee works
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(0, &dispatch_info, 69), 169);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(0, &dispatch_info, 69), 169);
|
||||
// Len (byte fee) + base fee works
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(42, &dispatch_info, 0), 520);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(42, &dispatch_info, 0), 520);
|
||||
// Weight fee + base fee works
|
||||
let dispatch_info = DispatchInfo {
|
||||
call_weight: Weight::from_parts(1000, 0),
|
||||
@@ -421,7 +421,7 @@ fn compute_fee_works_without_multiplier() {
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::Yes,
|
||||
};
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 1100);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 1100);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ fn compute_fee_works_with_multiplier() {
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::Yes,
|
||||
};
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 100);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 100);
|
||||
|
||||
// Everything works together :)
|
||||
let dispatch_info = DispatchInfo {
|
||||
@@ -453,7 +453,7 @@ fn compute_fee_works_with_multiplier() {
|
||||
};
|
||||
// 123 weight, 456 length, 100 base
|
||||
assert_eq!(
|
||||
Pallet::<Runtime>::compute_fee(456, &dispatch_info, 789),
|
||||
Pezpallet::<Runtime>::compute_fee(456, &dispatch_info, 789),
|
||||
100 + (3 * 123 / 2) + 4560 + 789,
|
||||
);
|
||||
});
|
||||
@@ -477,7 +477,7 @@ fn compute_fee_works_with_negative_multiplier() {
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::Yes,
|
||||
};
|
||||
assert_eq!(Pallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 100);
|
||||
assert_eq!(Pezpallet::<Runtime>::compute_fee(0, &dispatch_info, 0), 100);
|
||||
|
||||
// Everything works together.
|
||||
let dispatch_info = DispatchInfo {
|
||||
@@ -488,7 +488,7 @@ fn compute_fee_works_with_negative_multiplier() {
|
||||
};
|
||||
// 123 weight, 456 length, 100 base
|
||||
assert_eq!(
|
||||
Pallet::<Runtime>::compute_fee(456, &dispatch_info, 789),
|
||||
Pezpallet::<Runtime>::compute_fee(456, &dispatch_info, 789),
|
||||
100 + (123 / 2) + 4560 + 789,
|
||||
);
|
||||
});
|
||||
@@ -510,7 +510,7 @@ fn compute_fee_does_not_overflow() {
|
||||
pays_fee: Pays::Yes,
|
||||
};
|
||||
assert_eq!(
|
||||
Pallet::<Runtime>::compute_fee(u32::MAX, &dispatch_info, u64::MAX),
|
||||
Pezpallet::<Runtime>::compute_fee(u32::MAX, &dispatch_info, u64::MAX),
|
||||
u64::MAX
|
||||
);
|
||||
});
|
||||
@@ -640,7 +640,7 @@ fn refund_consistent_with_actual_weight() {
|
||||
|
||||
let refund_based_fee = prev_balance - Balances::free_balance(2);
|
||||
let actual_fee =
|
||||
Pallet::<Runtime>::compute_actual_fee(len as u32, &info, &actual_post_info, tip);
|
||||
Pezpallet::<Runtime>::compute_actual_fee(len as u32, &info, &actual_post_info, tip);
|
||||
|
||||
// 33 call weight, 10 ext weight, 10 length, 7 base, 5 tip
|
||||
assert_eq!(actual_fee, 7 + 10 + ((33 + 10) * 5 / 4) + 5);
|
||||
@@ -814,7 +814,7 @@ fn post_info_can_change_pays_fee() {
|
||||
|
||||
let refund_based_fee = prev_balance - Balances::free_balance(2);
|
||||
let actual_fee =
|
||||
Pallet::<Runtime>::compute_actual_fee(len as u32, &info, &post_info, tip);
|
||||
Pezpallet::<Runtime>::compute_actual_fee(len as u32, &info, &post_info, tip);
|
||||
|
||||
// Only 5 tip is paid
|
||||
assert_eq!(actual_fee, 5);
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
// frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --extrinsic=*
|
||||
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
|
||||
// --pallet=pezpallet_transaction_payment
|
||||
// --pezpallet=pezpallet_transaction_payment
|
||||
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
|
||||
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/transaction-payment/src/weights.rs
|
||||
// --wasm-execution=compiled
|
||||
|
||||
Reference in New Issue
Block a user