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:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example authorization transaction extension pallet"
description = "FRAME example authorization transaction extension pezpallet"
publish = false
documentation = "https://docs.rs/pezpallet-example-authorization-tx-extension"
@@ -126,7 +126,7 @@ where
let local_origin = Origin::Coowners(first_account, second_account);
// Turn it into a local `PalletsOrigin`.
let local_origin = <T as Config>::PalletsOrigin::from(local_origin);
// Then finally into a pallet `RuntimeOrigin`.
// Then finally into a pezpallet `RuntimeOrigin`.
let local_origin = <T as Config>::RuntimeOrigin::from(local_origin);
// Which the `set_caller_from` function will convert into the overarching `RuntimeOrigin`
// created by `construct_runtime!`.
@@ -21,9 +21,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Authorization Transaction Extension Example Pallet
//! # Authorization Transaction Extension Example Pezpallet
//!
//! **This pallet serves as an example and is not meant to be used in production.**
//! **This pezpallet serves as an example and is not meant to be used in production.**
//!
//! FRAME Transaction Extension reference implementation, origin mutation, origin authorization and
//! integration in a `TransactionExtension` pipeline.
@@ -31,7 +31,7 @@
//! The [TransactionExtension](pezsp_runtime::traits::TransactionExtension) used in this example is
//! [AuthorizeCoownership](extensions::AuthorizeCoownership). If activated, the extension will
//! authorize 2 signers as coowners, with a [coowner origin](pezpallet_coownership::Origin) specific to
//! the [coownership example pallet](pezpallet_coownership), by validating a signature of the rest of
//! the [coownership example pezpallet](pezpallet_coownership), by validating a signature of the rest of
//! the transaction from each party. This means any extensions after ours in the pipeline, their
//! implicits and the actual call. The extension pipeline used in our example checks the genesis
//! hash, transaction version and mortality of the transaction after the `AuthorizeCoownership` runs
@@ -41,7 +41,7 @@
//! In this example, aside from the [AuthorizeCoownership](extensions::AuthorizeCoownership)
//! extension, we use the following pallets:
//! - [pezpallet_coownership] - provides a coowner origin and the functionality to authorize it.
//! - [pezpallet_assets] - a dummy asset pallet that tracks assets, identified by an
//! - [pezpallet_assets] - a dummy asset pezpallet that tracks assets, identified by an
//! [AssetId](pezpallet_assets::AssetId), and their respective owners, which can be either an
//! [account](pezpallet_assets::Owner::Single) or a [pair of owners](pezpallet_assets::Owner::Double).
//!
@@ -56,7 +56,7 @@
//! ### Example usage
#![doc = docify::embed!("src/tests.rs", create_coowned_asset_works)]
//!
//! This example does not focus on any pallet logic or syntax, but rather on `TransactionExtension`
//! This example does not focus on any pezpallet logic or syntax, but rather on `TransactionExtension`
//! functionality. The pallets used are just skeletons to provide storage state and custom origin
//! choices and requirements, as shown in the examples. Any weight and/or
//! transaction fee is out of scope for this example.
@@ -75,12 +75,12 @@ extern crate alloc;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pezframe_support::pallet(dev_mode)]
#[pezframe_support::pezpallet(dev_mode)]
pub mod pezpallet_coownership {
use super::*;
use pezframe_support::traits::OriginTrait;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The aggregated origin which the dispatch will take.
type RuntimeOrigin: OriginTrait<PalletsOrigin = Self::PalletsOrigin>
@@ -91,12 +91,12 @@ pub mod pezpallet_coownership {
type PalletsOrigin: From<Origin<Self>> + TryInto<Origin<Self>, Error = Self::PalletsOrigin>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// Origin that this pallet can authorize. For the purposes of this example, it's just two
/// Origin that this pezpallet can authorize. For the purposes of this example, it's just two
/// accounts that own something together.
#[pallet::origin]
#[pezpallet::origin]
#[derive(
Clone,
PartialEq,
@@ -113,7 +113,7 @@ pub mod pezpallet_coownership {
}
}
#[pezframe_support::pallet(dev_mode)]
#[pezframe_support::pezpallet(dev_mode)]
pub mod pezpallet_assets {
use super::*;
@@ -126,7 +126,7 @@ pub mod pezpallet_assets {
Double(AccountId, AccountId),
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Type that can authorize an account pair coowner origin.
type CoownerOrigin: EnsureOrigin<
@@ -136,26 +136,26 @@ pub mod pezpallet_assets {
}
/// Map that holds the owner information for each asset it manages.
#[pallet::storage]
#[pezpallet::storage]
pub type AssetOwners<T> =
StorageMap<_, Blake2_128Concat, AssetId, Owner<<T as pezframe_system::Config>::AccountId>>;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Asset already exists.
AlreadyExists,
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Simple call that just creates an asset with a specific `AssetId`. This call will fail if
/// there is already an asset with the same `AssetId`.
///
/// The origin is either a single account (traditionally signed origin) or a coowner origin.
#[pallet::call_index(0)]
#[pezpallet::call_index(0)]
pub fn create_asset(origin: OriginFor<T>, asset_id: AssetId) -> DispatchResult {
let owner: Owner<T::AccountId> = match T::CoownerOrigin::try_origin(origin) {
Ok((first, second)) => Owner::Double(first, second),
@@ -65,7 +65,7 @@ mod example_runtime {
pub type Signature = MultiSignature;
pub type BlockNumber = u32;
// For testing the pallet, we construct a mock runtime.
// For testing the pezpallet, we construct a mock runtime.
pezframe_support::construct_runtime!(
pub enum Runtime
{
@@ -92,7 +92,7 @@ mod example_runtime {
type BenchmarkHelper = ();
}
/// Type that enables any pallet to ask for a coowner origin.
/// Type that enables any pezpallet to ask for a coowner origin.
pub struct EnsureCoowner;
impl EnsureOrigin<RuntimeOrigin> for EnsureCoowner {
type Success = (AccountId, AccountId);
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet"
description = "FRAME example pezpallet"
readme = "README.md"
publish = false
documentation = "https://docs.rs/pezpallet-example-basic"
+31 -31
View File
@@ -1,13 +1,13 @@
<!-- markdown-link-check-disable -->
# Basic Example Pallet
# Basic Example Pezpallet
<!-- Original author of paragraph: @gavofyork -->
The Example: A simple example of a FRAME pallet demonstrating
The Example: A simple example of a FRAME pezpallet demonstrating
concepts, APIs and structures common to most FRAME runtimes.
Run `cargo doc --package pezpallet-example-basic --open` to view this pallet's documentation.
Run `cargo doc --package pezpallet-example-basic --open` to view this pezpallet's documentation.
**This pallet serves as an example and is not meant to be used in production.**
**This pezpallet serves as an example and is not meant to be used in production.**
## Documentation Guidelines
@@ -15,8 +15,8 @@ Run `cargo doc --package pezpallet-example-basic --open` to view this pallet's d
<!-- label 'S3-FRAME' -->
<ul>
<li>Documentation comments (i.e. <code>/// comment</code>) - should
accompany pallet functions and be restricted to the pallet interface,
not the internals of the pallet implementation. Only state inputs,
accompany pezpallet functions and be restricted to the pezpallet interface,
not the internals of the pezpallet implementation. Only state inputs,
outputs, and a brief description that mentions whether calling it
requires root, but without repeating the source code details.
Capitalize the first word of each documentation comment and end it with
@@ -37,15 +37,15 @@ Run `cargo doc --package pezpallet-example-basic --open` to view this pallet's d
### Documentation Template:<br>
Copy and paste this template from frame/examples/basic/src/lib.rs into file
`frame/<INSERT_CUSTOM_PALLET_NAME>/src/lib.rs` of your own custom pallet and complete it.
`frame/<INSERT_CUSTOM_PALLET_NAME>/src/lib.rs` of your own custom pezpallet and complete it.
<details><p><pre>
// Add heading with custom pallet name
// Add heading with custom pezpallet name
\# <INSERT_CUSTOM_PALLET_NAME> Pallet
\# <INSERT_CUSTOM_PALLET_NAME> Pezpallet
// Add simple description
// Include the following links that shows what trait needs to be implemented to use the pallet
// Include the following links that shows what trait needs to be implemented to use the pezpallet
// and the supported dispatchables that are documented in the Call enum.
- \[`<INSERT_CUSTOM_PALLET_NAME>::Config`](https://docs.rs/pezpallet-example-basic/latest/pallet_example_basic/trait.Config.html)
@@ -55,11 +55,11 @@ Copy and paste this template from frame/examples/basic/src/lib.rs into file
\## Overview
<!-- Original author of paragraph: Various. See https://github.com/pezkuwichain/kurdistan-sdk/issues/1 -->
// Short description of pallet's purpose.
// Short description of pezpallet's purpose.
// Links to Traits that should be implemented.
// What this pallet is for.
// What functionality the pallet provides.
// When to use the pallet (use case examples).
// What this pezpallet is for.
// What functionality the pezpallet provides.
// When to use the pezpallet (use case examples).
// How it is used.
// Inputs it uses and the source of each input.
// Outputs it produces.
@@ -69,18 +69,18 @@ Copy and paste this template from frame/examples/basic/src/lib.rs into file
\## Terminology
// Add terminology used in the custom pallet. Include concepts, storage items, or actions that you think
// deserve to be noted to give context to the rest of the documentation or pallet usage. The author needs to
// Add terminology used in the custom pezpallet. Include concepts, storage items, or actions that you think
// deserve to be noted to give context to the rest of the documentation or pezpallet usage. The author needs to
// use some judgment about what is included. We don't want a list of every storage item nor types - the user
// can go to the code for that. For example, "transfer fee" is obvious and should not be included, but
// "free balance" and "reserved balance" should be noted to give context to the pallet.
// "free balance" and "reserved balance" should be noted to give context to the pezpallet.
// Please do not link to outside resources. The reference docs should be the ultimate source of truth.
<!-- Original author of heading: @Kianenigma in PR https://github.com/pezkuwichain/kurdistan-sdk/issues/52 -->
\## Goals
// Add goals that the custom pallet is designed to achieve.
// Add goals that the custom pezpallet is designed to achieve.
<!-- Original author of heading: @Kianenigma in PR https://github.com/pezkuwichain/kurdistan-sdk/issues/52 -->
@@ -90,14 +90,14 @@ Copy and paste this template from frame/examples/basic/src/lib.rs into file
\#### <INSERT_SCENARIO_NAME>
// Describe requirements prior to interacting with the custom pallet.
// Describe the process of interacting with the custom pallet for this scenario and public API functions used.
// Describe requirements prior to interacting with the custom pezpallet.
// Describe the process of interacting with the custom pezpallet for this scenario and public API functions used.
\## Interface
\### Supported Origins
// What origins are used and supported in this pallet (root, signed, none)
// What origins are used and supported in this pezpallet (root, signed, none)
// i.e. root when <code>\`ensure_root\`</code> used
// i.e. none when <code>\`ensure_none\`</code> used
// i.e. signed when <code>\`ensure_signed\`</code> used
@@ -132,14 +132,14 @@ Copy and paste this template from frame/examples/basic/src/lib.rs into file
<!-- Original author of paragraph: @joepetrowski -->
// A link to the rustdoc and any notes about usage in the pallet, not for specific functions.
// For example, in the Balances Pallet: "Note that when using the publicly exposed functions,
// A link to the rustdoc and any notes about usage in the pezpallet, not for specific functions.
// For example, in the Balances Pezpallet: "Note that when using the publicly exposed functions,
// you (the runtime developer) are responsible for implementing any necessary checks
// (e.g. that the sender is the signer) before calling a function that will affect storage."
<!-- Original author of paragraph: @AmarRSingh -->
// It is up to the writer of the respective pallet (with respect to how much information to provide).
// It is up to the writer of the respective pezpallet (with respect to how much information to provide).
\#### Public Inspection functions - Immutable (getters)
@@ -166,19 +166,19 @@ Copy and paste this template from frame/examples/basic/src/lib.rs into file
\### Storage Items
// Explain any storage items included in this pallet
// Explain any storage items included in this pezpallet
\### Digest Items
// Explain any digest items included in this pallet
// Explain any digest items included in this pezpallet
\### Inherent Data
// Explain what inherent data (if any) is defined in the pallet and any other related types
// Explain what inherent data (if any) is defined in the pezpallet and any other related types
\### Events:
// Insert events for this pallet if any
// Insert events for this pezpallet if any
\### Errors:
@@ -187,12 +187,12 @@ Copy and paste this template from frame/examples/basic/src/lib.rs into file
\## Usage
// Insert 2-3 examples of usage and code snippets that show how to
// use <INSERT_CUSTOM_PALLET_NAME> Pallet in a custom pallet.
// use <INSERT_CUSTOM_PALLET_NAME> Pezpallet in a custom pezpallet.
\### Prerequisites
// Show how to include necessary imports for <INSERT_CUSTOM_PALLET_NAME> and derive
// your pallet configuration trait with the `INSERT_CUSTOM_PALLET_NAME` trait.
// your pezpallet configuration trait with the `INSERT_CUSTOM_PALLET_NAME` trait.
\```rust
use <INSERT_CUSTOM_PALLET_NAME>;
@@ -220,7 +220,7 @@ pub trait Config: <INSERT_CUSTOM_PALLET_NAME>::Config { }
// Dependencies on other FRAME pallets and the genesis config should be mentioned,
// but not the Rust Standard Library.
// Genesis configuration modifications that may be made to incorporate this pallet
// Genesis configuration modifications that may be made to incorporate this pezpallet
// Interaction with other pallets
<!-- Original author of heading: @AmarRSingh -->
@@ -30,12 +30,12 @@ use crate::*;
use pezframe_benchmarking::v2::*;
use pezframe_system::RawOrigin;
// To actually run this benchmark on pezpallet-example-basic, we need to put this pallet into the
// To actually run this benchmark on pezpallet-example-basic, we need to put this pezpallet into the
// runtime and compile it with `runtime-benchmarks` feature. The detail procedures are
// documented at:
// https://docs.pezkuwichain.io/reference/how-to-guides/weights/add-benchmarks/
//
// The auto-generated weight estimate of this pallet is copied over to the `weights.rs` file.
// The auto-generated weight estimate of this pezpallet is copied over to the `weights.rs` file.
// The exact command of how the estimate generated is printed at the top of the file.
// Details on using the benchmarks macro can be seen at:
@@ -120,5 +120,5 @@ mod benchmarks {
//
// The line generates three steps per benchmark, with repeat=1 and the three steps are
// [low, mid, high] of the range.
impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test);
impl_benchmark_test_suite!(Pezpallet, crate::tests::new_test_ext(), crate::tests::Test);
}
+55 -55
View File
@@ -21,11 +21,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Basic Example Pallet
//! # Basic Example Pezpallet
//!
//! A pallet demonstrating concepts, APIs and structures common to most FRAME runtimes.
//! A pezpallet demonstrating concepts, APIs and structures common to most FRAME runtimes.
//!
//! **This pallet serves as an example and is not meant to be used in production.**
//! **This pezpallet serves as an example and is not meant to be used in production.**
//!
//! > Made with *Bizinikiwi*, for *Pezkuwi*.
//!
@@ -35,20 +35,20 @@
//! [pezkuwi]: https://img.shields.io/badge/polkadot-E6007A?style=for-the-badge&logo=polkadot&logoColor=white
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
//!
//! ## Pallet API
//! ## Pezpallet API
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes,
//! See the [`pezpallet`] module for more information about the interfaces this pezpallet exposes,
//! including its configuration trait, dispatchables, storage items, events and errors.
//!
//! ## Overview
//!
//! This pallet provides basic examples of using:
//! This pezpallet provides basic examples of using:
//!
//! - A custom weight calculator able to classify a call's dispatch class (see:
//! [`pezframe_support::dispatch::DispatchClass`])
//! - Pallet hooks to implement some custom logic that's executed before and after a block is
//! - Pezpallet hooks to implement some custom logic that's executed before and after a block is
//! imported (see: [`pezframe_support::traits::Hooks`])
//! - Inherited weight annotation for pallet calls, used to create less repetition for calls that
//! - Inherited weight annotation for pezpallet calls, used to create less repetition for calls that
//! use the [`Config::WeightInfo`] trait to calculate call weights. This can also be overridden,
//! as demonstrated by [`Call::set_dummy`].
//! - A private function that performs a storage update.
@@ -83,8 +83,8 @@ use pezsp_runtime::{
transaction_validity::{InvalidTransaction, ValidTransaction},
};
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
#[cfg(test)]
mod tests;
@@ -93,7 +93,7 @@ mod benchmarking;
pub mod weights;
pub use weights::*;
/// A type alias for the balance type from this pallet's point of view.
/// A type alias for the balance type from this pezpallet's point of view.
type BalanceOf<T> = <T as pezpallet_balances::Config>::Balance;
const MILLICENTS: u32 = 1_000_000_000;
@@ -103,7 +103,7 @@ const MILLICENTS: u32 = 1_000_000_000;
// The `WeightData<T>` trait has access to the arguments of the dispatch that it wants to assign a
// weight to. Nonetheless, the trait itself cannot make any assumptions about what the generic type
// of the arguments (`T`) is. Based on our needs, we could replace `T` with a more concrete type
// while implementing the trait. The `pallet::weight` expects whatever implements `WeighData<T>` to
// while implementing the trait. The `pezpallet::weight` expects whatever implements `WeighData<T>` to
// replace `T` with a tuple of the dispatch arguments. This is exactly how we will craft the
// implementation below.
//
@@ -144,39 +144,39 @@ impl<T: pezpallet_balances::Config> PaysFee<(&BalanceOf<T>,)> for WeightForSetDu
}
}
// Definition of the pallet logic, to be aggregated at runtime definition through
// Definition of the pezpallet logic, to be aggregated at runtime definition through
// `construct_runtime`.
#[pezframe_support::pallet]
pub mod pallet {
// Import various types used to declare pallet in scope.
#[pezframe_support::pezpallet]
pub mod pezpallet {
// Import various types used to declare pezpallet in scope.
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// Our pallet's configuration trait. All our types and constants go in here. If the
/// pallet is dependent on specific other pallets, then their configuration traits
/// Our pezpallet's configuration trait. All our types and constants go in here. If the
/// pezpallet is dependent on specific other pallets, then their configuration traits
/// should be added to our implied traits list.
///
/// `pezframe_system::Config` should always be included.
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezpallet_balances::Config + pezframe_system::Config {
// Setting a constant config parameter from the runtime
#[pallet::constant]
#[pezpallet::constant]
type MagicNumber: Get<Self::Balance>;
/// Type representing the weight of this pallet
/// Type representing the weight of this pezpallet
type WeightInfo: WeightInfo;
}
// Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and
// Simple declaration of the `Pezpallet` type. It is placeholder we use to implement traits and
// method.
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
// This pallet implements the [`pezframe_support::traits::Hooks`] trait to define some logic to
// This pezpallet implements the [`pezframe_support::traits::Hooks`] trait to define some logic to
// execute in some context.
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
// `on_initialize` is executed at the beginning of the block before any extrinsic are
// dispatched.
//
@@ -199,7 +199,7 @@ pub mod pallet {
// We don't do anything here.
// but we could dispatch extrinsic (transaction/unsigned/inherent) using
// pezsp_io::submit_extrinsic.
// To see example on offchain worker, please refer to example-offchain-worker pallet
// To see example on offchain worker, please refer to example-offchain-worker pezpallet
// accompanied in this repository.
}
}
@@ -234,10 +234,10 @@ pub mod pallet {
// against them as the first thing you do in your function. There are three convenience calls
// in system that do the matching for you and return a convenient result: `ensure_signed`,
// `ensure_root` and `ensure_none`.
#[pallet::call(weight(<T as Config>::WeightInfo))]
impl<T: Config> Pallet<T> {
#[pezpallet::call(weight(<T as Config>::WeightInfo))]
impl<T: Config> Pezpallet<T> {
/// This is your public interface. Be extremely careful.
/// This is just a simple example of how to interact with the pallet from the external
/// This is just a simple example of how to interact with the pezpallet from the external
/// world.
// This just increases the value of `Dummy` by `increase_by`.
//
@@ -259,7 +259,7 @@ pub mod pallet {
// If you can't be certain that the operation will succeed without substantial computation
// then you have a classic blockchain attack scenario. The normal way of managing this is
// to attach a bond to the operation. As the first major alteration of storage, reserve
// some value from the sender's account (`Balances` Pallet has a `reserve` function for
// some value from the sender's account (`Balances` Pezpallet has a `reserve` function for
// exactly this scenario). This amount should be enough to cover any costs of the
// substantial execution in case it turns out that you can't proceed with the operation.
//
@@ -274,12 +274,12 @@ pub mod pallet {
//
// If you don't respect these rules, it is likely that your chain will be attackable.
//
// Each transaction must define a `#[pallet::weight(..)]` attribute to convey a set of
// static information about its dispatch. FRAME System and FRAME Executive pallet then use
// Each transaction must define a `#[pezpallet::weight(..)]` attribute to convey a set of
// static information about its dispatch. FRAME System and FRAME Executive pezpallet then use
// this information to properly execute the transaction, whilst keeping the total load of
// the chain in a moderate rate.
//
// The parenthesized value of the `#[pallet::weight(..)]` attribute can be any type that
// The parenthesized value of the `#[pezpallet::weight(..)]` attribute can be any type that
// implements a set of traits, namely [`WeighData`], [`ClassifyDispatch`], and
// [`PaysFee`]. The first conveys the weight (a numeric representation of pure
// execution time and difficulty) of the transaction and the second demonstrates the
@@ -289,7 +289,7 @@ pub mod pallet {
//
// The weight for this extrinsic we rely on the auto-generated `WeightInfo` from the
// benchmark toolchain.
#[pallet::call_index(0)]
#[pezpallet::call_index(0)]
pub fn accumulate_dummy(origin: OriginFor<T>, increase_by: T::Balance) -> DispatchResult {
// This is a public call, so we ensure that the origin is some signed account.
let _sender = ensure_signed(origin)?;
@@ -329,11 +329,11 @@ pub mod pallet {
//
// The weight for this extrinsic we use our own weight object `WeightForSetDummy` to
// determine its weight
#[pallet::call_index(1)]
#[pallet::weight(WeightForSetDummy::<T>(<BalanceOf<T>>::from(100u32)))]
#[pezpallet::call_index(1)]
#[pezpallet::weight(WeightForSetDummy::<T>(<BalanceOf<T>>::from(100u32)))]
pub fn set_dummy(
origin: OriginFor<T>,
#[pallet::compact] new_value: T::Balance,
#[pezpallet::compact] new_value: T::Balance,
) -> DispatchResult {
ensure_root(origin)?;
@@ -356,10 +356,10 @@ pub mod pallet {
/// Events are a simple means of reporting specific conditions and
/// circumstances that have happened that users, Dapps and/or chain explorers would find
/// interesting and otherwise difficult to detect.
#[pallet::event]
/// This attribute generate the function `deposit_event` to deposit one of this pallet event,
#[pezpallet::event]
/// This attribute generate the function `deposit_event` to deposit one of this pezpallet event,
/// it is optional, it is also possible to provide a custom implementation.
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
// Just a normal `enum`, here's a dummy event to ensure it compiles.
/// Dummy event, just here so there's a generic type that's used.
@@ -375,7 +375,7 @@ pub mod pallet {
},
}
// pallet::storage attributes allow for type-safe usage of the Bizinikiwi storage database,
// pezpallet::storage attributes allow for type-safe usage of the Bizinikiwi storage database,
// so you can keep things around between blocks.
//
// Any storage must be one of `StorageValue`, `StorageMap` or `StorageDoubleMap`.
@@ -387,22 +387,22 @@ pub mod pallet {
// - for `type Foo<T> = StorageValue<_, u32, ValueQuery>`:
// - `Foo::put(1); Foo::get()` returns `1`;
// - `Foo::kill(); Foo::get()` returns `0` (u32::default()).
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Dummy<T: Config> = StorageValue<_, T::Balance>;
// A map that has enumerable entries.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Bar<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance>;
// this one uses the query kind: `ValueQuery`, we'll demonstrate the usage of 'mutate' API.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Foo<T: Config> = StorageValue<_, T::Balance, ValueQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type CountedMap<T> = CountedStorageMap<_, Blake2_128Concat, u8, u16>;
// The genesis config type.
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub dummy: T::Balance,
@@ -410,8 +410,8 @@ pub mod pallet {
pub foo: T::Balance,
}
// The build of genesis for the pallet.
#[pallet::genesis_build]
// The build of genesis for the pezpallet.
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
<Dummy<T>>::put(&self.dummy);
@@ -423,12 +423,12 @@ pub mod pallet {
}
}
// The main implementation block for the pallet. Functions here fall into three broad
// The main implementation block for the pezpallet. Functions here fall into three broad
// categories:
// - Public interface. These are functions that are `pub` and generally fall into inspector
// functions that do not write to storage and operation functions that do.
// - Private functions. These are your usual private utilities unavailable to other pallets.
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
// Add public immutables and private mutables.
#[allow(dead_code)]
fn accumulate_foo(origin: T::RuntimeOrigin, increase_by: T::Balance) -> DispatchResult {
@@ -447,11 +447,11 @@ impl<T: Config> Pallet<T> {
}
}
// Similar to other FRAME pallets, your pallet can also define a transaction extension and perform
// Similar to other FRAME pallets, your pezpallet can also define a transaction extension and perform
// some checks and [pre/post]processing [before/after] the transaction. A transaction extension can
// be any decodable type that implements `TransactionExtension`. See the trait definition for the
// full list of bounds. As a convention, you can follow this approach to create an extension for
// your pallet:
// your pezpallet:
// - If the extension does not carry any data, then use a tuple struct with just a `marker`
// (needed for the compiler to accept `T: Config`) will suffice.
// - Otherwise, create a tuple struct which contains the external data. Of course, for the entire
@@ -466,7 +466,7 @@ impl<T: Config> Pallet<T> {
// Using the extension, you can add some hooks to the life cycle of each transaction. Note that by
// default, an extension is applied to all `Call` functions (i.e. all transactions). the `Call` enum
// variant is given to each function of `TransactionExtension`. Hence, you can filter based on
// pallet or a particular call if needed.
// pezpallet or a particular call if needed.
//
// Some extra information, such as encoded length, some static dispatch info like weight and the
// sender of the transaction (if signed) are also provided.
@@ -37,12 +37,12 @@ use pezsp_runtime::{
transaction_validity::TransactionSource::External,
BuildStorage,
};
// Reexport crate as its pallet name for construct_runtime.
// Reexport crate as its pezpallet name for construct_runtime.
use crate as pezpallet_example_basic;
type Block = pezframe_system::mocking::MockBlock<Test>;
// For testing the pallet, we construct a mock runtime.
// For testing the pezpallet, we construct a mock runtime.
pezframe_support::construct_runtime!(
pub enum Test
{
@@ -30,11 +30,11 @@
// Executed Command:
// ./target/release/bizinikiwi
// benchmark
// pallet
// pezpallet
// --chain=dev
// --execution=wasm
// --wasm-execution=compiled
// --pallet=pezpallet_example_basic
// --pezpallet=pezpallet_example_basic
// --extrinsic=*
// --steps=50
// --repeat=20
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet demonstrating derive_impl / default_config in action"
description = "FRAME example pezpallet demonstrating derive_impl / default_config in action"
readme = "README.md"
publish = false
documentation = "https://docs.rs/pezpallet-default-config-example"
@@ -1,8 +1,8 @@
# Default Config Example Pallet
# Default Config Example Pezpallet
An example pallet demonstrating the ability to derive default testing configs via
`#[derive_impl]` and `#[pallet::config(with_default)]`.
An example pezpallet demonstrating the ability to derive default testing configs via
`#[derive_impl]` and `#[pezpallet::config(with_default)]`.
Run `cargo doc --package pezpallet-default-config-example --open` to view this pallet's documentation.
Run `cargo doc --package pezpallet-default-config-example --open` to view this pezpallet's documentation.
License: MIT-0
@@ -21,9 +21,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Default Config Pallet Example
//! # Default Config Pezpallet Example
//!
//! A simple example of a FRAME pallet that utilizes [`pezframe_support::derive_impl`] to demonstrate
//! A simple example of a FRAME pezpallet that utilizes [`pezframe_support::derive_impl`] to demonstrate
//! the simpler way to implement `Config` trait of pallets. This example only showcases this in a
//! `mock.rs` environment, but the same applies to a real runtime as well.
//!
@@ -31,31 +31,31 @@
//!
//! Study the following types:
//!
//! - [`pallet::DefaultConfig`], and how it differs from [`pallet::Config`].
//! - [`struct@pallet::config_preludes::TestDefaultConfig`] and how it implements
//! [`pallet::DefaultConfig`].
//! - Notice how [`pallet::DefaultConfig`] is independent of [`pezframe_system::Config`].
//! - [`pezpallet::DefaultConfig`], and how it differs from [`pezpallet::Config`].
//! - [`struct@pezpallet::config_preludes::TestDefaultConfig`] and how it implements
//! [`pezpallet::DefaultConfig`].
//! - Notice how [`pezpallet::DefaultConfig`] is independent of [`pezframe_system::Config`].
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use pezframe_support::pezpallet_prelude::*;
/// This pallet is annotated to have a default config. This will auto-generate
/// This pezpallet is annotated to have a default config. This will auto-generate
/// [`DefaultConfig`].
///
/// It will be an identical, but won't have anything that is `#[pallet::no_default]`.
#[pallet::config(with_default)]
/// It will be an identical, but won't have anything that is `#[pezpallet::no_default]`.
#[pezpallet::config(with_default)]
pub trait Config: pezframe_system::Config {
/// The overarching task type. This is coming from the runtime, and cannot have a default.
/// In general, `Runtime*`-oriented types cannot have a sensible default.
#[pallet::no_default] // optional. `RuntimeEvent` is automatically excluded as well.
#[pezpallet::no_default] // optional. `RuntimeEvent` is automatically excluded as well.
type RuntimeTask: Task;
/// An input parameter to this pallet. This value can have a default, because it is not
/// An input parameter to this pezpallet. This value can have a default, because it is not
/// reliant on `pezframe_system::Config` or the overarching runtime in any way.
type WithDefaultValue: Get<u32>;
@@ -69,13 +69,13 @@ pub mod pallet {
/// We might choose to declare as one that doesn't have a default, for whatever semantical
/// reason.
#[pallet::no_default]
#[pezpallet::no_default]
type HasNoDefault: Get<u32>;
/// Some types can technically have no default, such as those the rely on
/// `pezframe_system::Config` but are not present in `pezframe_system::DefaultConfig`. For
/// example, a `RuntimeCall` cannot reasonably have a default.
#[pallet::no_default] // if we skip this, there will be a compiler error.
#[pezpallet::no_default] // if we skip this, there will be a compiler error.
type CannotHaveDefault: Get<Self::RuntimeCall>;
/// Something that is a normal type, with default.
@@ -86,13 +86,13 @@ pub mod pallet {
type OverwrittenDefaultType;
}
/// Container for different types that implement [`DefaultConfig`]` of this pallet.
/// Container for different types that implement [`DefaultConfig`]` of this pezpallet.
pub mod config_preludes {
// This will help use not need to disambiguate anything when using `derive_impl`.
use super::*;
use pezframe_support::derive_impl;
/// A type providing default configurations for this pallet in testing environment.
/// A type providing default configurations for this pezpallet in testing environment.
pub struct TestDefaultConfig;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig, no_aggregated_types)]
@@ -110,7 +110,7 @@ pub mod pallet {
type OverwrittenDefaultType = u32;
}
/// A type providing default configurations for this pallet in another environment. Examples
/// A type providing default configurations for this pezpallet in another environment. Examples
/// could be a teyrchain, or a solochain.
///
/// Appropriate derive for `pezframe_system::DefaultConfig` needs to be provided. In this
@@ -130,10 +130,10 @@ pub mod pallet {
}
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::event]
#[pezpallet::event]
pub enum Event<T: Config> {}
}
@@ -141,7 +141,7 @@ pub mod pallet {
pub mod tests {
use super::*;
use pezframe_support::{derive_impl, parameter_types};
use pallet::{self as pezpallet_default_config_example, config_preludes::*};
use pezpallet::{self as pezpallet_default_config_example, config_preludes::*};
type Block = pezframe_system::mocking::MockBlock<Runtime>;
@@ -196,7 +196,7 @@ pub mod tests {
pub const SomeCall: RuntimeCall = RuntimeCall::System(pezframe_system::Call::<Runtime>::remark { remark: alloc::vec![] });
}
#[derive_impl(TestDefaultConfig as pallet::DefaultConfig)]
#[derive_impl(TestDefaultConfig as pezpallet::DefaultConfig)]
impl pezpallet_default_config_example::Config for Runtime {
// This cannot have default.
type RuntimeTask = RuntimeTask;
@@ -211,7 +211,7 @@ pub mod tests {
#[test]
fn it_works() {
use pezframe_support::traits::Get;
use pallet::{Config, DefaultConfig};
use pezpallet::{Config, DefaultConfig};
// assert one of the value types that is not overwritten.
assert_eq!(
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet"
description = "FRAME example pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-dev-mode"
publish = false
@@ -1,10 +1,10 @@
<!-- markdown-link-check-disable -->
# Dev Mode Example Pallet
# Dev Mode Example Pezpallet
A simple example of a FRAME pallet demonstrating
the ease of requirements for a pallet in dev mode.
A simple example of a FRAME pezpallet demonstrating
the ease of requirements for a pezpallet in dev mode.
Run `cargo doc --package pezpallet-dev-mode --open` to view this pallet's documentation.
Run `cargo doc --package pezpallet-dev-mode --open` to view this pezpallet's documentation.
**Dev mode is not meant to be used in production.**
@@ -22,12 +22,12 @@
// SOFTWARE.
//! <!-- markdown-link-check-disable -->
//! # Dev Mode Example Pallet
//! # Dev Mode Example Pezpallet
//!
//! A simple example of a FRAME pallet demonstrating
//! the ease of requirements for a pallet in dev mode.
//! A simple example of a FRAME pezpallet demonstrating
//! the ease of requirements for a pezpallet in dev mode.
//!
//! Run `cargo doc --package pezpallet-dev-mode --open` to view this pallet's documentation.
//! Run `cargo doc --package pezpallet-dev-mode --open` to view this pezpallet's documentation.
//!
//! **Dev mode is not meant to be used in production.**
@@ -40,32 +40,32 @@ use alloc::{vec, vec::Vec};
use pezframe_support::dispatch::DispatchResult;
use pezframe_system::ensure_signed;
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
#[cfg(test)]
mod tests;
/// A type alias for the balance type from this pallet's point of view.
/// A type alias for the balance type from this pezpallet's point of view.
type BalanceOf<T> = <T as pezpallet_balances::Config>::Balance;
/// Enable `dev_mode` for this pallet.
#[pezframe_support::pallet(dev_mode)]
pub mod pallet {
/// Enable `dev_mode` for this pezpallet.
#[pezframe_support::pezpallet(dev_mode)]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezpallet_balances::Config + pezframe_system::Config {}
// Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and
// Simple declaration of the `Pezpallet` type. It is placeholder we use to implement traits and
// method.
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
// No need to define a `call_index` attribute here because of `dev_mode`.
// No need to define a `weight` attribute here because of `dev_mode`.
pub fn add_dummy(origin: OriginFor<T>, id: T::AccountId) -> DispatchResult {
@@ -88,7 +88,7 @@ pub mod pallet {
// No need to define a `weight` attribute here because of `dev_mode`.
pub fn set_bar(
origin: OriginFor<T>,
#[pallet::compact] new_value: T::Balance,
#[pezpallet::compact] new_value: T::Balance,
) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -101,8 +101,8 @@ 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> {
AddDummy { account: T::AccountId },
SetBar { account: T::AccountId, balance: BalanceOf<T> },
@@ -110,15 +110,15 @@ pub mod pallet {
/// The MEL requirement for bounded pallets is skipped by `dev_mode`.
/// This means that all storages are marked as unbounded.
/// This is equivalent to specifying `#[pallet::unbounded]` on this type definitions.
/// This is equivalent to specifying `#[pezpallet::unbounded]` on this type definitions.
/// When the dev_mode is removed, we would need to implement implement `MaxEncodedLen`.
#[pallet::storage]
#[pezpallet::storage]
pub type Dummy<T: Config> = StorageValue<_, Vec<T::AccountId>>;
/// The Hasher requirement is skipped by `dev_mode`. So, second parameter can be `_`
/// and `Blake2_128Concat` is used as a default.
/// When the dev_mode is removed, we would need to specify the hasher like so:
/// `pub type Bar<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance>;`.
#[pallet::storage]
#[pezpallet::storage]
pub type Bar<T: Config> = StorageMap<_, _, T::AccountId, T::Balance>;
}
@@ -30,12 +30,12 @@ use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
// Reexport crate as its pallet name for construct_runtime.
// Reexport crate as its pezpallet name for construct_runtime.
use crate as pezpallet_dev_mode;
type Block = pezframe_system::mocking::MockBlock<Test>;
// For testing the pallet, we construct a mock runtime.
// For testing the pezpallet, we construct a mock runtime.
pezframe_support::construct_runtime!(
pub enum Test
{
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example kitchensink pallet"
description = "FRAME example kitchensink pezpallet"
publish = false
documentation = "https://docs.rs/pezpallet-example-kitchensink"
@@ -28,18 +28,18 @@
use super::*;
#[allow(unused)]
use crate::Pallet as Kitchensink;
use crate::Pezpallet as Kitchensink;
use pezframe_benchmarking::v2::*;
use pezframe_support::pezpallet_prelude::TransactionSource;
use pezframe_system::RawOrigin;
// To actually run this benchmark on pezpallet-example-kitchensink, we need to put this pallet into the
// To actually run this benchmark on pezpallet-example-kitchensink, we need to put this pezpallet into the
// runtime and compile it with `runtime-benchmarks` feature. The detail procedures are
// documented at:
// https://docs.pezkuwichain.io/reference/how-to-guides/weights/add-benchmarks/
//
// The auto-generated weight estimate of this pallet is copied over to the `weights.rs` file.
// The auto-generated weight estimate of this pezpallet is copied over to the `weights.rs` file.
// The exact command of how the estimate generated is printed at the top of the file.
// Details on using the benchmarks macro can be seen at:
@@ -78,7 +78,7 @@ mod benchmarks {
assert_eq!(Foo::<T>::get(), Some(42))
}
// This will measure the weight for the closure in `[pallet::authorize(...)]`.
// This will measure the weight for the closure in `[pezpallet::authorize(...)]`.
#[benchmark]
fn authorize_set_foo_using_authorize() {
// This is the benchmark setup phase.
@@ -21,20 +21,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Kitchensink Example Pallet
//! # Kitchensink Example Pezpallet
//!
//! **This pallet serves as an example and is not meant to be used in production.**
//! **This pezpallet serves as an example and is not meant to be used in production.**
//!
//! The kitchen-sink catalog of the the FRAME macros and their various syntax options.
//!
//! This example does not focus on pallet instancing, `dev_mode`, and does nto include any 'where'
//! This example does not focus on pezpallet instancing, `dev_mode`, and does nto include any 'where'
//! clauses on `T`. These will both incur additional complexity to the syntax, but are not discussed
//! here.
#![cfg_attr(not(feature = "std"), no_std)]
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
#[cfg(test)]
mod tests;
@@ -50,32 +50,32 @@ pub use weights::*;
extern crate alloc;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// The config trait of the pallet. You can basically do anything with the config trait that you
/// The config trait of the pezpallet. You can basically do anything with the config trait that you
/// can do with a normal rust trait: import items consisting of types, constants and functions.
///
/// A very common pattern is for a pallet to import implementations of traits such as
/// A very common pattern is for a pezpallet to import implementations of traits such as
/// [`pezframe_support::traits::Currency`], [`pezframe_support::traits::fungibles::Inspect`] and
/// [`pezframe_support::traits::Get`]. These are all types that the pallet is delegating to the top
/// [`pezframe_support::traits::Get`]. These are all types that the pezpallet is delegating to the top
/// level runtime to provide to it.
///
/// The `FRAME`-specific syntax are:
///
/// * the use of `#[pallet::constant]`([`pezframe_support::procedural`]), which places a `Get`
/// * the use of `#[pezpallet::constant]`([`pezframe_support::procedural`]), which places a `Get`
/// implementation in the metadata.
/// * `type RuntimeEvent`, which is mandatory if your pallet has events. See TODO.
/// * `type RuntimeEvent`, which is mandatory if your pezpallet has events. See TODO.
/// * Needless to say, because [`Config`] is bounded by [`pezframe_system::Config`], you can use
/// all the items from [`pezframe_system::Config`] as well, such as `AccountId`.
/// * `#[pallet::disable_pezframe_system_supertrait_check]` would remove the need for
/// * `#[pezpallet::disable_pezframe_system_supertrait_check]` would remove the need for
/// `pezframe_system::Config` to exist, which you should almost never need.
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Type representing the weight of this pallet
/// Type representing the weight of this pezpallet
type WeightInfo: WeightInfo;
/// This is a normal Rust type, nothing specific to FRAME here.
@@ -87,21 +87,21 @@ pub mod pallet {
/// And this
const FOO: u32;
/// This is a FRAME-specific item. It will be placed in the metadata of the pallet, and
/// This is a FRAME-specific item. It will be placed in the metadata of the pezpallet, and
/// therefore can be queried by offchain applications.
#[pallet::constant]
#[pezpallet::constant]
type InMetadata: Get<u32>;
}
/// Allows you to define some extra constants to be added into constant metadata.
#[pallet::extra_constants]
impl<T: Config> Pallet<T> {
#[pezpallet::extra_constants]
impl<T: Config> Pezpallet<T> {
#[allow(non_snake_case)]
fn SomeValue() -> u32 {
unimplemented!()
}
#[pallet::constant_name(OtherValue)]
#[pezpallet::constant_name(OtherValue)]
fn arbitrary_name() -> u32 {
unimplemented!()
}
@@ -109,15 +109,15 @@ pub mod pallet {
const STORAGE_VERSION: pezframe_support::traits::StorageVersion = StorageVersion::new(1);
/// The pallet struct. There's nothing special to FRAME about this; it can implement functions
/// The pezpallet struct. There's nothing special to FRAME about this; it can implement functions
/// in an impl blocks, traits and so on.
#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::without_storage_info]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
/// Allows you to define some origin for the pallet.
#[pallet::origin]
/// Allows you to define some origin for the pezpallet.
#[pezpallet::origin]
pub type Origin<T> = pezframe_system::RawOrigin<<T as pezframe_system::Config>::AccountId>;
// first, we showcase all the possible storage types, with most of their details.
@@ -127,17 +127,17 @@ pub mod pallet {
///
/// The value is stored a single trie node, and therefore can be retrieved with a single
/// database access.
#[pallet::storage]
#[pallet::unbounded] // optional
#[pallet::storage_prefix = "OtherFoo"] // optional
#[pezpallet::storage]
#[pezpallet::unbounded] // optional
#[pezpallet::storage_prefix = "OtherFoo"] // optional
pub type Foo<T> = StorageValue<Value = u32>;
#[pallet::type_value]
#[pezpallet::type_value]
pub fn DefaultForFoo() -> u32 {
1
}
#[pallet::storage]
#[pezpallet::storage]
pub type FooWithDefault<T> =
StorageValue<Value = u32, QueryKind = ValueQuery, OnEmpty = DefaultForFoo>;
@@ -145,12 +145,12 @@ pub mod pallet {
///
/// Keys and values can be iterated, albeit each value is stored under a unique trie key,
/// meaning that an iteration consists of many database accesses.
#[pallet::storage]
#[pezpallet::storage]
pub type Bar<T> = StorageMap<Hasher = Blake2_128Concat, Key = u32, Value = u32>;
/// Conceptually same as `StorageMap<>` where the key is a tuple of `(u32, u32)`. On top, it
/// provides some functions to iterate or remove items based on only the first key.
#[pallet::storage]
#[pezpallet::storage]
pub type Qux<T> = StorageDoubleMap<
Hasher1 = Blake2_128Concat,
Key1 = u32,
@@ -160,7 +160,7 @@ pub mod pallet {
>;
/// Same as `StorageDoubleMap`, but with arbitrary number of keys.
#[pallet::storage]
#[pezpallet::storage]
pub type Quux<T> = StorageNMap<
Key = (
NMapKey<Blake2_128Concat, u8>,
@@ -172,19 +172,19 @@ pub mod pallet {
/// In all of these examples, we chose a syntax where the storage item is defined using the
/// explicit generic syntax (`X = Y`). Alternatively:
#[pallet::storage]
#[pezpallet::storage]
pub type AlternativeSyntax<T> = StorageMap<_, Blake2_128Concat, u32, u32>;
/// Lastly, all storage items, as you saw, had to be generic over `T`. If they want to use an
/// item from `Config`, `<T: Config>` should be used.
#[pallet::storage]
#[pezpallet::storage]
pub type AlternativeSyntax2<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, u32>;
/// The genesis config type. This allows the pallet to define how it should initialized upon
/// The genesis config type. This allows the pezpallet to define how it should initialized upon
/// genesis.
///
/// It can be generic over `T` or not, depending on whether it is or not.
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub foo: u32,
pub bar: BlockNumberFor<T>,
@@ -197,7 +197,7 @@ pub mod pallet {
}
/// Allows you to define how `genesis_configuration is built.
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Foo::<T>::put(self.foo);
@@ -206,18 +206,18 @@ pub mod pallet {
/// The call declaration. This states the entry points that we handle. The
/// macro takes care of the marshalling of arguments and dispatch.
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::set_foo_benchmark())]
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::set_foo_benchmark())]
/// Marks this call as feeless if `new_foo` is zero.
#[pallet::feeless_if(|_origin: &OriginFor<T>, new_foo: &u32, _other_compact: &u128| -> bool {
#[pezpallet::feeless_if(|_origin: &OriginFor<T>, new_foo: &u32, _other_compact: &u128| -> bool {
*new_foo == 0
})]
pub fn set_foo(
_: OriginFor<T>,
new_foo: u32,
#[pallet::compact] _other_compact: u128,
#[pezpallet::compact] _other_compact: u128,
) -> DispatchResult {
Foo::<T>::set(Some(new_foo));
@@ -226,8 +226,8 @@ pub mod pallet {
/// A call that is specially authorized.
/// Authorized call can be dispatched by anybody without requiring any signature or fee.
#[pallet::call_index(1)]
#[pallet::authorize(|
#[pezpallet::call_index(1)]
#[pezpallet::authorize(|
_source: TransactionSource,
new_foo: &u32,
| -> TransactionValidityWithRefund {
@@ -244,11 +244,11 @@ pub mod pallet {
Err(InvalidTransaction::Call.into())
}
})]
#[pallet::weight(T::WeightInfo::set_foo_using_authorize())]
#[pallet::weight_of_authorize(T::WeightInfo::authorize_set_foo_using_authorize())]
#[pezpallet::weight(T::WeightInfo::set_foo_using_authorize())]
#[pezpallet::weight_of_authorize(T::WeightInfo::authorize_set_foo_using_authorize())]
pub fn set_foo_using_authorize(origin: OriginFor<T>, new_foo: u32) -> DispatchResult {
// We only dispatch if it comes from the authorized origin. Meaning that the closure
// passed in `pallet::authorize` has successfully authorized the call.
// passed in `pezpallet::authorize` has successfully authorized the call.
ensure_authorized(origin)?;
Foo::<T>::set(Some(new_foo));
@@ -262,12 +262,12 @@ pub mod pallet {
/// the variants actually use `<T: Config>`, the macro will generate a hidden `PhantomData`
/// variant.
///
/// The `generate_deposit` macro generates a function on `Pallet` called `deposit_event` which
/// will properly convert the error type of your pallet into `RuntimeEvent` (recall `type
/// The `generate_deposit` macro generates a function on `Pezpallet` called `deposit_event` which
/// will properly convert the error type of your pezpallet into `RuntimeEvent` (recall `type
/// RuntimeEvent: From<Event<Self>>`, so it can be converted) and deposit it via
/// `pezframe_system::Pallet::deposit_event`.
#[pallet::event]
#[pallet::generate_deposit(pub fn deposit_event)]
/// `pezframe_system::Pezpallet::deposit_event`.
#[pezpallet::event]
#[pezpallet::generate_deposit(pub fn deposit_event)]
pub enum Event<T: Config> {
/// A simple tuple style variant.
SomethingHappened(u32),
@@ -279,16 +279,16 @@ pub mod pallet {
}
/// The error enum. Must always be generic over `<T>`, which is expanded to `<T: Config>`.
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
SomethingWentWrong,
SomethingBroke,
}
/// All the possible hooks that a pallet can have. See [`pezframe_support::traits::Hooks`] for more
/// All the possible hooks that a pezpallet can have. See [`pezframe_support::traits::Hooks`] for more
/// info.
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn integrity_test() {}
fn offchain_worker(_n: BlockNumberFor<T>) {
@@ -327,17 +327,17 @@ pub mod pallet {
}
}
/// Allows you to define an enum on the pallet which will then instruct `construct_runtime` to
/// Allows you to define an enum on the pezpallet which will then instruct `construct_runtime` to
/// amalgamate all similarly-named enums from other pallets into an aggregate enum.
#[pallet::composite_enum]
#[pezpallet::composite_enum]
pub enum HoldReason {
Staking,
}
/// Allows the pallet to provide some inherent. See [`pezframe_support::inherent::ProvideInherent`]
/// Allows the pezpallet to provide some inherent. See [`pezframe_support::inherent::ProvideInherent`]
/// for more info.
#[pallet::inherent]
impl<T: Config> ProvideInherent for Pallet<T> {
#[pezpallet::inherent]
impl<T: Config> ProvideInherent for Pezpallet<T> {
type Call = Call<T>;
type Error = MakeFatalError<()>;
@@ -26,18 +26,18 @@
use crate::*;
use pezframe_support::{assert_ok, derive_impl, parameter_types, traits::VariantCountOf};
use pezsp_runtime::BuildStorage;
// Reexport crate as its pallet name for construct_runtime.
// Reexport crate as its pezpallet name for construct_runtime.
use crate as pezpallet_example_kitchensink;
type Block = pezframe_system::mocking::MockBlock<Test>;
// For testing the pallet, we construct a mock runtime.
// For testing the pezpallet, we construct a mock runtime.
pezframe_support::construct_runtime!(
pub enum Test
{
System: pezframe_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pezpallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Kitchensink: pezpallet_example_kitchensink::{Pallet, Call, Storage, Config<T>, Event<T>},
System: pezframe_system::{Pezpallet, Call, Config<T>, Storage, Event<T>},
Balances: pezpallet_balances::{Pezpallet, Call, Storage, Config<T>, Event<T>},
Kitchensink: pezpallet_example_kitchensink::{Pezpallet, Call, Storage, Config<T>, Event<T>},
}
);
@@ -32,10 +32,10 @@
// Executed Command:
// ./target/release/node-template
// benchmark
// pallet
// pezpallet
// --chain
// dev
// --pallet
// --pezpallet
// pezpallet_example_kitchensink
// --extrinsic
// *
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Example FRAME pallet for multi-block migrations"
description = "Example FRAME pezpallet for multi-block migrations"
publish = false
documentation = "https://docs.rs/pezpallet-example-mbm"
@@ -17,21 +17,21 @@
#![cfg_attr(not(feature = "std"), no_std)]
//! # Multi-Block Migrations Example Pallet
//! # Multi-Block Migrations Example Pezpallet
//!
//! This pallet serves as a minimal example of a pallet that uses the [Multi-Block Migrations
//! This pezpallet serves as a minimal example of a pezpallet that uses the [Multi-Block Migrations
//! Framework](pezframe_support::migrations). You can observe how to configure it in a runtime in the
//! `pez-kitchensink-runtime` crate.
//!
//! ## Introduction and Purpose
//!
//! The primary purpose of this pallet is to demonstrate the concept of Multi-Block Migrations in
//! The primary purpose of this pezpallet is to demonstrate the concept of Multi-Block Migrations in
//! Bizinikiwi. It showcases the migration of values from in the
//! [`MyMap`](`pallet::MyMap`) storage map a `u32` to a `u64` data type using the
//! [`MyMap`](`pezpallet::MyMap`) storage map a `u32` to a `u64` data type using the
//! [`SteppedMigration`](`pezframe_support::migrations::SteppedMigration`) implementation from the
//! [`migrations::v1`] module.
//!
//! The [`MyMap`](`pallet::MyMap`) storage item is defined in this `pallet`, and is
//! The [`MyMap`](`pezpallet::MyMap`) storage item is defined in this `pezpallet`, and is
//! aliased to [`v0::MyMap`](`migrations::v1::v0::MyMap`) in the [`migrations::v1`]
//! module.
//!
@@ -41,22 +41,22 @@
//!
//! - `cargo doc --package pezpallet-example-mbm --open`
//!
//! This documentation is organized to help you understand the pallet's components, features, and
//! This documentation is organized to help you understand the pezpallet's components, features, and
//! migration process.
//!
//! ## Example Usage
//!
//! To use this pallet and understand multi-block migrations, you can refer to the
//! To use this pezpallet and understand multi-block migrations, you can refer to the
//! [`migrations::v1`] module, which contains a step-by-step migration example.
//!
//! ## Pallet Structure
//! ## Pezpallet Structure
//!
//! The pallet is structured as follows:
//! The pezpallet is structured as follows:
//!
//! - [`migrations`]: Contains migration-related modules and migration logic.
//! - [`v1`](`migrations::v1`): Demonstrates the migration process for changing the data type in
//! the storage map.
//! - [`pallet`]: Defines the pallet configuration and storage items.
//! - [`pezpallet`]: Defines the pezpallet configuration and storage items.
//!
//! ## Migration Safety
//!
@@ -69,19 +69,19 @@
pub mod migrations;
mod mock;
pub use pallet::*;
pub use pezpallet::*;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use pezframe_support::{pezpallet_prelude::StorageMap, Blake2_128Concat};
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
/// Define a storage item to illustrate multi-block migrations.
#[pallet::storage]
#[pezpallet::storage]
pub type MyMap<T: Config> = StorageMap<_, Blake2_128Concat, u32, u64>;
}
@@ -22,8 +22,8 @@ pub mod v1;
/// A unique identifier across all pallets.
///
/// This constant represents a unique identifier for the migrations of this pallet.
/// It helps differentiate migrations for this pallet from those of others. Note that we don't
/// This constant represents a unique identifier for the migrations of this pezpallet.
/// It helps differentiate migrations for this pezpallet from those of others. Note that we don't
/// directly pull the crate name from the environment, since that would change if the crate were
/// ever to be renamed and could cause historic migrations to run again.
pub const PALLET_MIGRATIONS_ID: &[u8; 21] = b"pezpallet-example-mbm";
@@ -24,7 +24,7 @@ use crate::{
v1,
v1::{weights, weights::WeightInfo},
},
Config, Pallet,
Config, Pezpallet,
};
use pezframe_benchmarking::v2::*;
use pezframe_support::{migrations::SteppedMigration, weights::WeightMeter};
@@ -50,5 +50,5 @@ mod benches {
assert_eq!(meter.consumed(), weights::BizinikiwiWeight::<T>::step() * 2);
}
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);
}
@@ -19,12 +19,12 @@
//!
//! This module showcases a simple migration that iterates over the values in the
//! [`v0::MyMap`](`crate::migrations::v1::v0::MyMap`) storage map, transforms them,
//! and inserts them into the [`MyMap`](`crate::pallet::MyMap`) storage map.
//! and inserts them into the [`MyMap`](`crate::pezpallet::MyMap`) storage map.
extern crate alloc;
use super::PALLET_MIGRATIONS_ID;
use crate::pallet::{Config, MyMap};
use crate::pezpallet::{Config, MyMap};
use pezframe_support::{
migrations::{MigrationId, SteppedMigration, SteppedMigrationError},
pezpallet_prelude::PhantomData,
@@ -49,12 +49,12 @@ pub mod weights;
// intended to be used by any other code.
pub mod v0 {
use super::Config;
use crate::pallet::Pallet;
use crate::pezpallet::Pezpallet;
use pezframe_support::{storage_alias, Blake2_128Concat};
#[storage_alias]
/// The storage item that is being migrated from.
pub type MyMap<T: Config> = StorageMap<Pallet<T>, Blake2_128Concat, u32, u32>;
pub type MyMap<T: Config> = StorageMap<Pezpallet<T>, Blake2_128Concat, u32, u32>;
}
/// Migrates the items of the [`crate::MyMap`] map from `u32` to `u64`.
@@ -42,7 +42,7 @@ fn lazy_migration_works() {
// Give it enough weight do do exactly 16 iterations:
let limit = <T as pezpallet_migrations::Config>::WeightInfo::progress_mbms_none() +
pezpallet_migrations::Pallet::<T>::exec_migration_max_weight() +
pezpallet_migrations::Pezpallet::<T>::exec_migration_max_weight() +
weights::BizinikiwiWeight::<T>::step() * 16;
MigratorServiceWeight::set(&limit);
@@ -27,10 +27,10 @@
// pezkuwi-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --runtime
// target/release/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.compact.compressed.wasm
// --pallet
// --pezpallet
// pezpallet_example_mbm
// --extrinsic
//
@@ -67,7 +67,7 @@ construct_runtime! {
pub struct Runtime
{
System: pezframe_system,
Pallet: crate,
Pezpallet: crate,
Migrator: pezpallet_migrations,
}
}
@@ -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_example_mbm
// --pezpallet=pezpallet_example_mbm
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/examples/multi-block-migrations/src/weights.rs
// --wasm-execution=compiled
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet for offchain worker"
description = "FRAME example pezpallet for offchain worker"
readme = "README.md"
publish = false
documentation = "https://docs.rs/pezpallet-example-offchain-worker"
@@ -1,7 +1,7 @@
<!-- markdown-link-check-disable -->
# Offchain Worker Example Pallet
# Offchain Worker Example Pezpallet
The Offchain Worker Example: A simple pallet demonstrating
The Offchain Worker Example: A simple pezpallet demonstrating
concepts, APIs and structures common to most offchain workers.
Run `cargo doc --package pezpallet-example-offchain-worker --open` to view this module's
@@ -11,7 +11,7 @@ documentation.
- [`Call`](./enum.Call.html)
- [`Module`](./struct.Module.html)
**This pallet serves as an example showcasing Bizinikiwi off-chain worker and is not meant to be
**This pezpallet serves as an example showcasing Bizinikiwi off-chain worker and is not meant to be
used in production.**
## Overview
@@ -22,9 +22,9 @@
// SOFTWARE.
//! <!-- markdown-link-check-disable -->
//! # Offchain Worker Example Pallet
//! # Offchain Worker Example Pezpallet
//!
//! The Offchain Worker Example: A simple pallet demonstrating
//! The Offchain Worker Example: A simple pezpallet demonstrating
//! concepts, APIs and structures common to most offchain workers.
//!
//! Run `cargo doc --package pezpallet-example-offchain-worker --open` to view this module's
@@ -32,9 +32,9 @@
//!
//! - [`Config`]
//! - [`Call`]
//! - [`Pallet`]
//! - [`Pezpallet`]
//!
//! **This pallet serves as an example showcasing Bizinikiwi off-chain worker and is not meant to
//! **This pezpallet serves as an example showcasing Bizinikiwi off-chain worker and is not meant to
//! be used in production.**
//!
//! ## Overview
@@ -120,16 +120,16 @@ pub mod crypto {
}
}
pub use pallet::*;
pub use pezpallet::*;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// This pallet's configuration trait
#[pallet::config]
/// This pezpallet's configuration trait
#[pezpallet::config]
pub trait Config:
CreateSignedTransaction<Call<Self>> + CreateBare<Call<Self>> + pezframe_system::Config
{
@@ -143,33 +143,33 @@ pub mod pallet {
/// To avoid sending too many transactions, we only attempt to send one
/// every `GRACE_PERIOD` blocks. We use Local Storage to coordinate
/// sending between distinct runs of this offchain worker.
#[pallet::constant]
#[pezpallet::constant]
type GracePeriod: Get<BlockNumberFor<Self>>;
/// Number of blocks of cooldown after unsigned transaction is included.
///
/// This ensures that we only accept unsigned transactions once, every `UnsignedInterval`
/// blocks.
#[pallet::constant]
#[pezpallet::constant]
type UnsignedInterval: Get<BlockNumberFor<Self>>;
/// A configuration for base priority of unsigned transactions.
///
/// This is exposed so that it can be tuned for particular runtime, when
/// multiple pallets send unsigned transactions.
#[pallet::constant]
#[pezpallet::constant]
type UnsignedPriority: Get<TransactionPriority>;
/// Maximum number of prices.
#[pallet::constant]
#[pezpallet::constant]
type MaxPrices: Get<u32>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
/// Offchain Worker entry point.
///
/// By implementing `fn offchain_worker` you declare a new offchain worker.
@@ -190,7 +190,7 @@ pub mod pallet {
// to the storage and other included pallets.
//
// We can easily import `pezframe_system` and retrieve a block hash of the parent block.
let parent_hash = <system::Pallet<T>>::block_hash(block_number - 1u32.into());
let parent_hash = <system::Pezpallet<T>>::block_hash(block_number - 1u32.into());
log::debug!("Current block: {:?} (parent hash: {:?})", block_number, parent_hash);
// It's a good practice to keep `fn offchain_worker()` function minimal, and move most
@@ -219,9 +219,9 @@ pub mod pallet {
}
}
/// A public part of the pallet.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// A public part of the pezpallet.
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Submit new price to the list.
///
/// This method is a public function of the module and can be called from within
@@ -236,8 +236,8 @@ pub mod pallet {
/// working and receives (and provides) meaningful data.
/// This example is not focused on correctness of the oracle itself, but rather its
/// purpose is to showcase offchain worker capabilities.
#[pallet::call_index(0)]
#[pallet::weight({0})]
#[pezpallet::call_index(0)]
#[pezpallet::weight({0})]
pub fn submit_price(origin: OriginFor<T>, price: u32) -> DispatchResultWithPostInfo {
// Retrieve sender of the transaction.
let who = ensure_signed(origin)?;
@@ -262,8 +262,8 @@ pub mod pallet {
///
/// This example is not focused on correctness of the oracle itself, but rather its
/// purpose is to showcase offchain worker capabilities.
#[pallet::call_index(1)]
#[pallet::weight({0})]
#[pezpallet::call_index(1)]
#[pezpallet::weight({0})]
pub fn submit_price_unsigned(
origin: OriginFor<T>,
_block_number: BlockNumberFor<T>,
@@ -274,13 +274,13 @@ pub mod pallet {
// Add the price to the on-chain list, but mark it as coming from an empty address.
Self::add_price(None, price);
// now increment the block number at which we expect next unsigned transaction.
let current_block = <system::Pallet<T>>::block_number();
let current_block = <system::Pezpallet<T>>::block_number();
<NextUnsignedAt<T>>::put(current_block + T::UnsignedInterval::get());
Ok(().into())
}
#[pallet::call_index(2)]
#[pallet::weight({0})]
#[pezpallet::call_index(2)]
#[pezpallet::weight({0})]
pub fn submit_price_unsigned_with_signed_payload(
origin: OriginFor<T>,
price_payload: PricePayload<T::Public, BlockNumberFor<T>>,
@@ -291,22 +291,22 @@ pub mod pallet {
// Add the price to the on-chain list, but mark it as coming from an empty address.
Self::add_price(None, price_payload.price);
// now increment the block number at which we expect next unsigned transaction.
let current_block = <system::Pallet<T>>::block_number();
let current_block = <system::Pezpallet<T>>::block_number();
<NextUnsignedAt<T>>::put(current_block + T::UnsignedInterval::get());
Ok(().into())
}
}
/// Events for the pallet.
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
/// Events for the pezpallet.
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Event generated when new price is accepted to contribute to the average.
NewPrice { price: u32, maybe_who: Option<T::AccountId> },
}
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
#[pezpallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pezpallet<T> {
type Call = Call<T>;
/// Validate unsigned call to this module.
@@ -338,7 +338,7 @@ pub mod pallet {
/// A vector of recently submitted prices.
///
/// This is used to calculate average price, should have bounded size.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Prices<T: Config> = StorageValue<_, BoundedVec<u32, T::MaxPrices>, ValueQuery>;
/// Defines the block when next unsigned transaction will be accepted.
@@ -346,7 +346,7 @@ pub mod pallet {
/// To prevent spam of unsigned (and unpaid!) transactions on the network,
/// we only allow one transaction every `T::UnsignedInterval` blocks.
/// This storage entry defines when new transaction is going to be accepted.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type NextUnsignedAt<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
}
@@ -375,7 +375,7 @@ enum TransactionType {
None,
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Chooses which transaction type to send.
///
/// This function serves mostly to showcase `StorageValue` helper
@@ -465,7 +465,7 @@ impl<T: Config> Pallet<T> {
// local keystore with expected `KEY_TYPE`.
let results = signer.send_signed_transaction(|_account| {
// Received price is wrapped into a call to `submit_price` public function of this
// pallet. This means that the transaction, when executed, will simply call that
// pezpallet. This means that the transaction, when executed, will simply call that
// function passing `price` as an argument.
Call::submit_price { price }
});
@@ -496,7 +496,7 @@ impl<T: Config> Pallet<T> {
let price = Self::fetch_price().map_err(|_| "Failed to fetch price")?;
// Received price is wrapped into a call to `submit_price_unsigned` public function of this
// pallet. This means that the transaction, when executed, will simply call that function
// pezpallet. This means that the transaction, when executed, will simply call that function
// passing `price` as an argument.
let call = Call::submit_price_unsigned { block_number, price };
@@ -690,7 +690,7 @@ impl<T: Config> Pallet<T> {
return InvalidTransaction::Stale.into();
}
// Let's make sure to reject transactions from the future.
let current_block = <system::Pallet<T>>::block_number();
let current_block = <system::Pezpallet<T>>::block_number();
if &current_block < block_number {
return InvalidTransaction::Future.into();
}
@@ -9,7 +9,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet with umbrella crate"
description = "FRAME example pezpallet with umbrella crate"
publish = false
documentation = "https://docs.rs/pezpallet-example-pezframe-crate"
@@ -23,24 +23,24 @@
use frame::prelude::*;
#[frame::pallet(dev_mode)]
pub mod pallet {
#[frame::pezpallet(dev_mode)]
pub mod pezpallet {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::event]
#[pezpallet::event]
pub enum Event<T: Config> {}
#[pallet::storage]
#[pezpallet::storage]
pub type Value<T> = StorageValue<Value = u32>;
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn some_dispatchable(_origin: OriginFor<T>) -> DispatchResult {
Ok(())
}
@@ -49,7 +49,7 @@ pub mod pallet {
#[cfg(test)]
mod tests {
use crate::pallet as my_pallet;
use crate::pezpallet as my_pallet;
use frame::testing_prelude::*;
construct_runtime!(
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet demonstrating best-practices for writing storage migrations."
description = "FRAME example pezpallet demonstrating best-practices for writing storage migrations."
publish = false
documentation = "https://docs.rs/pezpallet-example-single-block-migrations"
@@ -21,10 +21,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Single Block Migration Example Pallet
//! # Single Block Migration Example Pezpallet
//!
//! An example pallet demonstrating best-practices for writing single-block migrations in the
//! context of upgrading pallet storage.
//! An example pezpallet demonstrating best-practices for writing single-block migrations in the
//! context of upgrading pezpallet storage.
//!
//! ## Forewarning
//!
@@ -37,26 +37,26 @@
//!
//! TODO: Link above to multi-block migration example.
//!
//! ## Pallet Overview
//! ## Pezpallet Overview
//!
//! This example pallet contains a single storage item [`Value`](pallet::Value), which may be set by
//! This example pezpallet contains a single storage item [`Value`](pezpallet::Value), which may be set by
//! any signed origin by calling the [`set_value`](crate::Call::set_value) extrinsic.
//!
//! For the purposes of this exercise, we imagine that in [`StorageVersion`] V0 of this pallet
//! [`Value`](pallet::Value) is a `u32`, and this what is currently stored on-chain.
//! For the purposes of this exercise, we imagine that in [`StorageVersion`] V0 of this pezpallet
//! [`Value`](pezpallet::Value) is a `u32`, and this what is currently stored on-chain.
//!
//! ```ignore
//! // (Old) Storage Version V0 representation of `Value`
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Value<T: Config> = StorageValue<_, u32>;
//! ```
//!
//! In [`StorageVersion`] V1 of the pallet a new struct [`CurrentAndPreviousValue`] is introduced:
//! In [`StorageVersion`] V1 of the pezpallet a new struct [`CurrentAndPreviousValue`] is introduced:
#![doc = docify::embed!("src/lib.rs", CurrentAndPreviousValue)]
//! and [`Value`](pallet::Value) is updated to store this new struct instead of a `u32`:
//! and [`Value`](pezpallet::Value) is updated to store this new struct instead of a `u32`:
#![doc = docify::embed!("src/lib.rs", Value)]
//!
//! In StorageVersion V1 of the pallet when [`set_value`](crate::Call::set_value) is called, the
//! In StorageVersion V1 of the pezpallet when [`set_value`](crate::Call::set_value) is called, the
//! new value is stored in the `current` field of [`CurrentAndPreviousValue`], and the previous
//! value (if it exists) is stored in the `previous` field.
#![doc = docify::embed!("src/lib.rs", pezpallet_calls)]
@@ -74,18 +74,18 @@
//!
//! Writing a pallets migrations in a separate module is strongly recommended.
//!
//! Here's how the migration module is defined for this pallet:
//! Here's how the migration module is defined for this pezpallet:
//!
//! ```text
//! bizinikiwi/pezframe/examples/single-block-migrations/src/
//! ├── lib.rs <-- pallet definition
//! ├── Cargo.toml <-- pallet manifest
//! ├── lib.rs <-- pezpallet definition
//! ├── Cargo.toml <-- pezpallet manifest
//! └── migrations/
//! ├── mod.rs <-- migrations module definition
//! └── v1.rs <-- migration logic for the V0 to V1 transition
//! ```
//!
//! This structure allows keeping migration logic separate from the pallet logic and
//! This structure allows keeping migration logic separate from the pezpallet logic and
//! easily adding new migrations in the future.
//!
//! ## Writing the Migration
@@ -114,12 +114,12 @@
//! Otherwise, we would have two implementations of [`OnRuntimeUpgrade`] which could be confusing,
//! and may lead to accidentally using the wrong one.
//!
//! #### Standalone Struct or Pallet Hook?
//! #### Standalone Struct or Pezpallet Hook?
//!
//! Note that the storage migration logic is attached to a standalone struct implementing
//! [`UncheckedOnRuntimeUpgrade`], rather than implementing the
//! [`Hooks::on_runtime_upgrade`](pezframe_support::traits::Hooks::on_runtime_upgrade) hook directly on
//! the pallet. The pallet hook is better suited for special types of logic that need to execute on
//! the pezpallet. The pezpallet hook is better suited for special types of logic that need to execute on
//! every runtime upgrade, but not so much for one-off storage migrations.
//!
//! ### `MigrateV0ToV1`
@@ -142,7 +142,7 @@
//! When writing migration tests, don't forget to check:
//! - `on_runtime_upgrade` returns the expected weight
//! - `post_upgrade` succeeds when given the bytes returned by `pre_upgrade`
//! - Pallet storage is in the expected state after the migration
//! - Pezpallet storage is in the expected state after the migration
//!
//! [`VersionedMigration`]: pezframe_support::migrations::VersionedMigration
//! [`GetStorageVersion`]: pezframe_support::traits::GetStorageVersion
@@ -150,13 +150,13 @@
//! [`UncheckedOnRuntimeUpgrade`]: pezframe_support::traits::UncheckedOnRuntimeUpgrade
//! [`MigrateV0ToV1`]: crate::migrations::v1::MigrateV0ToV1
// We make sure this pallet uses `no_std` for compiling to Wasm.
// We make sure this pezpallet uses `no_std` for compiling to Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
// allow non-camel-case names for storage version V0 value
#![allow(non_camel_case_types)]
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
// Export migrations so they may be used in the runtime.
pub mod migrations;
@@ -182,33 +182,33 @@ pub struct CurrentAndPreviousValue {
pub previous: Option<u32>,
}
// Pallet for demonstrating storage migrations.
#[pezframe_support::pallet(dev_mode)]
pub mod pallet {
// Pezpallet for demonstrating storage migrations.
#[pezframe_support::pezpallet(dev_mode)]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// Define the current [`StorageVersion`] of the pallet.
/// Define the current [`StorageVersion`] of the pezpallet.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
/// [`StorageVersion`] V1 of [`Value`].
///
/// Currently used.
#[docify::export]
#[pallet::storage]
#[pezpallet::storage]
pub type Value<T: Config> = StorageValue<_, CurrentAndPreviousValue>;
#[docify::export(pezpallet_calls)]
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn set_value(origin: OriginFor<T>, value: u32) -> DispatchResult {
ensure_signed(origin)?;
@@ -37,15 +37,15 @@ mod v0 {
/// V0 type for [`crate::Value`].
#[storage_alias]
pub type Value<T: crate::Config> = StorageValue<crate::Pallet<T>, u32>;
pub type Value<T: crate::Config> = StorageValue<crate::Pezpallet<T>, u32>;
}
/// Implements [`UncheckedOnRuntimeUpgrade`], migrating the state of this pallet from V0 to V1.
/// Implements [`UncheckedOnRuntimeUpgrade`], migrating the state of this pezpallet from V0 to V1.
///
/// In V0 of the template [`crate::Value`] is just a `u32`. In V1, it has been upgraded to
/// contain the struct [`crate::CurrentAndPreviousValue`].
///
/// In this migration, update the on-chain storage for the pallet to reflect the new storage
/// In this migration, update the on-chain storage for the pezpallet to reflect the new storage
/// layout.
pub struct InnerMigrateV0ToV1<T: crate::Config>(core::marker::PhantomData<T>);
@@ -123,7 +123,7 @@ pub type MigrateV0ToV1<T> = pezframe_support::migrations::VersionedMigration<
0, // The migration will only execute when the on-chain storage version is 0
1, // The on-chain storage version will be set to 1 after the migration is complete
InnerMigrateV0ToV1<T>,
crate::pallet::Pallet<T>,
crate::pezpallet::Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
@@ -26,17 +26,17 @@
use crate::*;
use pezframe_support::{derive_impl, weights::constants::ParityDbWeight};
// Re-export crate as its pallet name for construct_runtime.
// Re-export crate as its pezpallet name for construct_runtime.
use crate as pezpallet_example_storage_migration;
type Block = pezframe_system::mocking::MockBlock<MockRuntime>;
// For testing the pallet, we construct a mock runtime.
// For testing the pezpallet, we construct a mock runtime.
pezframe_support::construct_runtime!(
pub struct MockRuntime {
System: pezframe_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pezpallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Example: pezpallet_example_storage_migration::{Pallet, Call, Storage},
System: pezframe_system::{Pezpallet, Call, Config<T>, Storage, Event<T>},
Balances: pezpallet_balances::{Pezpallet, Call, Storage, Config<T>, Event<T>},
Example: pezpallet_example_storage_migration::{Pezpallet, Call, Storage},
}
);
@@ -6,7 +6,7 @@ edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example split pallet"
description = "FRAME example split pezpallet"
readme = "README.md"
publish = false
documentation = "https://docs.rs/pezpallet-example-split"
+3 -3
View File
@@ -1,10 +1,10 @@
<!-- markdown-link-check-disable -->
# Basic Example For Splitting A Pallet
A simple example of a FRAME pallet demonstrating the ability to split sections across multiple
# Basic Example For Splitting A Pezpallet
A simple example of a FRAME pezpallet demonstrating the ability to split sections across multiple
files.
Note that this is purely experimental at this point.
Run `cargo doc --package pezpallet-example-split --open` to view this pallet's documentation.
Run `cargo doc --package pezpallet-example-split --open` to view this pezpallet's documentation.
License: MIT-0
@@ -28,7 +28,7 @@
use super::*;
#[allow(unused)]
use crate::Pallet as Template;
use crate::Pezpallet as Template;
use pezframe_benchmarking::v2::*;
use pezframe_system::RawOrigin;
@@ -23,12 +23,12 @@
use pezframe_support::pezpallet_macros::*;
/// A [`pezpallet_section`] that defines the events for a pallet.
/// This can later be imported into the pallet using [`import_section`].
/// A [`pezpallet_section`] that defines the events for a pezpallet.
/// This can later be imported into the pezpallet using [`import_section`].
#[pezpallet_section]
mod events {
#[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> {
/// Event documentation should end with an array that provides descriptive names for event
/// parameters. [something, who]
+23 -23
View File
@@ -21,18 +21,18 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Split Example Pallet
//! # Split Example Pezpallet
//!
//! **This pallet serves as an example and is not meant to be used in production.**
//! **This pezpallet serves as an example and is not meant to be used in production.**
//!
//! A FRAME pallet demonstrating the ability to split sections across multiple files.
//! A FRAME pezpallet demonstrating the ability to split sections across multiple files.
//!
//! Note that this is purely experimental at this point.
#![cfg_attr(not(feature = "std"), no_std)]
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
#[cfg(test)]
mod mock;
@@ -50,30 +50,30 @@ pub use weights::*;
use pezframe_support::pezpallet_macros::*;
/// Imports a [`pezpallet_section`] defined at [`events::events`].
/// This brings the events defined in that section into the pallet's namespace.
/// This brings the events defined in that section into the pezpallet's namespace.
#[import_section(events::events)]
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
/// Configure the pezpallet by specifying the parameters and types on which it depends.
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Type representing the weight of this pallet
/// Type representing the weight of this pezpallet
type WeightInfo: WeightInfo;
}
// The pallet's runtime storage items.
#[pallet::storage]
// The pezpallet's runtime storage items.
#[pezpallet::storage]
pub type Something<T> = StorageValue<_, u32>;
// Errors inform users that something went wrong.
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Error names should be descriptive.
NoneValue,
@@ -81,15 +81,15 @@ pub mod pallet {
StorageOverflow,
}
// Dispatchable functions allows users to interact with the pallet and invoke state changes.
// Dispatchable functions allows users to interact with the pezpallet and invoke state changes.
// These functions materialize as "extrinsics", which are often compared to transactions.
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// An example dispatchable that takes a singles value as a parameter, writes the value to
/// storage and emits an event. This function must be dispatched by a signed extrinsic.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::do_something())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::do_something())]
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
// Check that the extrinsic was signed and get the signer.
// This function will return an error if the extrinsic is not signed.
@@ -105,8 +105,8 @@ pub mod pallet {
}
/// An example dispatchable that may throw a custom error.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::cause_error())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::cause_error())]
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
let _who = ensure_signed(origin)?;
@@ -26,7 +26,7 @@ use pezframe_support::{derive_impl, pezsp_runtime::BuildStorage};
type Block = pezframe_system::mocking::MockBlock<Test>;
// Configure a mock runtime to test the pallet.
// Configure a mock runtime to test the pezpallet.
pezframe_support::construct_runtime!(
pub enum Test
{
@@ -31,7 +31,7 @@ fn it_works_for_default_value() {
System::set_block_number(1);
// Dispatch a signed extrinsic.
assert_ok!(TemplatePallet::do_something(RuntimeOrigin::signed(1), 42));
// Read pallet storage and assert an expected result.
// Read pezpallet storage and assert an expected result.
assert_eq!(Something::<Test>::get(), Some(42));
// Assert that the correct event was deposited
System::assert_last_event(Event::SomethingStored { something: 42, who: 1 }.into());
@@ -32,10 +32,10 @@
// Executed Command:
// ../../target/release/node-template
// benchmark
// pallet
// pezpallet
// --chain
// dev
// --pallet
// --pezpallet
// pezpallet_template
// --extrinsic
// *
+13 -13
View File
@@ -15,44 +15,44 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # FRAME Pallet Examples
//! # FRAME Pezpallet Examples
//!
//! This crate contains a collection of simple examples of FRAME pallets, demonstrating useful
//! features in action. It is not intended to be used in production.
//!
//! ## Pallets
//!
//! - [`pezpallet_example_basic`]: This pallet demonstrates concepts, APIs and structures common to
//! - [`pezpallet_example_basic`]: This pezpallet demonstrates concepts, APIs and structures common to
//! most FRAME runtimes.
//!
//! - [`pezpallet_example_offchain_worker`]: This pallet demonstrates concepts, APIs and structures
//! - [`pezpallet_example_offchain_worker`]: This pezpallet demonstrates concepts, APIs and structures
//! common to most offchain workers.
//!
//! - [`pezpallet_default_config_example`]: This pallet demonstrates different ways to implement the
//! - [`pezpallet_default_config_example`]: This pezpallet demonstrates different ways to implement the
//! `Config` trait of pallets.
//!
//! - [`pezpallet_dev_mode`]: This pallet demonstrates the ease of requirements for a pallet in "dev
//! - [`pezpallet_dev_mode`]: This pezpallet demonstrates the ease of requirements for a pezpallet in "dev
//! mode".
//!
//! - [`pezpallet_example_kitchensink`]: This pallet demonstrates a catalog of all FRAME macros in use
//! - [`pezpallet_example_kitchensink`]: This pezpallet demonstrates a catalog of all FRAME macros in use
//! and their various syntax options.
//!
//! - [`pezpallet_example_split`]: A simple example of a FRAME pallet demonstrating the ability to
//! - [`pezpallet_example_split`]: A simple example of a FRAME pezpallet demonstrating the ability to
//! split sections across multiple files.
//!
//! - [`pezpallet_example_frame_crate`]: Example pallet showcasing how one can be built using only the
//! - [`pezpallet_example_frame_crate`]: Example pezpallet showcasing how one can be built using only the
//! `frame` umbrella crate.
//!
//! - [`pezpallet_example_single_block_migrations`]: An example pallet demonstrating best-practices for
//! - [`pezpallet_example_single_block_migrations`]: An example pezpallet demonstrating best-practices for
//! writing storage migrations.
//!
//! - [`pezpallet_example_tasks`]: This pallet demonstrates the use of `Tasks` to execute service work.
//! - [`pezpallet_example_tasks`]: This pezpallet demonstrates the use of `Tasks` to execute service work.
//!
//! - [`pezpallet_example_view_functions`]: This pallet demonstrates the use of view functions to query
//! pallet state.
//! - [`pezpallet_example_view_functions`]: This pezpallet demonstrates the use of view functions to query
//! pezpallet state.
//!
//! - [`pezpallet_example_authorization_tx_extension`]: An example `TransactionExtension` that
//! authorizes a custom origin through signature validation, along with two support pallets to
//! showcase the usage.
//!
//! **Tip**: Use `cargo doc --package <pezpallet-name> --open` to view each pallet's documentation.
//! **Tip**: Use `cargo doc --package <pezpallet-name> --open` to view each pezpallet's documentation.
@@ -38,5 +38,5 @@ mod benchmarks {
assert_eq!(Numbers::<T>::get(0), None);
}
impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::mock::Runtime);
impl_benchmark_test_suite!(Pezpallet, crate::tests::new_test_ext(), crate::mock::Runtime);
}
+19 -19
View File
@@ -15,15 +15,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! This pallet demonstrates the use of the `pallet::task` api for service work.
//! This pezpallet demonstrates the use of the `pezpallet::task` api for service work.
#![cfg_attr(not(feature = "std"), no_std)]
use pezframe_support::dispatch::DispatchResult;
use pezframe_system::offchain::CreateBare;
#[cfg(feature = "experimental")]
use pezframe_system::offchain::SubmitTransaction;
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
pub mod mock;
pub mod tests;
@@ -37,25 +37,25 @@ pub use weights::*;
#[cfg(feature = "experimental")]
const LOG_TARGET: &str = "pezpallet-example-tasks";
#[pezframe_support::pallet(dev_mode)]
pub mod pallet {
#[pezframe_support::pezpallet(dev_mode)]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The referenced task was not found.
NotFound,
}
#[pallet::tasks_experimental]
impl<T: Config> Pallet<T> {
#[pezpallet::tasks_experimental]
impl<T: Config> Pezpallet<T> {
/// Add a pair of numbers into the totals and remove them.
#[pallet::task_list(Numbers::<T>::iter_keys())]
#[pallet::task_condition(|i| Numbers::<T>::contains_key(i))]
#[pallet::task_weight(T::WeightInfo::add_number_into_total())]
#[pallet::task_index(0)]
#[pezpallet::task_list(Numbers::<T>::iter_keys())]
#[pezpallet::task_condition(|i| Numbers::<T>::contains_key(i))]
#[pezpallet::task_weight(T::WeightInfo::add_number_into_total())]
#[pezpallet::task_index(0)]
pub fn add_number_into_total(i: u32) -> DispatchResult {
let v = Numbers::<T>::take(i).ok_or(Error::<T>::NotFound)?;
Total::<T>::mutate(|(total_keys, total_values)| {
@@ -66,8 +66,8 @@ pub mod pallet {
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
#[cfg(feature = "experimental")]
fn offchain_worker(_block_number: BlockNumberFor<T>) {
if let Some(key) = Numbers::<T>::iter_keys().next() {
@@ -90,7 +90,7 @@ pub mod pallet {
fn offchain_worker(_block_number: BlockNumberFor<T>) {}
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: CreateBare<pezframe_system::Call<Self>> + pezframe_system::Config {
type RuntimeTask: pezframe_support::traits::Task
+ IsType<<Self as pezframe_system::Config>::RuntimeTask>
@@ -98,14 +98,14 @@ pub mod pallet {
type WeightInfo: WeightInfo;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// Some running total.
#[pallet::storage]
#[pezpallet::storage]
pub type Total<T: Config> = StorageValue<_, (u32, u32), ValueQuery>;
/// Numbers to be added into the total.
#[pallet::storage]
#[pezpallet::storage]
pub type Numbers<T: Config> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
}
@@ -45,7 +45,7 @@ pub fn new_test_ext() -> pezsp_io::TestExternalities {
fn task_enumerate_works() {
new_test_ext().execute_with(|| {
Numbers::<Runtime>::insert(0, 1);
assert_eq!(crate::pallet::Task::<Runtime>::iter().collect::<Vec<_>>().len(), 1);
assert_eq!(crate::pezpallet::Task::<Runtime>::iter().collect::<Vec<_>>().len(), 1);
});
}
@@ -66,7 +66,7 @@ fn runtime_task_enumerate_works_via_pallet_config() {
new_test_ext().execute_with(|| {
Numbers::<Runtime>::insert(1, 4);
assert_eq!(
<Runtime as crate::pallet::Config>::RuntimeTask::iter()
<Runtime as crate::pezpallet::Config>::RuntimeTask::iter()
.collect::<Vec<_>>()
.len(),
1
@@ -77,7 +77,7 @@ fn runtime_task_enumerate_works_via_pallet_config() {
#[test]
fn task_index_works_at_pallet_level() {
new_test_ext().execute_with(|| {
assert_eq!(crate::pallet::Task::<Runtime>::AddNumberIntoTotal { i: 2u32 }.task_index(), 0);
assert_eq!(crate::pezpallet::Task::<Runtime>::AddNumberIntoTotal { i: 2u32 }.task_index(), 0);
});
}
@@ -85,7 +85,7 @@ fn task_index_works_at_pallet_level() {
fn task_index_works_at_runtime_level() {
new_test_ext().execute_with(|| {
assert_eq!(
<Runtime as pezframe_system::Config>::RuntimeTask::TasksExample(crate::pallet::Task::<
<Runtime as pezframe_system::Config>::RuntimeTask::TasksExample(crate::pezpallet::Task::<
Runtime,
>::AddNumberIntoTotal {
i: 1u32
@@ -105,7 +105,7 @@ fn task_execution_works() {
Numbers::<Runtime>::insert(1, 4);
let task =
<Runtime as pezframe_system::Config>::RuntimeTask::TasksExample(crate::pallet::Task::<
<Runtime as pezframe_system::Config>::RuntimeTask::TasksExample(crate::pezpallet::Task::<
Runtime,
>::AddNumberIntoTotal {
i: 1u32,
@@ -127,7 +127,7 @@ fn task_execution_fails_for_invalid_task() {
System::do_task(
RuntimeOrigin::signed(1),
<Runtime as pezframe_system::Config>::RuntimeTask::TasksExample(
crate::pallet::Task::<Runtime>::AddNumberIntoTotal { i: 0u32 }
crate::pezpallet::Task::<Runtime>::AddNumberIntoTotal { i: 0u32 }
),
),
pezframe_system::Error::<Runtime>::InvalidTask
@@ -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_example_tasks
// --pezpallet=pezpallet_example_tasks
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/examples/tasks/src/weights.rs
// --wasm-execution=compiled
@@ -6,7 +6,7 @@ edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "Pallet to demonstrate the usage of view functions to query pallet state"
description = "Pallet to demonstrate the usage of view functions to query pezpallet state"
documentation = "https://docs.rs/pezpallet-example-view-functions"
publish = false
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! This pallet demonstrates the use of the `pallet::view_functions` api for service
//! This pezpallet demonstrates the use of the `pezpallet::view_functions` api for service
//! work.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -38,28 +38,28 @@ impl SomeAssociation1 for u64 {
type _1 = u64;
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::storage]
#[pezpallet::storage]
pub type SomeValue<T: Config> = StorageValue<_, u32>;
#[pallet::storage]
#[pezpallet::storage]
pub type SomeMap<T: Config> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
#[pallet::view_functions]
impl<T: Config> Pallet<T>
#[pezpallet::view_functions]
impl<T: Config> Pezpallet<T>
where
T::AccountId: From<SomeType1> + SomeAssociation1,
{
@@ -75,29 +75,29 @@ pub mod pallet {
}
}
#[pezframe_support::pallet]
#[pezframe_support::pezpallet]
pub mod pallet2 {
use super::*;
use pezframe_support::pezpallet_prelude::*;
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {}
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
#[pallet::storage]
#[pezpallet::storage]
pub type SomeValue<T: Config<I>, I: 'static = ()> = StorageValue<_, u32>;
#[pallet::storage]
#[pezpallet::storage]
pub type SomeMap<T: Config<I>, I: 'static = ()> =
StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
#[pallet::view_functions]
impl<T: Config<I>, I: 'static> Pallet<T, I>
#[pezpallet::view_functions]
impl<T: Config<I>, I: 'static> Pezpallet<T, I>
where
T::AccountId: From<SomeType1> + SomeAssociation1,
{
@@ -19,7 +19,7 @@
#![cfg(test)]
use crate::{
pallet::{self, Pallet},
pezpallet::{self, Pezpallet},
pallet2,
};
use codec::{Decode, Encode};
@@ -39,7 +39,7 @@ type Block = pezframe_system::mocking::MockBlock<Runtime>;
pezframe_support::construct_runtime!(
pub enum Runtime {
System: pezframe_system,
ViewFunctionsExample: pallet,
ViewFunctionsExample: pezpallet,
ViewFunctionsInstance: pallet2,
ViewFunctionsInstance1: pallet2::<Instance1>,
}
@@ -52,7 +52,7 @@ impl pezframe_system::Config for Runtime {
type Block = Block;
}
impl pallet::Config for Runtime {}
impl pezpallet::Config for Runtime {}
impl pallet2::Config<pallet2::Instance1> for Runtime {}
impl pallet2::Config for Runtime {}
@@ -68,10 +68,10 @@ pub fn new_test_ext() -> pezsp_io::TestExternalities {
fn pezpallet_get_value_query() {
new_test_ext().execute_with(|| {
let some_value = Some(99);
pallet::SomeValue::<Runtime>::set(some_value);
assert_eq!(some_value, Pallet::<Runtime>::get_value());
pezpallet::SomeValue::<Runtime>::set(some_value);
assert_eq!(some_value, Pezpallet::<Runtime>::get_value());
let query = pallet::GetValueViewFunction::<Runtime>::new();
let query = pezpallet::GetValueViewFunction::<Runtime>::new();
test_dispatch_view_function(&query, some_value);
});
}
@@ -81,10 +81,10 @@ fn pezpallet_get_value_with_arg_query() {
new_test_ext().execute_with(|| {
let some_key = 1u32;
let some_value = Some(123);
pallet::SomeMap::<Runtime>::set(some_key, some_value);
assert_eq!(some_value, Pallet::<Runtime>::get_value_with_arg(some_key));
pezpallet::SomeMap::<Runtime>::set(some_key, some_value);
assert_eq!(some_value, Pezpallet::<Runtime>::get_value_with_arg(some_key));
let query = pallet::GetValueWithArgViewFunction::<Runtime>::new(some_key);
let query = pezpallet::GetValueWithArgViewFunction::<Runtime>::new(some_key);
test_dispatch_view_function(&query, some_value);
});
}
@@ -115,7 +115,7 @@ fn metadata_ir_definitions() {
let pallet1 = metadata_ir
.pallets
.iter()
.find(|pallet| pallet.name == "ViewFunctionsExample")
.find(|pezpallet| pezpallet.name == "ViewFunctionsExample")
.unwrap();
fn view_fn_id(preifx_hash: [u8; 16], view_fn_signature: &str) -> [u8; 32] {