chore: regenerate umbrella crate, fix feature propagation

This commit is contained in:
2025-12-16 11:28:32 +03:00
parent dd6d48f528
commit 620b0e3aa0
1358 changed files with 9464 additions and 7656 deletions
@@ -50,9 +50,10 @@ fn tasks_work() {
super::new_test_ext().execute_with(|| {
Numbers::<Runtime>::insert(0, 1);
let task = RuntimeTask::System(super::pezframe_system::Task::<Runtime>::AddNumberIntoTotal {
i: 0u32,
});
let task =
RuntimeTask::System(super::pezframe_system::Task::<Runtime>::AddNumberIntoTotal {
i: 0u32,
});
assert_ok!(System::do_task(RuntimeOrigin::signed(1), task.clone(),));
assert_eq!(Numbers::<Runtime>::get(0), None);
@@ -20,7 +20,10 @@ use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_freeze_reason(pezpallet_decls: &[Pezpallet], scrate: &TokenStream) -> TokenStream {
pub fn expand_outer_freeze_reason(
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut conversion_fns = Vec::new();
let mut freeze_reason_variants = Vec::new();
let mut freeze_reason_variants_count = Vec::new();
@@ -20,7 +20,10 @@ use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_hold_reason(pezpallet_decls: &[Pezpallet], scrate: &TokenStream) -> TokenStream {
pub fn expand_outer_hold_reason(
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut conversion_fns = Vec::new();
let mut hold_reason_variants = Vec::new();
let mut hold_reason_variants_count = Vec::new();
@@ -20,7 +20,10 @@ use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_slash_reason(pezpallet_decls: &[Pezpallet], scrate: &TokenStream) -> TokenStream {
pub fn expand_outer_slash_reason(
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut conversion_fns = Vec::new();
let mut slash_reason_variants = Vec::new();
for decl in pezpallet_decls {
@@ -28,9 +28,9 @@
//! From the explicit state, Bizinikiwi expands the pallets with additional information
//! that is to be included in the runtime metadata. This expansion makes visible some extra
//! parts of the pallets, mainly the `Error` if defined. The expanded state looks like
//! `System: pezframe_system expanded::{Error} ::{Pezpallet, Call}` and concatenates the extra expanded
//! parts with the user-provided parts. For example, the `Pezpallet`, `Call` and `Error` parts are
//! collected.
//! `System: pezframe_system expanded::{Error} ::{Pezpallet, Call}` and concatenates the extra
//! expanded parts with the user-provided parts. For example, the `Pezpallet`, `Call` and `Error`
//! parts are collected.
//!
//! Pallets must provide the `tt_extra_parts` and `tt_default_parts` macros for these transitions.
//! These are automatically implemented by the `#[pezpallet::pezpallet]` macro.
@@ -38,9 +38,9 @@
//! This macro also generates the following enums for ease of decoding:
//! - `enum RuntimeCall`: This type contains the information needed to decode extrinsics.
//! - `enum RuntimeEvent`: This type contains the information needed to decode events.
//! - `enum RuntimeError`: While this cannot be used directly to decode `pezsp_runtime::DispatchError`
//! from the chain, it contains the information needed to decode the
//! `pezsp_runtime::DispatchError::Module`.
//! - `enum RuntimeError`: While this cannot be used directly to decode
//! `pezsp_runtime::DispatchError` from the chain, it contains the information needed to decode
//! the `pezsp_runtime::DispatchError::Module`.
//!
//! # State Transitions
//!
@@ -63,12 +63,13 @@
//! # Implicit to Explicit
//!
//! The `construct_runtime` macro transforms the implicit declaration of each pezpallet
//! `System: pezframe_system` to an explicit one `System: pezframe_system::{Pezpallet, Call}` using the
//! `tt_default_parts` macro.
//! `System: pezframe_system` to an explicit one `System: pezframe_system::{Pezpallet, Call}` using
//! the `tt_default_parts` macro.
//!
//! The `tt_default_parts` macro exposes a comma separated list of pezpallet parts. For example, the
//! `Event` part is exposed only if the pezpallet implements an event via `#[pezpallet::event]` macro.
//! The tokens generated by this macro are ` expanded :: { Pezpallet, Call }` for our example.
//! `Event` part is exposed only if the pezpallet implements an event via `#[pezpallet::event]`
//! macro. The tokens generated by this macro are ` expanded :: { Pezpallet, Call }` for our
//! example.
//!
//! The `match_and_insert` macro takes in 3 arguments:
//! - target: This is the `TokenStream` that contains the `construct_runtime!` macro.
@@ -200,9 +201,10 @@
//! Users normally do not care about this transition.
//!
//! Similarly to the previous transition, the macro expansion transforms `System:
//! pezframe_system::{Pezpallet, Call}` into `System: pezframe_system expanded::{Error} ::{Pezpallet, Call}`.
//! The `expanded` section adds extra parts that the Bizinikiwi would like to expose for each pezpallet
//! by default. This is done to expose the appropriate types for metadata construction.
//! pezframe_system::{Pezpallet, Call}` into `System: pezframe_system expanded::{Error}
//! ::{Pezpallet, Call}`. The `expanded` section adds extra parts that the Bizinikiwi would like to
//! expose for each pezpallet by default. This is done to expose the appropriate types for metadata
//! construction.
//!
//! This time, instead of calling `tt_default_parts` we are using the `tt_extra_parts` macro.
//! This macro returns the ` :: expanded { Error }` list of additional parts we would like to
@@ -213,11 +215,13 @@ pub(crate) mod parse;
use crate::pezpallet::parse::helper::two128_str;
use cfg_expr::Predicate;
use itertools::Itertools;
use parse::{
ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pezpallet, RuntimeDeclaration,
};
use pezframe_support_procedural_tools::{
generate_access_from_frame_or_crate, generate_crate_access, generate_hidden_includes,
};
use itertools::Itertools;
use parse::{ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pezpallet, RuntimeDeclaration};
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
@@ -289,10 +293,15 @@ fn construct_runtime_implicit_to_explicit(
let mut expansion = quote::quote!(
#pezframe_support::construct_runtime! { #input }
);
for pezpallet in definition.pallets.iter().filter(|pezpallet| pezpallet.pezpallet_parts.is_none()) {
for pezpallet in definition
.pallets
.iter()
.filter(|pezpallet| pezpallet.pezpallet_parts.is_none())
{
let pezpallet_path = &pezpallet.path;
let pezpallet_name = &pezpallet.name;
let pezpallet_instance = pezpallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>));
let pezpallet_instance =
pezpallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>));
expansion = quote::quote!(
#pezframe_support::__private::tt_call! {
macro = [{ #pezpallet_path::tt_default_parts }]
@@ -328,7 +337,8 @@ fn construct_runtime_explicit_to_explicit_expanded(
for pezpallet in definition.pallets.iter().filter(|pezpallet| !pezpallet.is_expanded) {
let pezpallet_path = &pezpallet.path;
let pezpallet_name = &pezpallet.name;
let pezpallet_instance = pezpallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>));
let pezpallet_instance =
pezpallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>));
expansion = quote::quote!(
#pezframe_support::__private::tt_call! {
macro = [{ #pezpallet_path::tt_extra_parts }]
@@ -539,7 +549,8 @@ pub(crate) fn decl_all_pallets<'a>(
let pezpallet = &pezpallet_declaration.path;
let docs = &pezpallet_declaration.docs;
let mut generics = vec![quote!(#runtime)];
generics.extend(pezpallet_declaration.instance.iter().map(|name| quote!(#pezpallet::#name)));
generics
.extend(pezpallet_declaration.instance.iter().map(|name| quote!(#pezpallet::#name)));
let mut attrs = Vec::new();
for cfg in &pezpallet_declaration.cfg_pattern {
let feat = format!("#[cfg({})]\n", cfg.original());
@@ -197,7 +197,8 @@ pub struct PalletDeclaration {
pub index: Option<u8>,
/// The path of the pezpallet, e.g. `pezframe_system` in `System: pezframe_system`.
pub path: PalletPath,
/// The instance of the pezpallet, e.g. `Instance1` in `Council: pezpallet_collective::<Instance1>`.
/// The instance of the pezpallet, e.g. `Instance1` in `Council:
/// pezpallet_collective::<Instance1>`.
pub instance: Option<Ident>,
/// The declared pezpallet parts,
/// e.g. `Some([Pezpallet, Call])` for `System: system::{Pezpallet, Call}`
@@ -301,7 +302,16 @@ impl Parse for PalletDeclaration {
None
};
Ok(Self { is_expanded, attrs, name, path, instance, pezpallet_parts, specified_parts, index })
Ok(Self {
is_expanded,
attrs,
name,
path,
instance,
pezpallet_parts,
specified_parts,
index,
})
}
}
@@ -585,7 +595,8 @@ pub struct Pezpallet {
pub index: u8,
/// The path of the pezpallet, e.g. `pezframe_system` in `System: pezframe_system`.
pub path: PalletPath,
/// The instance of the pezpallet, e.g. `Instance1` in `Council: pezpallet_collective::<Instance1>`.
/// The instance of the pezpallet, e.g. `Instance1` in `Council:
/// pezpallet_collective::<Instance1>`.
pub instance: Option<Ident>,
/// The pezpallet parts to use for the pezpallet.
pub pezpallet_parts: Vec<PalletPart>,
@@ -18,8 +18,8 @@
//! Code for the `#[dynamic_params]`, `#[dynamic_pallet_params]` and
//! `#[dynamic_aggregated_params_internal]` macros.
use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
use inflector::Inflector;
use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote, ToTokens};
use syn::{parse2, spanned::Spanned, visit_mut, visit_mut::VisitMut, Result, Token};
@@ -37,8 +37,8 @@ mod storage_alias;
mod transactional;
mod tt_macro;
use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
use macro_magic::{import_tokens_attr, import_tokens_attr_verbatim};
use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
use proc_macro::TokenStream;
use quote::{quote, ToTokens};
use std::{cell::RefCell, str::FromStr};
@@ -129,19 +129,20 @@ fn counter_prefix(prefix: &str) -> String {
/// * `path::to::pezpallet`: identifiers separated by colons which declare the path to a pezpallet
/// definition.
///
/// * `::<InstanceN>` optional: specify the instance of the pezpallet to use. If not specified it will
/// use the default instance (or the only instance in case of non-instantiable pallets).
/// * `::<InstanceN>` optional: specify the instance of the pezpallet to use. If not specified it
/// will use the default instance (or the only instance in case of non-instantiable pallets).
///
/// * `::{ Part1, Part2<T>, .. }` optional if pezpallet declared with `pezframe_support::pezpallet`: Comma
/// separated parts declared with their generic. If a pezpallet is declared with
/// `pezframe_support::pezpallet` macro then the parts can be automatically derived if not explicitly
/// provided. We provide support for the following module parts in a pezpallet:
/// * `::{ Part1, Part2<T>, .. }` optional if pezpallet declared with `pezframe_support::pezpallet`:
/// Comma separated parts declared with their generic. If a pezpallet is declared with
/// `pezframe_support::pezpallet` macro then the parts can be automatically derived if not
/// explicitly provided. We provide support for the following module parts in a pezpallet:
///
/// - `Pezpallet` - Required for all pallets
/// - `Call` - If the pezpallet has callable functions
/// - `Storage` - If the pezpallet uses storage
/// - `Event` or `Event<T>` (if the event is generic) - If the pezpallet emits events
/// - `Origin` or `Origin<T>` (if the origin is generic) - If the pezpallet has instantiable origins
/// - `Origin` or `Origin<T>` (if the origin is generic) - If the pezpallet has instantiable
/// origins
/// - `Config` or `Config<T>` (if the config is generic) - If the pezpallet builds the genesis
/// storage with `GenesisConfig`
/// - `Inherent` - If the pezpallet provides/can check inherents.
@@ -151,23 +152,23 @@ fn counter_prefix(prefix: &str) -> String {
/// the pezpallet usable in the runtime.
///
/// * `exclude_parts { Part1, Part2 }` optional: comma separated parts without generics. I.e. one of
/// `Pezpallet`, `Call`, `Storage`, `Event`, `Origin`, `Config`, `Inherent`, `ValidateUnsigned`. It
/// is incompatible with `use_parts`. This specifies the part to exclude. In order to select
/// `Pezpallet`, `Call`, `Storage`, `Event`, `Origin`, `Config`, `Inherent`, `ValidateUnsigned`.
/// It is incompatible with `use_parts`. This specifies the part to exclude. In order to select
/// subset of the pezpallet parts.
///
/// For example excluding the part `Call` can be useful if the runtime doesn't want to make the
/// pezpallet calls available.
///
/// * `use_parts { Part1, Part2 }` optional: comma separated parts without generics. I.e. one of
/// `Pezpallet`, `Call`, `Storage`, `Event`, `Origin`, `Config`, `Inherent`, `ValidateUnsigned`. It
/// is incompatible with `exclude_parts`. This specifies the part to use. In order to select a
/// `Pezpallet`, `Call`, `Storage`, `Event`, `Origin`, `Config`, `Inherent`, `ValidateUnsigned`.
/// It is incompatible with `exclude_parts`. This specifies the part to use. In order to select a
/// subset of the pezpallet parts.
///
/// For example not using the part `Call` can be useful if the runtime doesn't want to make the
/// pezpallet calls available.
///
/// * `= $n` optional: number to define at which index the pezpallet variants in `OriginCaller`, `Call`
/// and `Event` are encoded, and to define the ModuleToIndex value.
/// * `= $n` optional: number to define at which index the pezpallet variants in `OriginCaller`,
/// `Call` and `Event` are encoded, and to define the ModuleToIndex value.
///
/// if `= $n` is not given, then index is resolved in the same way as fieldless enum in Rust
/// (i.e. incrementally from previous index):
@@ -424,7 +425,8 @@ pub fn impl_key_prefix_for_tuples(input: TokenStream) -> TokenStream {
.into()
}
/// Internal macro use by pezframe_support to generate dummy part checker for old pezpallet declaration
/// Internal macro use by pezframe_support to generate dummy part checker for old pezpallet
/// declaration
#[proc_macro]
pub fn __generate_dummy_part_checker(input: TokenStream) -> TokenStream {
dummy_part_checker::generate_dummy_part_checker(input)
@@ -468,7 +470,8 @@ pub fn __create_tt_macro(input: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::storage_alias`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::storage_alias`.
#[proc_macro_attribute]
pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream {
storage_alias::storage_alias(attributes.into(), input.into())
@@ -537,8 +540,8 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// attached with [`#[inject_runtime_type]`]) should not be injected with the respective concrete
/// types. By default, all such types are injected.
///
/// You can also make use of `#[pezpallet::no_default]` on specific items in your default impl that you
/// want to ensure will not be copied over but that you nonetheless want to use locally in the
/// You can also make use of `#[pezpallet::no_default]` on specific items in your default impl that
/// you want to ensure will not be copied over but that you nonetheless want to use locally in the
/// context of the foreign impl and the pezpallet (or context) in which it is defined.
///
/// ## Use-Case Example: Auto-Derive Test Pezpallet Config Traits
@@ -552,10 +555,11 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// implements a compatible `Config` such as `pezframe_system::Config` for a test/mock runtime, and
/// should receive as its first argument the path to a `DefaultConfig` impl that has been registered
/// via [`#[register_default_impl]`](`macro@register_default_impl`), and as its second argument, the
/// path to the auto-generated `DefaultConfig` for the existing pezpallet `Config` we want to base our
/// test config off of.
/// path to the auto-generated `DefaultConfig` for the existing pezpallet `Config` we want to base
/// our test config off of.
///
/// The following is what the `basic` example pezpallet would look like with a default testing config:
/// The following is what the `basic` example pezpallet would look like with a default testing
/// config:
///
/// ```ignore
/// #[derive_impl(pezframe_system::config_preludes::TestDefaultConfig as pezframe_system::pezpallet::DefaultConfig)]
@@ -640,8 +644,8 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// [`#[pezpallet::no_default]`](`macro@no_default`), in which case it cannot be overridden, and any
/// attempts to do so will result in a compiler error.
///
/// See `frame/examples/default-config/tests.rs` for a runnable end-to-end example pezpallet that makes
/// use of `derive_impl` to derive its testing config.
/// See `frame/examples/default-config/tests.rs` for a runnable end-to-end example pezpallet that
/// makes use of `derive_impl` to derive its testing config.
///
/// See [here](`macro@config`) for more information and caveats about the auto-generated
/// `DefaultConfig` trait.
@@ -649,10 +653,10 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// ## Optional Conventions
///
/// Note that as an optional convention, we encourage creating a `config_preludes` module inside of
/// your pezpallet. This is the convention we follow for `pezframe_system`'s `TestDefaultConfig` which, as
/// shown above, is located at `pezframe_system::config_preludes::TestDefaultConfig`. This is just a
/// suggested convention -- there is nothing in the code that expects modules with these names to be
/// in place, so there is no imperative to follow this pattern unless desired.
/// your pezpallet. This is the convention we follow for `pezframe_system`'s `TestDefaultConfig`
/// which, as shown above, is located at `pezframe_system::config_preludes::TestDefaultConfig`. This
/// is just a suggested convention -- there is nothing in the code that expects modules with these
/// names to be in place, so there is no imperative to follow this pattern unless desired.
///
/// In `config_preludes`, you can place types named like:
///
@@ -717,7 +721,8 @@ pub fn no_default(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::no_default_bounds`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::no_default_bounds`.
#[proc_macro_attribute]
pub fn no_default_bounds(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -866,7 +871,8 @@ pub fn constant(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::constant_name`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::constant_name`.
#[proc_macro_attribute]
pub fn constant_name(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -885,7 +891,8 @@ pub fn disable_pezframe_system_supertrait_check(_: TokenStream, _: TokenStream)
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::storage_version`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::storage_version`.
#[proc_macro_attribute]
pub fn storage_version(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -950,7 +957,8 @@ pub fn feeless_if(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::extra_constants`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::extra_constants`.
#[proc_macro_attribute]
pub fn extra_constants(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -977,7 +985,8 @@ pub fn event(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::include_metadata`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::include_metadata`.
#[proc_macro_attribute]
pub fn include_metadata(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -986,7 +995,8 @@ pub fn include_metadata(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::generate_deposit`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::generate_deposit`.
#[proc_macro_attribute]
pub fn generate_deposit(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1013,7 +1023,8 @@ pub fn getter(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::storage_prefix`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::storage_prefix`.
#[proc_macro_attribute]
pub fn storage_prefix(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1031,7 +1042,8 @@ pub fn unbounded(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::whitelist_storage`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::whitelist_storage`.
#[proc_macro_attribute]
pub fn whitelist_storage(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1059,7 +1071,8 @@ pub fn type_value(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::genesis_config`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::genesis_config`.
#[proc_macro_attribute]
pub fn genesis_config(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1068,7 +1081,8 @@ pub fn genesis_config(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::genesis_build`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::genesis_build`.
#[proc_macro_attribute]
pub fn genesis_build(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1086,7 +1100,8 @@ pub fn inherent(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::validate_unsigned`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::validate_unsigned`.
#[proc_macro_attribute]
pub fn validate_unsigned(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1114,7 +1129,8 @@ pub fn origin(_: TokenStream, _: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pezpallet_macros::composite_enum`.
/// Documentation for this macro can be found at
/// `pezframe_support::pezpallet_macros::composite_enum`.
#[proc_macro_attribute]
pub fn composite_enum(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
@@ -1125,9 +1141,9 @@ pub fn composite_enum(_: TokenStream, _: TokenStream) -> TokenStream {
/// The off-chain worker can then create and submit all such work items at any given time.
///
/// These work items are defined as instances of the `Task` trait (found at
/// `pezframe_support::traits::Task`). [`pezpallet:tasks_experimental`](macro@tasks_experimental) when
/// attached to an `impl` block inside a pezpallet, will generate an enum `Task<T>` whose variants
/// are mapped to functions inside this `impl` block.
/// `pezframe_support::traits::Task`). [`pezpallet:tasks_experimental`](macro@tasks_experimental)
/// when attached to an `impl` block inside a pezpallet, will generate an enum `Task<T>` whose
/// variants are mapped to functions inside this `impl` block.
///
/// Each such function must have the following set of attributes:
///
@@ -1460,11 +1476,11 @@ pub fn dynamic_aggregated_params_internal(attrs: TokenStream, input: TokenStream
///
/// Authorize process comes with 2 attributes macro on top of the authorized call:
///
/// * `#[pezpallet::authorize($authorized_function)]` - defines the function that authorizes the call.
/// First argument is the transaction source `TransactionSource` then followed by the same as call
/// arguments but by reference `&`. Return type is `TransactionValidityWithRefund`.
/// * `#[pezpallet::weight_of_authorize($weight)]` - defines the value of the weight of the authorize
/// function. This attribute is similar to `#[pezpallet::weight]`:
/// * `#[pezpallet::authorize($authorized_function)]` - defines the function that authorizes the
/// call. First argument is the transaction source `TransactionSource` then followed by the same
/// as call arguments but by reference `&`. Return type is `TransactionValidityWithRefund`.
/// * `#[pezpallet::weight_of_authorize($weight)]` - defines the value of the weight of the
/// authorize function. This attribute is similar to `#[pezpallet::weight]`:
/// * it can be ignore in `dev_mode`
/// * it can be automatically infered from weight info. For the call `foo` the function
/// `authorize_foo` in the weight info will be used. (weight info needs to be provided in the
@@ -191,8 +191,9 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
.collect::<Vec<_>>()
});
let default_docs =
[syn::parse_quote!(r"Contains a variant per dispatchable extrinsic that this pezpallet has.")];
let default_docs = [syn::parse_quote!(
r"Contains a variant per dispatchable extrinsic that this pezpallet has."
)];
let docs = if docs.is_empty() { &default_docs[..] } else { &docs[..] };
let maybe_compile_error = if def.call.is_none() {
@@ -35,12 +35,13 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
let type_decl_gen = &def.type_decl_generics(def.pezpallet_struct.attr_span);
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let config_where_clause = &def.config.where_clause;
let deprecation_status =
match crate::deprecation::get_deprecation(&quote::quote! {#pezframe_support}, &def.item.attrs)
{
Ok(deprecation) => deprecation,
Err(e) => return e.into_compile_error(),
};
let deprecation_status = match crate::deprecation::get_deprecation(
&quote::quote! {#pezframe_support},
&def.item.attrs,
) {
Ok(deprecation) => deprecation,
Err(e) => return e.into_compile_error(),
};
let mut storages_where_clauses = vec![&def.config.where_clause];
storages_where_clauses.extend(def.storages.iter().map(|storage| &storage.where_clause));
@@ -105,8 +106,10 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
)
};
let storage_info_span =
def.pezpallet_struct.without_storage_info.unwrap_or(def.pezpallet_struct.attr_span);
let storage_info_span = def
.pezpallet_struct
.without_storage_info
.unwrap_or(def.pezpallet_struct.attr_span);
let storage_names = &def.storages.iter().map(|storage| &storage.ident).collect::<Vec<_>>();
let storage_cfg_attrs =
@@ -157,7 +157,8 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
}
syn::parse_quote!(#pezframe_support::traits::GetDefault)
};
let default_max_values: syn::Type = syn::parse_quote!(#pezframe_support::traits::GetDefault);
let default_max_values: syn::Type =
syn::parse_quote!(#pezframe_support::traits::GetDefault);
let set_result_query_type_parameter = |query_type: &mut syn::Type| -> syn::Result<()> {
if let Some(QueryKind::ResultQuery(error_path, _)) = storage_def.query_kind.as_ref() {
@@ -860,8 +861,8 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
.iter()
.filter_map(|storage| {
// A little hacky; don't generate for cfg gated storages to not get compile errors
// when building "frame-feature-testing" gated storages in the "pezframe-support-test"
// crate.
// when building "frame-feature-testing" gated storages in the
// "pezframe-support-test" crate.
if storage.try_decode && storage.cfg_attrs.is_empty() {
let ident = &storage.ident;
let gen = &def.type_use_generics(storage.attr_span);
@@ -298,7 +298,8 @@ impl CallDef {
return Err(syn::Error::new(method.sig.span(), msg));
},
Some(syn::FnArg::Receiver(_)) => {
let msg = "Invalid pezpallet::call, first argument must be a typed argument, \
let msg =
"Invalid pezpallet::call, first argument must be a typed argument, \
e.g. `origin: OriginFor<T>`";
return Err(syn::Error::new(method.sig.span(), msg));
},
@@ -329,7 +330,8 @@ impl CallDef {
},
FunctionAttr::Weight(w) => {
if weight.is_some() {
let msg = "Invalid pezpallet::call, too many weight attributes given";
let msg =
"Invalid pezpallet::call, too many weight attributes given";
return Err(syn::Error::new(method.sig.span(), msg));
}
weight = Some(w);
@@ -91,7 +91,8 @@ pub struct CompositeDef {
pub composite_keyword: keyword::CompositeKeyword,
/// Name of the associated type.
pub ident: syn::Ident,
/// Type parameters and where clause attached to a declaration of the pezpallet::composite_enum.
/// Type parameters and where clause attached to a declaration of the
/// pezpallet::composite_enum.
pub generics: syn::Generics,
/// The span of the pezpallet::composite_enum attribute.
pub attr_span: proc_macro2::Span,
@@ -16,7 +16,9 @@
// limitations under the License.
use super::helper;
use pezframe_support_procedural_tools::{get_cfg_attributes, get_doc_literals, is_using_frame_crate};
use pezframe_support_procedural_tools::{
get_cfg_attributes, get_doc_literals, is_using_frame_crate,
};
use proc_macro_warning::Warning;
use quote::ToTokens;
use syn::{parse_quote, spanned::Spanned, token, Token, TraitItemType};
@@ -43,8 +45,8 @@ mod keyword {
#[derive(Default)]
pub struct DefaultTrait {
/// A bool for each sub-trait item indicates whether the item has
/// `#[pezpallet::no_default_bounds]` attached to it. If true, the item will not have any bounds
/// in the generated default sub-trait.
/// `#[pezpallet::no_default_bounds]` attached to it. If true, the item will not have any
/// bounds in the generated default sub-trait.
pub items: Vec<(syn::TraitItem, bool)>,
pub has_system: bool,
}
@@ -305,15 +307,17 @@ fn has_expected_system_config(path: syn::Path, pezframe_system: &syn::Path) -> b
let mut expected_system_config =
match (is_using_frame_crate(&path), is_using_frame_crate(&pezframe_system)) {
(true, false) =>
// We can't use the path to `pezframe_system` from `frame` if `pezframe_system` is not being
// in scope through `frame`.
// We can't use the path to `pezframe_system` from `frame` if `pezframe_system` is not
// being in scope through `frame`.
return false,
(false, true) =>
// We know that the only valid pezframe_system path is one that is `pezframe_system`, as
// `frame` re-exports it as such.
syn::parse2::<syn::Path>(quote::quote!(pezframe_system)).expect("is a valid path; qed"),
syn::parse2::<syn::Path>(quote::quote!(pezframe_system))
.expect("is a valid path; qed"),
(_, _) =>
// They are either both `pezframe_system` or both `pezkuwi_sdk_frame::xyz::pezframe_system`.
// They are either both `pezframe_system` or both
// `pezkuwi_sdk_frame::xyz::pezframe_system`.
pezframe_system.clone(),
};
@@ -634,7 +638,8 @@ mod tests {
let path = syn::parse2::<syn::Path>(quote::quote!(pezframe_system::Config)).unwrap();
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system))
.unwrap();
assert!(has_expected_system_config(path.clone(), &pezframe_system));
let pezframe_system =
@@ -645,10 +650,12 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::deps::pezframe_system::Config
))
.unwrap();
assert!(has_expected_system_config(path, &pezframe_system));
let pezframe_system =
@@ -661,10 +668,12 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_other_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::xyz::pezframe_system::Config
))
.unwrap();
assert!(has_expected_system_config(path, &pezframe_system));
let pezframe_system =
@@ -677,29 +686,34 @@ mod tests {
#[test]
fn has_expected_system_config_does_not_works_with_mixed_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::deps::pezframe_system::Config
))
.unwrap();
assert!(!has_expected_system_config(path, &pezframe_system));
}
#[test]
fn has_expected_system_config_does_not_works_with_other_mixed_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::xyz::pezframe_system::Config
))
.unwrap();
assert!(!has_expected_system_config(path, &pezframe_system));
}
#[test]
fn has_expected_system_config_does_not_work_with_frame_full_path_if_not_frame_crate() {
let pezframe_system = syn::parse2::<syn::Path>(quote::quote!(pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system::Config))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::deps::pezframe_system::Config
))
.unwrap();
assert!(!has_expected_system_config(path, &pezframe_system));
}
@@ -67,7 +67,10 @@ impl ErrorDef {
let item = if let syn::Item::Enum(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::error, expected item enum"));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::error, expected item enum",
));
};
if !matches!(item.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pezpallet::error, `Error` must be public";
@@ -80,41 +83,42 @@ impl ErrorDef {
vec![helper::check_type_def_gen_no_bounds(&item.generics, item.ident.span())?];
if item.generics.where_clause.is_some() {
let msg = "Invalid pezpallet::error, where clause is not allowed on pezpallet error item";
let msg =
"Invalid pezpallet::error, where clause is not allowed on pezpallet error item";
return Err(syn::Error::new(item.generics.where_clause.as_ref().unwrap().span(), msg));
}
let error = syn::parse2::<keyword::Error>(item.ident.to_token_stream())?;
let variants = item
.variants
.iter()
.map(|variant| {
let field_ty = match &variant.fields {
Fields::Unit => None,
Fields::Named(_) => Some(VariantField { is_named: true }),
Fields::Unnamed(_) => Some(VariantField { is_named: false }),
};
let variants =
item.variants
.iter()
.map(|variant| {
let field_ty = match &variant.fields {
Fields::Unit => None,
Fields::Named(_) => Some(VariantField { is_named: true }),
Fields::Unnamed(_) => Some(VariantField { is_named: false }),
};
match &variant.discriminant {
None |
Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
Some((_, expr)) => {
let msg = "Invalid pezpallet::error, only integer discriminants are supported";
return Err(syn::Error::new(expr.span(), msg));
},
}
let cfg_attrs: Vec<syn::Attribute> = helper::get_item_cfg_attrs(&variant.attrs);
let maybe_allow_attrs = extract_or_return_allow_attrs(&variant.attrs).collect();
match &variant.discriminant {
None |
Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
Some((_, expr)) => {
let msg = "Invalid pezpallet::error, only integer discriminants are supported";
return Err(syn::Error::new(expr.span(), msg));
},
}
let cfg_attrs: Vec<syn::Attribute> = helper::get_item_cfg_attrs(&variant.attrs);
let maybe_allow_attrs = extract_or_return_allow_attrs(&variant.attrs).collect();
Ok(VariantDef {
ident: variant.ident.clone(),
field: field_ty,
cfg_attrs,
maybe_allow_attrs,
Ok(VariantDef {
ident: variant.ident.clone(),
field: field_ty,
cfg_attrs,
maybe_allow_attrs,
})
})
})
.collect::<Result<_, _>>()?;
.collect::<Result<_, _>>()?;
Ok(ErrorDef { attr_span, index, variants, instances, error })
}
@@ -104,7 +104,10 @@ impl EventDef {
let item = if let syn::Item::Enum(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::event, expected enum item"));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::event, expected enum item",
));
};
crate::deprecation::prevent_deprecation_attr_on_outer_enum(&item.attrs)?;
@@ -48,7 +48,8 @@ pub trait MutItemAttrs {
fn mut_item_attrs(&mut self) -> Option<&mut Vec<syn::Attribute>>;
}
/// Take the first pezpallet attribute (e.g. attribute like `#[pezpallet..]`) and decode it to `Attr`
/// Take the first pezpallet attribute (e.g. attribute like `#[pezpallet..]`) and decode it to
/// `Attr`
pub(crate) fn take_first_item_pallet_attr<Attr>(
item: &mut impl MutItemAttrs,
) -> syn::Result<Option<Attr>>
@@ -58,7 +59,10 @@ where
let Some(attrs) = item.mut_item_attrs() else { return Ok(None) };
let Some(index) = attrs.iter().position(|attr| {
attr.path().segments.first().map_or(false, |segment| segment.ident == "pezpallet")
attr.path()
.segments
.first()
.map_or(false, |segment| segment.ident == "pezpallet")
}) else {
return Ok(None);
};
@@ -67,7 +71,8 @@ where
Ok(Some(syn::parse2(pezpallet_attr.into_token_stream())?))
}
/// Take all the pezpallet attributes (e.g. attribute like `#[pezpallet..]`) and decode them to `Attr`
/// Take all the pezpallet attributes (e.g. attribute like `#[pezpallet..]`) and decode them to
/// `Attr`
pub(crate) fn take_item_pallet_attrs<Attr>(item: &mut impl MutItemAttrs) -> syn::Result<Vec<Attr>>
where
Attr: syn::parse::Parse,
@@ -34,7 +34,8 @@ impl InherentDef {
};
if item.trait_.is_none() {
let msg = "Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
let msg =
"Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -44,7 +45,8 @@ impl InherentDef {
return Err(syn::Error::new(last.span(), msg));
}
} else {
let msg = "Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
let msg =
"Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -609,8 +609,9 @@ enum PalletAttr {
/// Can be used to reduce the repetitive weight annotation in the trivial case. It accepts one
/// argument that is expected to be an implementation of the `WeightInfo` or something that
/// behaves syntactically equivalent. This allows to annotate a `WeightInfo` for all the calls.
/// Now each call does not need to specify its own `#[pezpallet::weight]` but can instead use the
/// one from the `#[pezpallet::call]` definition. So instead of having to write it on each call:
/// Now each call does not need to specify its own `#[pezpallet::weight]` but can instead use
/// the one from the `#[pezpallet::call]` definition. So instead of having to write it on each
/// call:
///
/// ```ignore
/// #[pezpallet::call]
@@ -631,9 +632,10 @@ enum PalletAttr {
///
/// ### Dev Mode
///
/// Normally the `dev_mode` sets all weights of calls without a `#[pezpallet::weight]` annotation
/// to zero. Now when there is a `weight` attribute on the `#[pezpallet::call]`, then that is used
/// instead of the zero weight. So to say: it works together with `dev_mode`.
/// Normally the `dev_mode` sets all weights of calls without a `#[pezpallet::weight]`
/// annotation to zero. Now when there is a `weight` attribute on the `#[pezpallet::call]`,
/// then that is used instead of the zero weight. So to say: it works together with
/// `dev_mode`.
RuntimeCall(Option<InheritedCallWeightAttr>, proc_macro2::Span),
Error(proc_macro2::Span),
Tasks(proc_macro2::Span),
@@ -803,7 +805,8 @@ impl syn::parse::Parse for PalletAttr {
}
}
/// The optional weight annotation on a `#[pezpallet::call]` like `#[pezpallet::call(weight($type))]`.
/// The optional weight annotation on a `#[pezpallet::call]` like
/// `#[pezpallet::call(weight($type))]`.
#[derive(Clone)]
pub struct InheritedCallWeightAttr {
pub typename: syn::Type,
@@ -130,7 +130,8 @@ impl PalletStructDef {
}
if item.generics.where_clause.is_some() {
let msg = "Invalid pezpallet::pezpallet, where clause not supported on Pezpallet declaration";
let msg =
"Invalid pezpallet::pezpallet, where clause not supported on Pezpallet declaration";
return Err(syn::Error::new(item.generics.where_clause.span(), msg));
}
@@ -704,7 +704,8 @@ fn process_generics(
.collect::<Vec<_>>();
process_named_generics(&storage_kind, args_span, &args, dev_mode)
} else {
let msg = "Invalid pezpallet::storage, invalid generic declaration for storage. Expect only \
let msg =
"Invalid pezpallet::storage, invalid generic declaration for storage. Expect only \
type generics or binding generics, e.g. `<Name1 = Gen1, Name2 = Gen2, ..>` or \
`<Gen1, Gen2, ..>`.";
Err(syn::Error::new(segment.span(), msg))
@@ -792,7 +793,10 @@ impl StorageDef {
let item = if let syn::Item::Type(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::storage, expect item type."));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::storage, expect item type.",
));
};
let attrs: Vec<PalletStorageAttr> = helper::take_item_pallet_attrs(&mut item.attrs)?;
@@ -920,7 +924,8 @@ impl StorageDef {
.unwrap_or(Some(QueryKind::OptionQuery));
if let (None, Some(getter)) = (query_kind.as_ref(), getter.as_ref()) {
let msg = "Invalid pezpallet::storage, cannot generate getter because QueryKind is not \
let msg =
"Invalid pezpallet::storage, cannot generate getter because QueryKind is not \
identifiable. QueryKind must be `OptionQuery`, `ResultQuery`, `ValueQuery`, or default \
one to be identifiable.";
return Err(syn::Error::new(getter.span(), msg));
@@ -506,7 +506,10 @@ fn extract_pallet_attr(item_enum: &mut ItemEnum) -> Result<Option<TokenStream2>>
.cloned()
.collect();
if let Some(span) = duplicate {
return Err(Error::new(span, "only one `#[pezpallet::_]` attribute is supported on this item"));
return Err(Error::new(
span,
"only one `#[pezpallet::_]` attribute is supported on this item",
));
}
Ok(attr)
}
@@ -60,7 +60,8 @@ impl TypeValueDef {
}
}
let msg = "Invalid pezpallet::type_value, unexpected attribute, only doc attribute are \
let msg =
"Invalid pezpallet::type_value, unexpected attribute, only doc attribute are \
allowed";
return Err(syn::Error::new(attr.span(), msg));
}
@@ -31,7 +31,8 @@ impl ValidateUnsignedDef {
};
if item.trait_.is_none() {
let msg = "Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
let msg =
"Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -42,7 +43,8 @@ impl ValidateUnsignedDef {
return Err(syn::Error::new(last.span(), msg));
}
} else {
let msg = "Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
let msg =
"Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -15,8 +15,8 @@
// See the License for the specific language governsing permissions and
// limitations under the License.
use pezframe_support_procedural_tools::get_doc_literals;
use inflector::Inflector;
use pezframe_support_procedural_tools::get_doc_literals;
use syn::spanned::Spanned;
/// Parsed representation of an impl block annotated with `pezpallet::view_functions`.
@@ -100,12 +100,14 @@ fn construct_runtime_implicit_to_explicit(
let pezpallet_path = &pezpallet.path;
let pezpallet_name = &pezpallet.name;
let runtime_param = &pezpallet.runtime_param;
let pezpallet_segment_and_instance = match (&pezpallet.pezpallet_segment, &pezpallet.instance) {
(Some(segment), Some(instance)) => quote::quote!(::#segment<#runtime_param, #instance>),
(Some(segment), None) => quote::quote!(::#segment<#runtime_param>),
(None, Some(instance)) => quote::quote!(<#instance>),
(None, None) => quote::quote!(),
};
let pezpallet_segment_and_instance =
match (&pezpallet.pezpallet_segment, &pezpallet.instance) {
(Some(segment), Some(instance)) =>
quote::quote!(::#segment<#runtime_param, #instance>),
(Some(segment), None) => quote::quote!(::#segment<#runtime_param>),
(None, Some(instance)) => quote::quote!(<#instance>),
(None, None) => quote::quote!(),
};
expansion = quote::quote!(
#pezframe_support::__private::tt_call! {
macro = [{ #pezpallet_path::tt_default_parts_v2 }]
@@ -35,9 +35,9 @@
//! is defined inside `#[runtime::derive]`:
//! - `enum RuntimeCall`: This type contains the information needed to decode extrinsics.
//! - `enum RuntimeEvent`: This type contains the information needed to decode events.
//! - `enum RuntimeError`: While this cannot be used directly to decode `pezsp_runtime::DispatchError`
//! from the chain, it contains the information needed to decode the
//! `pezsp_runtime::DispatchError::Module`.
//! - `enum RuntimeError`: While this cannot be used directly to decode
//! `pezsp_runtime::DispatchError` from the chain, it contains the information needed to decode
//! the `pezsp_runtime::DispatchError::Module`.
//!
//! # State Transitions
//!
@@ -53,12 +53,12 @@
//! ```
//!
//! The `runtime` macro transforms the implicit declaration of each pezpallet
//! `System: pezframe_system` to an explicit one `System: pezframe_system + Pezpallet + Call` using the
//! `tt_default_parts_v2` macro.
//! `System: pezframe_system` to an explicit one `System: pezframe_system + Pezpallet + Call` using
//! the `tt_default_parts_v2` macro.
//!
//! The `tt_default_parts_v2` macro exposes a plus separated list of pezpallet parts. For example, the
//! `Event` part is exposed only if the pezpallet implements an event via `#[pezpallet::event]` macro.
//! The tokens generated by this macro are `+ Pezpallet + Call` for our example.
//! The `tt_default_parts_v2` macro exposes a plus separated list of pezpallet parts. For example,
//! the `Event` part is exposed only if the pezpallet implements an event via `#[pezpallet::event]`
//! macro. The tokens generated by this macro are `+ Pezpallet + Call` for our example.
//!
//! The `match_and_insert` macro takes in 3 arguments:
//! - target: This is the `TokenStream` that contains the `runtime` macro.
@@ -66,8 +66,8 @@
//! - tokens: The tokens to added after the pattern match.
//!
//! The `runtime` macro uses the `tt_call` to get the default pezpallet parts via
//! the `tt_default_parts_v2` macro defined by each pezpallet. The pezpallet parts are then returned as
//! input to the `match_and_replace` macro.
//! the `tt_default_parts_v2` macro defined by each pezpallet. The pezpallet parts are then returned
//! as input to the `match_and_replace` macro.
//! The `match_and_replace` then will modify the `runtime` to expand the implicit
//! definition to the explicit one.
//!
@@ -211,7 +211,8 @@ impl Def {
&bounds,
)?;
if let Some(used_pallet) = indices.insert(pezpallet.index, pezpallet.name.clone())
if let Some(used_pallet) =
indices.insert(pezpallet.index, pezpallet.name.clone())
{
let msg = format!(
"Pezpallet indices are conflicting: Both pallets {} and {} are at index {}",
@@ -16,7 +16,7 @@
// limitations under the License.
use crate::{
construct_runtime::parse::{Pezpallet, PalletPart, PalletPartKeyword, PalletPath},
construct_runtime::parse::{PalletPart, PalletPartKeyword, PalletPath, Pezpallet},
runtime::parse::PalletDeclaration,
};
use pezframe_support_procedural_tools::get_doc_literals;
@@ -24,7 +24,8 @@ pub struct PalletDeclaration {
pub name: Ident,
/// The path of the pezpallet, e.g. `pezframe_system` in `pub type System = pezframe_system`.
pub path: syn::Path,
/// The segment of the pezpallet, e.g. `Pezpallet` in `pub type System = pezframe_system::Pezpallet`.
/// The segment of the pezpallet, e.g. `Pezpallet` in `pub type System =
/// pezframe_system::Pezpallet`.
pub pezpallet_segment: Option<syn::PathSegment>,
/// The runtime parameter of the pezpallet, e.g. `Runtime` in
/// `pub type System = pezframe_system::Pezpallet<Runtime>`.
@@ -459,8 +459,8 @@ impl Parse for Input {
enum PrefixType {
/// An appropriate prefix will be determined automatically.
///
/// If generics are passed, this is assumed to be a pezpallet and the pezpallet name should be used.
/// Otherwise use the verbatim passed name as prefix.
/// If generics are passed, this is assumed to be a pezpallet and the pezpallet name should be
/// used. Otherwise use the verbatim passed name as prefix.
Compatibility,
/// The provided ident/name will be used as the prefix.
Verbatim,
+7 -6
View File
@@ -21,9 +21,6 @@
use crate::traits::UnfilteredDispatchable;
use codec::{Codec, Decode, DecodeWithMemTracking, Encode, EncodeLike, MaxEncodedLen};
use core::fmt;
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use pezsp_runtime::{
generic::{CheckedExtrinsic, UncheckedExtrinsic},
traits::{
@@ -32,6 +29,9 @@ use pezsp_runtime::{
DispatchError,
};
use pezsp_weights::Weight;
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
/// The return type of a `Dispatchable` in frame. When returned explicitly from
/// a dispatchable function it allows overriding the default `PostDispatchInfo`
@@ -60,8 +60,9 @@ pub type CallableCallFor<A, R> = <A as Callable<R>>::RuntimeCall;
/// Means to checks if the dispatchable is feeless.
///
/// This is automatically implemented for all dispatchables during pezpallet expansion.
/// If a call is marked by [`#[pezpallet::feeless_if]`](`macro@pezframe_support_procedural::feeless_if`)
/// attribute, the corresponding closure is checked.
/// If a call is marked by
/// [`#[pezpallet::feeless_if]`](`macro@pezframe_support_procedural::feeless_if`) attribute, the
/// corresponding closure is checked.
pub trait CheckIfFeeless {
/// The Origin type of the runtime.
type Origin;
@@ -1207,7 +1208,6 @@ mod per_dispatch_class_tests {
#[cfg(test)]
mod test_extensions {
use codec::{Decode, DecodeWithMemTracking, Encode};
use scale_info::TypeInfo;
use pezsp_runtime::{
impl_tx_ext_default,
traits::{
@@ -1217,6 +1217,7 @@ mod test_extensions {
transaction_validity::TransactionValidityError,
};
use pezsp_weights::Weight;
use scale_info::TypeInfo;
use super::{DispatchResult, PostDispatchInfo};
@@ -27,11 +27,11 @@
//! # FRAME integration
//!
//! The FRAME macros implement
//! [`UnfilteredDispatchable`](pezframe_support::traits::UnfilteredDispatchable) for each pezpallet `Call`
//! enum. Part of this implementation is the call to [`run_in_context`], so that each call to
//! [`UnfilteredDispatchable`](pezframe_support::traits::UnfilteredDispatchable) for each pezpallet
//! `Call` enum. Part of this implementation is the call to [`run_in_context`], so that each call to
//! [`UnfilteredDispatchable::dispatch_bypass_filter`](crate::traits::UnfilteredDispatchable::dispatch_bypass_filter)
//! or [`Dispatchable::dispatch`](pezsp_runtime::traits::Dispatchable::dispatch) will run in a dispatch
//! context.
//! or [`Dispatchable::dispatch`](pezsp_runtime::traits::Dispatchable::dispatch) will run in a
//! dispatch context.
//!
//! # Example
//!
+6 -6
View File
@@ -17,8 +17,8 @@
//! Some instance placeholder to be used in [`pezframe_support::pezpallet`] attribute macro.
//!
//! [`pezframe_support::pezpallet`] attribute macro does only requires the instance generic `I` to be
//! static (contrary to `decl_*` macro which requires instance generic to implement
//! [`pezframe_support::pezpallet`] attribute macro does only requires the instance generic `I` to
//! be static (contrary to `decl_*` macro which requires instance generic to implement
//! [`pezframe_support::traits::Instance`]).
//!
//! Thus support provides some instance types to be used, This allow some instantiable pezpallet to
@@ -28,12 +28,12 @@
//! pub trait Config<I: 'static = ()>: another_pallet::Config<I> {}
//! ```
//!
//! NOTE: [`pezframe_support::pezpallet`] will reexport them inside the module, in order to make them
//! accessible to [`pezframe_support::construct_runtime`].
//! NOTE: [`pezframe_support::pezpallet`] will reexport them inside the module, in order to make
//! them accessible to [`pezframe_support::construct_runtime`].
/// `Instance1` to be used for instantiable pallets defined with the
/// [`#[pezpallet]`](`pezframe_support::pezpallet`) macro. Instances 2-16 are also available but are hidden
/// from docs.
/// [`#[pezpallet]`](`pezframe_support::pezpallet`) macro. Instances 2-16 are also available but are
/// hidden from docs.
#[derive(Clone, Copy, PartialEq, Eq, crate::RuntimeDebugNoBound)]
pub struct Instance1;
+134 -122
View File
@@ -57,9 +57,6 @@ pub mod __private {
pub use impl_trait_for_tuples;
pub use log;
pub use paste;
pub use scale_info;
pub use serde;
pub use serde_json;
pub use pezsp_core::{Get, OpaqueMetadata, Void};
pub use pezsp_crypto_hashing_proc_macro;
pub use pezsp_inherents;
@@ -77,6 +74,9 @@ pub mod __private {
pub use pezsp_state_machine::BasicExternalities;
pub use pezsp_std;
pub use pezsp_tracing;
pub use scale_info;
pub use serde;
pub use serde_json;
pub use tt_call::*;
}
@@ -128,8 +128,8 @@ pub use pezsp_runtime::{
};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use pezsp_runtime::TypeId;
use scale_info::TypeInfo;
/// A unified log target for support operations.
pub const LOG_TARGET: &str = "runtime::pezframe-support";
@@ -146,17 +146,18 @@ impl TypeId for PalletId {
const TYPE_ID: [u8; 4] = *b"modl";
}
/// Generate a [`#[pezpallet::storage]`](pezpallet_macros::storage) alias outside of a pezpallet.
/// Generate a [`#[pezpallet::storage]`](pezpallet_macros::storage) alias outside of a
/// pezpallet.
///
/// This storage alias works similarly to the [`#[pezpallet::storage]`](pezpallet_macros::storage)
/// attribute macro. It supports [`StorageValue`](storage::types::StorageValue),
/// [`StorageMap`](storage::types::StorageMap),
/// This storage alias works similarly to the
/// [`#[pezpallet::storage]`](pezpallet_macros::storage) attribute macro. It supports
/// [`StorageValue`](storage::types::StorageValue), [`StorageMap`](storage::types::StorageMap),
/// [`StorageDoubleMap`](storage::types::StorageDoubleMap) and
/// [`StorageNMap`](storage::types::StorageNMap). The main difference to the normal
/// [`#[pezpallet::storage]`](pezpallet_macros::storage) is the flexibility around declaring the
/// storage prefix to use. The storage prefix determines where to find the value in the
/// storage. [`#[pezpallet::storage]`](pezpallet_macros::storage) uses the name of the pezpallet as
/// declared in [`construct_runtime!`].
/// [`#[pezpallet::storage]`](pezpallet_macros::storage) is the flexibility around declaring
/// the storage prefix to use. The storage prefix determines where to find the value in the
/// storage. [`#[pezpallet::storage]`](pezpallet_macros::storage) uses the name of the
/// pezpallet as declared in [`construct_runtime!`].
///
/// The flexibility around declaring the storage prefix makes this macro very useful for
/// writing migrations etc.
@@ -166,9 +167,10 @@ impl TypeId for PalletId {
/// There are different ways to declare the `prefix` to use. The `prefix` type can either be
/// declared explicitly by passing it to the macro as an attribute or by letting the macro
/// guess on what the `prefix` type is. The `prefix` is always passed as the first generic
/// argument to the type declaration. When using [`#[pezpallet::storage]`](pezpallet_macros::storage)
/// this first generic argument is always `_`. Besides declaring the `prefix`, the rest of the
/// type declaration works as with [`#[pezpallet::storage]`](pezpallet_macros::storage).
/// argument to the type declaration. When using
/// [`#[pezpallet::storage]`](pezpallet_macros::storage) this first generic argument is always
/// `_`. Besides declaring the `prefix`, the rest of the type declaration works as with
/// [`#[pezpallet::storage]`](pezpallet_macros::storage).
///
/// 1. Use the `verbatim` prefix type. This prefix type uses the given identifier as the
/// `prefix`:
@@ -178,8 +180,8 @@ impl TypeId for PalletId {
/// configured in [`construct_runtime!`] as the `prefix`:
#[doc = docify::embed!("src/tests/storage_alias.rs", pezpallet_name_attribute)]
/// It requires that the given prefix type implements
/// [`PalletInfoAccess`](traits::PalletInfoAccess) (which is always the case for FRAME pezpallet
/// structs). In the example above, `Pezpallet<T>` is the prefix type.
/// [`PalletInfoAccess`](traits::PalletInfoAccess) (which is always the case for FRAME
/// pezpallet structs). In the example above, `Pezpallet<T>` is the prefix type.
///
/// 3. Use the `dynamic` prefix type. This prefix type calls [`Get::get()`](traits::Get::get)
/// to get the `prefix`:
@@ -187,8 +189,8 @@ impl TypeId for PalletId {
/// It requires that the given prefix type implements [`Get<'static str>`](traits::Get).
///
/// 4. Let the macro "guess" what kind of prefix type to use. This only supports verbatim or
/// pezpallet name. The macro uses the presence of generic arguments to the prefix type as an
/// indication that it should use the pezpallet name as the `prefix`:
/// pezpallet name. The macro uses the presence of generic arguments to the prefix type as
/// an indication that it should use the pezpallet name as the `prefix`:
#[doc = docify::embed!("src/tests/storage_alias.rs", storage_alias_guess)]
pub use pezframe_support_procedural::storage_alias;
@@ -444,7 +446,6 @@ pub mod pezpallet_prelude {
pub use core::marker::PhantomData;
pub use pezframe_support::pezpallet_macros::*;
pub use pezframe_support_procedural::{inject_runtime_type, register_default_impl};
pub use scale_info::TypeInfo;
pub use pezsp_inherents::MakeFatalError;
pub use pezsp_runtime::{
traits::{
@@ -460,6 +461,7 @@ pub mod pezpallet_prelude {
DispatchError, RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE,
};
pub use pezsp_weights::Weight;
pub use scale_info::TypeInfo;
}
/// The pezpallet macro has 2 purposes:
@@ -488,7 +490,8 @@ pub mod pezpallet_prelude {
/// }
/// ```
///
/// The documentation for each individual part can be found at [pezframe_support::pezpallet_macros]
/// The documentation for each individual part can be found at
/// [pezframe_support::pezpallet_macros]
///
/// ## Dev Mode (`#[pezpallet(dev_mode)]`)
///
@@ -517,8 +520,9 @@ pub mod pezpallet_prelude {
/// * Call indices no longer need to be specified on every `#[pezpallet::call]` declaration. By
/// default, dev mode pallets will assume a call index based on the order of the call.
/// * All storages are marked as unbounded, meaning you do not need to implement
/// [`MaxEncodedLen`](pezframe_support::pezpallet_prelude::MaxEncodedLen) on storage types. This is
/// equivalent to specifying `#[pezpallet::unbounded]` on all storage type definitions.
/// [`MaxEncodedLen`](pezframe_support::pezpallet_prelude::MaxEncodedLen) on storage types.
/// This is equivalent to specifying `#[pezpallet::unbounded]` on all storage type
/// definitions.
/// * Storage hashers no longer need to be specified and can be replaced by `_`. In dev mode,
/// these will be replaced by `Blake2_128Concat`. In case of explicit key-binding, `Hasher`
/// can simply be ignored when in `dev_mode`.
@@ -572,20 +576,20 @@ pub mod pezpallet_prelude {
/// It also implements on the pezpallet:
///
/// * [`GetStorageVersion`](pezframe_support::traits::GetStorageVersion)
/// * [`OnGenesis`](pezframe_support::traits::OnGenesis): contains some logic to write the pezpallet
/// version into storage.
/// * [`PalletInfoAccess`](pezframe_support::traits::PalletInfoAccess) to ease access to pezpallet
/// information given by [`pezframe_support::traits::PalletInfo`]. (The implementation uses the
/// associated type [`pezframe_support::traits::PalletInfo`]).
/// * [`StorageInfoTrait`](pezframe_support::traits::StorageInfoTrait) to give information about
/// storages.
/// * [`OnGenesis`](pezframe_support::traits::OnGenesis): contains some logic to write the
/// pezpallet version into storage.
/// * [`PalletInfoAccess`](pezframe_support::traits::PalletInfoAccess) to ease access to
/// pezpallet information given by [`pezframe_support::traits::PalletInfo`]. (The
/// implementation uses the associated type [`pezframe_support::traits::PalletInfo`]).
/// * [`StorageInfoTrait`](pezframe_support::traits::StorageInfoTrait) to give information
/// about storages.
///
/// If the attribute `set_storage_max_encoded_len` is set then the macro calls
/// [`StorageInfoTrait`](pezframe_support::traits::StorageInfoTrait) for each storage in the
/// implementation of [`StorageInfoTrait`](pezframe_support::traits::StorageInfoTrait) for the
/// pezpallet. Otherwise, it implements
/// [`StorageInfoTrait`](pezframe_support::traits::StorageInfoTrait) for the pezpallet using the
/// [`PartialStorageInfoTrait`](pezframe_support::traits::PartialStorageInfoTrait)
/// [`StorageInfoTrait`](pezframe_support::traits::StorageInfoTrait) for the pezpallet using
/// the [`PartialStorageInfoTrait`](pezframe_support::traits::PartialStorageInfoTrait)
/// implementation of storages.
///
/// ## Note on deprecation.
@@ -717,9 +721,9 @@ pub mod pezpallet_macros {
/// Declares a storage as unbounded in potential size.
///
/// When implementing the storage info (when `#[pezpallet::generate_storage_info]` is
/// specified on the pezpallet struct placeholder), the size of the storage will be declared
/// as unbounded. This can be useful for storage which can never go into PoV (Proof of
/// Validity).
/// specified on the pezpallet struct placeholder), the size of the storage will be
/// declared as unbounded. This can be useful for storage which can never go into PoV
/// (Proof of Validity).
///
/// ## Example
///
@@ -780,8 +784,8 @@ pub mod pezpallet_macros {
/// Ensures the trait item will not be used as a default with the
/// `#[derive_impl(..)]` attribute macro.
///
/// The optional attribute `#[pezpallet::no_default]` can be attached to trait items within a
/// `Config` trait impl that has [`#[pezpallet::config(with_default)]`](`config`)
/// The optional attribute `#[pezpallet::no_default]` can be attached to trait items within
/// a `Config` trait impl that has [`#[pezpallet::config(with_default)]`](`config`)
/// attached.
pub use pezframe_support_procedural::no_default;
@@ -789,21 +793,21 @@ pub mod pezpallet_macros {
/// [`#[import_section]`](`import_section`).
///
/// Note that sections are imported by their module name/ident, and should be referred to
/// by their _full path_ from the perspective of the target pezpallet. Do not attempt to make
/// use of `use` statements to bring pezpallet sections into scope, as this will not work
/// (unless you do so as part of a wildcard import, in which case it will work).
/// by their _full path_ from the perspective of the target pezpallet. Do not attempt to
/// make use of `use` statements to bring pezpallet sections into scope, as this will not
/// work (unless you do so as part of a wildcard import, in which case it will work).
///
/// ## Naming Logistics
///
/// Also note that because of how `#[pezpallet_section]` works, pezpallet section names must be
/// globally unique _within the crate in which they are defined_. For more information on
/// why this must be the case, see macro_magic's
/// Also note that because of how `#[pezpallet_section]` works, pezpallet section names
/// must be globally unique _within the crate in which they are defined_. For more
/// information on why this must be the case, see macro_magic's
/// [`#[export_tokens]`](https://docs.rs/macro_magic/latest/macro_magic/attr.export_tokens.html) macro.
///
/// Optionally, you may provide an argument to `#[pezpallet_section]` such as
/// `#[pezpallet_section(some_ident)]`, in the event that there is another pezpallet section in
/// same crate with the same ident/name. The ident you specify can then be used instead of
/// the module's ident name when you go to import it via
/// `#[pezpallet_section(some_ident)]`, in the event that there is another pezpallet
/// section in same crate with the same ident/name. The ident you specify can then be used
/// instead of the module's ident name when you go to import it via
/// [`#[import_section]`](`import_section`).
pub use pezframe_support_procedural::pezpallet_section;
@@ -915,9 +919,9 @@ pub mod pezpallet_macros {
/// `use` statements within your pezpallet section, so they are imported as well, or by
/// otherwise ensuring that you have the same imports on the target pezpallet.
///
/// It is perfectly permissible to import multiple pezpallet sections into the same pezpallet,
/// which can be done by having multiple `#[import_section(something)]` attributes
/// attached to the pezpallet.
/// It is perfectly permissible to import multiple pezpallet sections into the same
/// pezpallet, which can be done by having multiple `#[import_section(something)]`
/// attributes attached to the pezpallet.
///
/// Note that sections are imported by their module name/ident, and should be referred to
/// by their _full path_ from the perspective of the target pezpallet.
@@ -944,7 +948,8 @@ pub mod pezpallet_macros {
/// }
/// ```
///
/// See [`pezpallet::storage`](`pezframe_support::pezpallet_macros::storage`) for more info.
/// See [`pezpallet::storage`](`pezframe_support::pezpallet_macros::storage`) for more
/// info.
pub use pezframe_support_procedural::getter;
/// Defines constants that are added to the constant field of
@@ -1036,9 +1041,9 @@ pub mod pezpallet_macros {
/// ```
///
/// I.e. a regular trait definition named `Config`, with the supertrait
/// [`pezframe_system::pezpallet::Config`](../../pezframe_system/pezpallet/trait.Config.html), and
/// optionally other supertraits and a where clause. (Specifying other supertraits here is
/// known as [tight coupling](https://docs.pezkuwichain.io/reference/how-to-guides/pezpallet-design/use-tight-coupling/))
/// [`pezframe_system::pezpallet::Config`](../../pezframe_system/pezpallet/trait.Config.
/// html), and optionally other supertraits and a where clause. (Specifying other
/// supertraits here is known as [tight coupling](https://docs.pezkuwichain.io/reference/how-to-guides/pezpallet-design/use-tight-coupling/))
///
/// ## Optional: `with_default`
///
@@ -1081,15 +1086,16 @@ pub mod pezpallet_macros {
/// As shown above:
/// * you may attach the [`#[pezpallet::no_default]`](`no_default`)
/// attribute to specify that a particular trait item _cannot_ be used as a default when a
/// test `Config` is derived using the [`#[derive_impl(..)]`](`pezframe_support::derive_impl`)
/// attribute macro. This will cause that particular trait item to simply not appear in
/// default testing configs based on this config (the trait item will not be included in
/// `DefaultConfig`).
/// test `Config` is derived using the
/// [`#[derive_impl(..)]`](`pezframe_support::derive_impl`) attribute macro. This will
/// cause that particular trait item to simply not appear in default testing configs based
/// on this config (the trait item will not be included in `DefaultConfig`).
/// * you may attach the [`#[pezpallet::no_default_bounds]`](`no_default_bounds`)
/// attribute to specify that a particular trait item can be used as a default when a
/// test `Config` is derived using the [`#[derive_impl(..)]`](`pezframe_support::derive_impl`)
/// attribute macro. But its bounds cannot be enforced at this point and should be
/// discarded when generating the default config trait.
/// test `Config` is derived using the
/// [`#[derive_impl(..)]`](`pezframe_support::derive_impl`) attribute macro. But its
/// bounds cannot be enforced at this point and should be discarded when generating the
/// default config trait.
/// * you may not specify any attribute to generate a trait item in the default config
/// trait.
///
@@ -1108,11 +1114,11 @@ pub mod pezpallet_macros {
///
/// Consequently:
/// - Any items that rely on externalities _must_ be marked with
/// [`#[pezpallet::no_default]`](`no_default`) or your trait will fail to compile when used
/// with [`derive_impl`](`pezframe_support::derive_impl`).
/// - Items marked with [`#[pezpallet::no_default]`](`no_default`) are entirely excluded from
/// the `DefaultConfig` trait, and therefore any impl of `DefaultConfig` doesn't need to
/// implement such items.
/// [`#[pezpallet::no_default]`](`no_default`) or your trait will fail to compile when
/// used with [`derive_impl`](`pezframe_support::derive_impl`).
/// - Items marked with [`#[pezpallet::no_default]`](`no_default`) are entirely excluded
/// from the `DefaultConfig` trait, and therefore any impl of `DefaultConfig` doesn't
/// need to implement such items.
///
/// For more information, see:
/// * [`pezframe_support::derive_impl`].
@@ -1246,8 +1252,8 @@ pub mod pezpallet_macros {
/// [`ValidateUnsigned`](pezframe_support::pezpallet_prelude::ValidateUnsigned) for
/// type `Pezpallet<T>`, and some optional where clause.
///
/// NOTE: There is also the [`pezsp_runtime::traits::TransactionExtension`] trait that can be
/// used to add some specific logic for transaction validation.
/// NOTE: There is also the [`pezsp_runtime::traits::TransactionExtension`] trait that can
/// be used to add some specific logic for transaction validation.
///
/// ## Macro expansion
///
@@ -1258,9 +1264,9 @@ pub mod pezpallet_macros {
/// Allows defining view functions on a pezpallet.
///
/// A pezpallet view function is a read-only function providing access to the state of the
/// pezpallet from both outside and inside the runtime. It should provide a _stable_ interface
/// for querying the state of the pezpallet, avoiding direct storage access and upgrading
/// along with the runtime.
/// pezpallet from both outside and inside the runtime. It should provide a _stable_
/// interface for querying the state of the pezpallet, avoiding direct storage access and
/// upgrading along with the runtime.
///
/// ## Syntax
/// View functions methods must be read-only and always return some output. A
@@ -1295,23 +1301,23 @@ pub mod pezpallet_macros {
///
/// ## Usage and implementation details
/// To allow outside access to pezpallet view functions, you need to add a runtime API that
/// accepts view function queries and dispatches them to the right pezpallet. You can do that
/// by implementing the
/// accepts view function queries and dispatches them to the right pezpallet. You can do
/// that by implementing the
/// [`RuntimeViewFunction`](pezframe_support::view_functions::runtime_api::RuntimeViewFunction)
/// trait for the runtime inside an [`impl_runtime_apis!`](pezsp_api::impl_runtime_apis)
/// block.
///
/// The `RuntimeViewFunction` trait implements a hashing-based dispatching mechanism to
/// dispatch view functions to the right method in the right pezpallet based on their IDs. A
/// view function ID depends both on its pezpallet and on its method signature, so it remains
/// stable as long as those two elements are not modified. In general, pezpallet view
/// functions should expose a _stable_ interface and changes to the method signature are
/// strongly discouraged. For more details on the dispatching mechanism, see the
/// dispatch view functions to the right method in the right pezpallet based on their IDs.
/// A view function ID depends both on its pezpallet and on its method signature, so it
/// remains stable as long as those two elements are not modified. In general, pezpallet
/// view functions should expose a _stable_ interface and changes to the method signature
/// are strongly discouraged. For more details on the dispatching mechanism, see the
/// [`DispatchViewFunction`](pezframe_support::view_functions::DispatchViewFunction) trait.
pub use pezframe_support_procedural::view_functions;
/// Allows defining a struct implementing the [`Get`](pezframe_support::traits::Get) trait to
/// ease the use of storage types.
/// Allows defining a struct implementing the [`Get`](pezframe_support::traits::Get) trait
/// to ease the use of storage types.
///
/// This attribute is meant to be used alongside [`#[pezpallet::storage]`](`storage`) to
/// define a storage's default value. This attribute can be used multiple times.
@@ -1498,8 +1504,8 @@ pub mod pezpallet_macros {
///
/// ### Macro expansion
///
/// The macro implements the [`pezpallet_skip_feeless_payment::CheckIfFeeless`] trait on the
/// dispatchable and calls the corresponding closure in the implementation.
/// The macro implements the [`pezpallet_skip_feeless_payment::CheckIfFeeless`] trait on
/// the dispatchable and calls the corresponding closure in the implementation.
///
/// [`pezpallet_skip_feeless_payment::SkipCheckIfFeeless`]: ../../pezpallet_skip_feeless_payment/struct.SkipCheckIfFeeless.html
/// [`pezpallet_skip_feeless_payment::CheckIfFeeless`]: ../../pezpallet_skip_feeless_payment/struct.SkipCheckIfFeeless.html
@@ -1562,8 +1568,8 @@ pub mod pezpallet_macros {
///
/// ## Note on deprecation of Errors
///
/// - Usage of `deprecated` attribute will propagate deprecation information to the pezpallet
/// metadata where the item was declared.
/// - Usage of `deprecated` attribute will propagate deprecation information to the
/// pezpallet metadata where the item was declared.
/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
/// - It's possible to deprecated either certain variants inside the `Error` or the whole
/// `Error` itself. If both the `Error` and its variants are deprecated a compile error
@@ -1618,8 +1624,8 @@ pub mod pezpallet_macros {
///
/// ## Note on deprecation of Events
///
/// - Usage of `deprecated` attribute will propagate deprecation information to the pezpallet
/// metadata where the item was declared.
/// - Usage of `deprecated` attribute will propagate deprecation information to the
/// pezpallet metadata where the item was declared.
/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
/// - It's possible to deprecated either certain variants inside the `Event` or the whole
/// `Event` itself. If both the `Event` and its variants are deprecated a compile error
@@ -1749,11 +1755,12 @@ pub mod pezpallet_macros {
/// ## Weight info
///
/// Each call needs to define a weight.
/// * The weight can be defined explicitly using the attribute `#[pezpallet::weight($expr)]`
/// (Note that argument of the call are available inside the expression).
/// * The weight can be defined explicitly using the attribute
/// `#[pezpallet::weight($expr)]` (Note that argument of the call are available inside
/// the expression).
/// * Or it can be defined implicitly, the weight info for the calls needs to be specified
/// in the call attribute: `#[pezpallet::call(weight = $WeightInfo)]`, then each call that
/// doesn't have explicit weight will use `$WeightInfo::$call_name` as the weight.
/// in the call attribute: `#[pezpallet::call(weight = $WeightInfo)]`, then each call
/// that doesn't have explicit weight will use `$WeightInfo::$call_name` as the weight.
///
/// * Or it can be simply ignored when the pezpallet is in `dev_mode`.
///
@@ -1827,8 +1834,8 @@ pub mod pezpallet_macros {
///
/// ## Note on deprecation of Calls
///
/// - Usage of `deprecated` attribute will propagate deprecation information to the pezpallet
/// metadata where the item was declared.
/// - Usage of `deprecated` attribute will propagate deprecation information to the
/// pezpallet metadata where the item was declared.
/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
/// generated code.
@@ -1885,8 +1892,8 @@ pub mod pezpallet_macros {
pub use pezframe_support_procedural::genesis_config;
/// Allows you to define how the state of your pezpallet at genesis is built. This
/// takes as input the `GenesisConfig` type (as `self`) and constructs the pezpallet's initial
/// state.
/// takes as input the `GenesisConfig` type (as `self`) and constructs the pezpallet's
/// initial state.
///
/// The fields of the `GenesisConfig` can in turn be populated by the chain-spec.
///
@@ -1947,8 +1954,8 @@ pub mod pezpallet_macros {
pub use pezframe_support_procedural::genesis_build;
/// Allows adding an associated type trait bounded by
/// [`Get`](pezframe_support::pezpallet_prelude::Get) from [`pezpallet::config`](`macro@config`)
/// into metadata.
/// [`Get`](pezframe_support::pezpallet_prelude::Get) from
/// [`pezpallet::config`](`macro@config`) into metadata.
///
/// ## Example
///
@@ -1969,8 +1976,8 @@ pub mod pezpallet_macros {
///
/// ## Note on deprecation of constants
///
/// - Usage of `deprecated` attribute will propagate deprecation information to the pezpallet
/// metadata where the item was declared.
/// - Usage of `deprecated` attribute will propagate deprecation information to the
/// pezpallet metadata where the item was declared.
/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
/// generated code.
@@ -1983,7 +1990,8 @@ pub mod pezpallet_macros {
/// Storage items are pointers to data stored on-chain (the *blockchain state*), under a
/// specific key. The exact key is dependent on the type of the storage.
///
/// > From the perspective of this pezpallet, the entire blockchain state is abstracted behind
/// > From the perspective of this pezpallet, the entire blockchain state is abstracted
/// > behind
/// > a key-value api, namely [`pezsp_io::storage`].
///
/// ## Storage Types
@@ -2016,8 +2024,8 @@ pub mod pezpallet_macros {
/// Each `Key` type requires its own designated `Hasher` declaration, so that
/// [`StorageDoubleMap`](pezframe_support::storage::types::StorageDoubleMap) needs two of
/// each, and [`StorageNMap`](pezframe_support::storage::types::StorageNMap) needs `N` such
/// pairs. Since [`StorageValue`](pezframe_support::storage::types::StorageValue) only stores
/// a single element, no configuration of hashers is needed.
/// pairs. Since [`StorageValue`](pezframe_support::storage::types::StorageValue) only
/// stores a single element, no configuration of hashers is needed.
///
/// ### Syntax
///
@@ -2077,24 +2085,25 @@ pub mod pezpallet_macros {
///
/// There are three types of queries:
///
/// 1. [`OptionQuery`](pezframe_support::storage::types::OptionQuery): The default query type.
/// It returns `Some(V)` if the value is present, or `None` if it isn't, where `V` is
/// the value type.
/// 2. [`ValueQuery`](pezframe_support::storage::types::ValueQuery): Returns the value itself
/// if present; otherwise, it returns `Default::default()`. This behavior can be
/// 1. [`OptionQuery`](pezframe_support::storage::types::OptionQuery): The default query
/// type. It returns `Some(V)` if the value is present, or `None` if it isn't, where `V`
/// is the value type.
/// 2. [`ValueQuery`](pezframe_support::storage::types::ValueQuery): Returns the value
/// itself if present; otherwise, it returns `Default::default()`. This behavior can be
/// adjusted with the `OnEmpty` generic parameter, which defaults to `OnEmpty =
/// GetDefault`.
/// 3. [`ResultQuery`](pezframe_support::storage::types::ResultQuery): Returns `Result<V, E>`,
/// where `V` is the value type.
/// 3. [`ResultQuery`](pezframe_support::storage::types::ResultQuery): Returns `Result<V,
/// E>`, where `V` is the value type.
///
/// See [`QueryKind`](pezframe_support::storage::types::QueryKindTrait) for further examples.
/// See [`QueryKind`](pezframe_support::storage::types::QueryKindTrait) for further
/// examples.
///
/// ### Optimized Appending
///
/// All storage items — such as
/// [`StorageValue`](pezframe_support::storage::types::StorageValue),
/// [`StorageMap`](pezframe_support::storage::types::StorageMap), and their variants—offer an
/// `::append()` method optimized for collections. Using this method avoids the
/// [`StorageMap`](pezframe_support::storage::types::StorageMap), and their variants—offer
/// an `::append()` method optimized for collections. Using this method avoids the
/// inefficiency of decoding and re-encoding entire collections when adding items. For
/// instance, consider the storage declaration `type MyVal<T> = StorageValue<_, Vec<u8>,
/// ValueQuery>`. With `MyVal` storing a large list of bytes, `::append()` lets you
@@ -2121,9 +2130,9 @@ pub mod pezpallet_macros {
/// ### Hashers
///
/// For all storage types, except
/// [`StorageValue`](pezframe_support::storage::types::StorageValue), a set of hashers needs
/// to be specified. The choice of hashers is crucial, especially in production chains. The
/// purpose of storage hashers in maps is to ensure the keys of a map are
/// [`StorageValue`](pezframe_support::storage::types::StorageValue), a set of hashers
/// needs to be specified. The choice of hashers is crucial, especially in production
/// chains. The purpose of storage hashers in maps is to ensure the keys of a map are
/// uniformly distributed. An unbalanced map/trie can lead to inefficient performance.
///
/// In general, hashers are categorized as either cryptographically secure or not. The
@@ -2149,10 +2158,11 @@ pub mod pezpallet_macros {
///
/// Internally, every storage type generates a "prefix". This prefix serves as the initial
/// segment of the key utilized to store values in the on-chain state (i.e., the final key
/// used in [`pezsp_io::storage`](pezsp_io::storage)). For all storage types, the following rule
/// applies:
/// used in [`pezsp_io::storage`](pezsp_io::storage)). For all storage types, the following
/// rule applies:
///
/// > The storage prefix begins with `twox128(pezpallet_prefix) ++ twox128(STORAGE_PREFIX)`,
/// > The storage prefix begins with `twox128(pezpallet_prefix) ++
/// > twox128(STORAGE_PREFIX)`,
/// > where
/// > `pezpallet_prefix` is the name assigned to the pezpallet instance in
/// > [`pezframe_support::construct_runtime`](pezframe_support::construct_runtime), and
@@ -2160,9 +2170,9 @@ pub mod pezpallet_macros {
/// > as
/// > `Foo` in `type Foo<T> = StorageValue<..>`.
///
/// For [`StorageValue`](pezframe_support::storage::types::StorageValue), no additional key is
/// required. For map types, the prefix is extended with one or more keys defined by the
/// map.
/// For [`StorageValue`](pezframe_support::storage::types::StorageValue), no additional key
/// is required. For map types, the prefix is extended with one or more keys defined by
/// the map.
///
/// #### Example
#[doc = docify::embed!("src/lib.rs", example_storage_value_map_prefixes)]
@@ -2197,8 +2207,8 @@ pub mod pezpallet_macros {
///
/// ## Note on deprecation of storage items
///
/// - Usage of `deprecated` attribute will propagate deprecation information to the pezpallet
/// metadata where the storage item was declared.
/// - Usage of `deprecated` attribute will propagate deprecation information to the
/// pezpallet metadata where the storage item was declared.
/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
/// generated code.
@@ -2270,7 +2280,9 @@ pub mod pezpallet_macros {
pub use pezframe_support_procedural::origin;
}
#[deprecated(note = "Will be removed after July 2023; Use `pezsp_runtime::traits` directly instead.")]
#[deprecated(
note = "Will be removed after July 2023; Use `pezsp_runtime::traits` directly instead."
)]
pub mod error {
#[doc(hidden)]
pub use pezsp_runtime::traits::{BadOrigin, LookupError};
+20 -12
View File
@@ -264,14 +264,14 @@ pub fn migrate_from_pallet_version_to_storage_version<
/// pezpallet.
///
/// This struct is generic over two parameters:
/// - `P` is a type that implements the `Get` trait for a static string, representing the pezpallet's
/// name.
/// - `P` is a type that implements the `Get` trait for a static string, representing the
/// pezpallet's name.
/// - `DbWeight` is a type that implements the `Get` trait for `RuntimeDbWeight`, providing the
/// weight for database operations.
///
/// On runtime upgrade, the `on_runtime_upgrade` function will clear all storage items associated
/// with the specified pezpallet, logging the number of keys removed. If the `try-runtime` feature is
/// enabled, the `pre_upgrade` and `post_upgrade` functions can be used to verify the storage
/// with the specified pezpallet, logging the number of keys removed. If the `try-runtime` feature
/// is enabled, the `pre_upgrade` and `post_upgrade` functions can be used to verify the storage
/// removal before and after the upgrade.
///
/// # Examples:
@@ -314,8 +314,8 @@ pub fn migrate_from_pallet_version_to_storage_version<
pub struct RemovePallet<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>>(
PhantomData<(P, DbWeight)>,
);
impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> pezframe_support::traits::OnRuntimeUpgrade
for RemovePallet<P, DbWeight>
impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>>
pezframe_support::traits::OnRuntimeUpgrade for RemovePallet<P, DbWeight>
{
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
let hashed_prefix = twox_128(P::get().as_bytes());
@@ -369,8 +369,8 @@ impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> pezframe_support::tra
/// `RemoveStorage` is a utility struct used to remove a storage item from a specific pezpallet.
///
/// This struct is generic over three parameters:
/// - `P` is a type that implements the [`Get`] trait for a static string, representing the pezpallet's
/// name.
/// - `P` is a type that implements the [`Get`] trait for a static string, representing the
/// pezpallet's name.
/// - `S` is a type that implements the [`Get`] trait for a static string, representing the storage
/// name.
/// - `DbWeight` is a type that implements the [`Get`] trait for [`RuntimeDbWeight`], providing the
@@ -721,8 +721,10 @@ pub trait SteppedMigrations {
///
/// Returns `None` if the index is out of bounds.
#[cfg(feature = "try-runtime")]
fn nth_post_upgrade(n: u32, _state: Vec<u8>)
-> Option<Result<(), pezsp_runtime::TryRuntimeError>>;
fn nth_post_upgrade(
n: u32,
_state: Vec<u8>,
) -> Option<Result<(), pezsp_runtime::TryRuntimeError>>;
/// The maximal encoded length across all cursors.
fn cursor_max_encoded_len() -> usize;
@@ -882,7 +884,10 @@ impl<T: SteppedMigration> SteppedMigrations for T {
}
#[cfg(feature = "try-runtime")]
fn nth_post_upgrade(n: u32, state: Vec<u8>) -> Option<Result<(), pezsp_runtime::TryRuntimeError>> {
fn nth_post_upgrade(
n: u32,
state: Vec<u8>,
) -> Option<Result<(), pezsp_runtime::TryRuntimeError>> {
if n != 0 {
defensive!("nth_post_upgrade should only be called with n==0");
}
@@ -970,7 +975,10 @@ impl SteppedMigrations for Tuple {
}
#[cfg(feature = "try-runtime")]
fn nth_post_upgrade(n: u32, state: Vec<u8>) -> Option<Result<(), pezsp_runtime::TryRuntimeError>> {
fn nth_post_upgrade(
n: u32,
state: Vec<u8>,
) -> Option<Result<(), pezsp_runtime::TryRuntimeError>> {
let mut i = 0;
for_tuples! ( #(
@@ -208,7 +208,8 @@ pub fn kill(child_info: &ChildInfo, key: &[u8]) {
/// Get a Vec of bytes from storage.
pub fn get_raw(child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>> {
match child_info.child_type() {
ChildType::ParentKeyId => pezsp_io::default_child_storage::get(child_info.storage_key(), key),
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::get(child_info.storage_key(), key),
}
}
@@ -311,8 +311,8 @@ pub fn take_storage_item<K: Encode + Sized, T: Decode + Sized, H: StorageHasher>
///
/// # Example
///
/// If a pezpallet named "my_example" has 2 storages named "Foo" and "Bar" and the pezpallet is renamed
/// "my_new_example_name", a migration can be:
/// If a pezpallet named "my_example" has 2 storages named "Foo" and "Bar" and the pezpallet is
/// renamed "my_new_example_name", a migration can be:
/// ```
/// # use pezframe_support::storage::migration::move_storage_from_pallet;
/// # pezsp_io::TestExternalities::new_empty().execute_with(|| {
@@ -885,8 +885,9 @@ pub trait StorageNMap<K: KeyGenerator, V: FullCodec> {
/// Attempt to remove items from the map matching a `partial_key` prefix.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map which match the `partial key`. If so, then the map may not be
@@ -1391,8 +1392,9 @@ pub trait StoragePrefixedMap<Value: FullCodec> {
/// Attempt to remove all items from the map.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map. If so, then the map may not be empty when the resultant
@@ -1752,8 +1754,8 @@ mod test {
use super::*;
use crate::{assert_ok, hash::Identity, pezpallet_prelude::NMapKey, Twox128};
use bounded_vec::BoundedVec;
use pezframe_support::traits::ConstU32;
use generator::StorageValue as _;
use pezframe_support::traits::ConstU32;
use pezsp_crypto_hashing::twox_128;
use pezsp_io::TestExternalities;
use weak_bounded_vec::WeakBoundedVec;
@@ -59,7 +59,10 @@ impl<'a> StorageNoopGuard<'a> {
/// Creates a new [`StorageNoopGuard`] with a custom error message.
pub fn from_error_message(error_message: &'a str) -> Self {
Self { storage_root: pezsp_io::storage::root(pezsp_runtime::StateVersion::V1), error_message }
Self {
storage_root: pezsp_io::storage::root(pezsp_runtime::StateVersion::V1),
error_message,
}
}
/// Sets a custom error message for a [`StorageNoopGuard`].
@@ -338,8 +338,9 @@ where
/// Attempt to remove all items from the map.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map. If so, then the map may not be empty when the resultant
@@ -239,8 +239,9 @@ where
/// Attempt to remove items from the map matching a `partial_key` prefix.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map which match the `partial key`. If so, then the map may not be
@@ -401,8 +402,9 @@ where
/// Attempt to remove all items from the map.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map. If so, then the map may not be empty when the resultant
@@ -330,8 +330,9 @@ where
/// Attempt to remove items from the map matching a `first_key` prefix.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map which match the `first_key`. If so, then the map may not be
@@ -523,8 +524,9 @@ where
/// Attempt to remove all items from the map.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map. If so, then the map may not be empty when the resultant
@@ -89,8 +89,8 @@ where
Key: FullCodec + MaxEncodedLen,
{
fn get() -> u32 {
// The `max_len` of the key hash plus the pezpallet prefix and storage prefix (which both are
// hashed with `Twox128`).
// The `max_len` of the key hash plus the pezpallet prefix and storage prefix (which both
// are hashed with `Twox128`).
let z = Hasher::max_len::<Key>() + Twox128::max_len::<()>() * 2;
z as u32
}
@@ -336,8 +336,9 @@ where
/// Attempt to remove all items from the map.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map. If so, then the map may not be empty when the resultant
@@ -37,8 +37,8 @@ use pezsp_runtime::SaturatedConversion;
/// A type representing an *NMap* in storage. This structure associates an arbitrary number of keys
/// with a value of a specified type stored on-chain.
///
/// For example, [`StorageDoubleMap`](pezframe_support::storage::types::StorageDoubleMap) is a special
/// case of an *NMap* with N = 2.
/// For example, [`StorageDoubleMap`](pezframe_support::storage::types::StorageDoubleMap) is a
/// special case of an *NMap* with N = 2.
///
/// For general information regarding the `#[pezpallet::storage]` attribute, refer to
/// [`crate::pezpallet_macros::storage`].
@@ -238,8 +238,9 @@ where
/// Attempt to remove items from the map matching a `partial_key` prefix.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map which match the `partial key`. If so, then the map may not be
@@ -402,8 +403,9 @@ where
/// Attempt to remove all items from the map.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result.
/// Once the resultant `maybe_cursor` field is `None`, then no further items remain to be
/// deleted.
///
/// NOTE: After the initial call for any given map, it is important that no further items
/// are inserted into the map. If so, then the map may not be empty when the resultant
@@ -127,8 +127,8 @@ pub fn kill_prefix(prefix: &[u8], limit: Option<u32>) -> pezsp_io::KillStorageRe
/// cursor need not be passed in and a `None` may be passed instead. This exception may be useful
/// then making this call solely from a block-hook such as `on_initialize`.
///
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once the
/// resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
/// Returns [`MultiRemovalResults`](pezsp_io::MultiRemovalResults) to inform about the result. Once
/// the resultant `maybe_cursor` field is `None`, then no further items remain to be deleted.
///
/// NOTE: After the initial call for any given child storage, it is important that no keys further
/// keys are inserted. If so, then they may or may not be deleted by subsequent calls.
@@ -128,8 +128,8 @@ fn pezpallet_name_attribute() {
Value::<Runtime>::put(1);
assert_eq!(1, Value::<Runtime>::get().unwrap());
// The prefix is the pezpallet name. In this case the pezpallet name is `System` as declared in
// `construct_runtime!`.
// The prefix is the pezpallet name. In this case the pezpallet name is `System` as declared
// in `construct_runtime!`.
assert_eq!(&b"System"[..], Value::<Runtime>::pezpallet_prefix());
});
}
@@ -83,8 +83,8 @@ impl AggregatedKeyValue for () {
/// Allows to create a `ParameterStore` from a `RuntimeParameterStore`.
///
/// This concretization is useful when configuring pallets, since a pezpallet will require a parameter
/// store for its own KV type and not the aggregated runtime-wide KV type.
/// This concretization is useful when configuring pallets, since a pezpallet will require a
/// parameter store for its own KV type and not the aggregated runtime-wide KV type.
pub struct ParameterStoreAdapter<PS, KV>(core::marker::PhantomData<(PS, KV)>);
impl<PS, KV> ParameterStore<KV> for ParameterStoreAdapter<PS, KV>
@@ -25,16 +25,16 @@ use core::marker::PhantomData;
/// ## Notes
///
/// The pezpallet error enum has a maximum encoded size as defined by
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`]. If the pezpallet error type exceeds this size
/// limit, a static assertion during compilation will fail. The compilation error will be in the
/// format of `error[E0080]: evaluation of constant value failed` due to the usage of
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`]. If the pezpallet error type exceeds this
/// size limit, a static assertion during compilation will fail. The compilation error will be in
/// the format of `error[E0080]: evaluation of constant value failed` due to the usage of
/// const assertions.
pub trait PalletError: Encode + Decode {
/// The maximum encoded size for the implementing type.
///
/// This will be used to check whether the pezpallet error type is less than or equal to
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`], and if it is, a compilation error will be
/// thrown.
/// [`pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE`], and if it is, a compilation error will
/// be thrown.
const MAX_ENCODED_SIZE: usize;
}
@@ -397,8 +397,8 @@ impl_for_tuples_attr! {
/// > because they are not part of the consensus/main block building logic. See
/// > [`OffchainWorker`](crate::traits::misc::OffchainWorker) for more information.
///
/// To learn more about the execution of hooks see the FRAME `Executive` pezpallet which is in charge
/// of dispatching extrinsics and calling hooks in the correct order.
/// To learn more about the execution of hooks see the FRAME `Executive` pezpallet which is in
/// charge of dispatching extrinsics and calling hooks in the correct order.
pub trait Hooks<BlockNumber> {
/// Block initialization hook. This is called at the very beginning of block execution.
///
@@ -414,8 +414,8 @@ pub trait Hooks<BlockNumber> {
/// complexity. For example, do not execute any unbounded iterations.
///
/// NOTE: This function is called BEFORE ANY extrinsic in a block is applied, including inherent
/// extrinsics. Hence for instance, if you runtime includes `pezpallet-timestamp`, the `timestamp`
/// is not yet up to date at this point.
/// extrinsics. Hence for instance, if you runtime includes `pezpallet-timestamp`, the
/// `timestamp` is not yet up to date at this point.
fn on_initialize(_n: BlockNumber) -> Weight {
Weight::zero()
}
@@ -461,9 +461,9 @@ pub trait Hooks<BlockNumber> {
/// Hook executed when a code change (aka. a "runtime upgrade") is detected by the FRAME
/// `Executive` pezpallet.
///
/// Be aware that this is called before [`Hooks::on_initialize`] of any pezpallet; therefore, a lot
/// of the critical storage items such as `block_number` in system pezpallet might have not been
/// set yet.
/// Be aware that this is called before [`Hooks::on_initialize`] of any pezpallet; therefore, a
/// lot of the critical storage items such as `block_number` in system pezpallet might have not
/// been set yet.
///
/// Similar to [`Hooks::on_initialize`], any code in this block is mandatory and MUST execute.
/// It is strongly recommended to dry-run the execution of these hooks using
@@ -23,10 +23,10 @@ use crate::defensive;
use alloc::vec::Vec;
use codec::{Decode, DecodeWithMemTracking, Encode, FullCodec, MaxEncodedLen};
use core::{cmp::Ordering, fmt::Debug, marker::PhantomData};
use scale_info::TypeInfo;
use pezsp_core::{ConstU32, Get, TypedGet};
use pezsp_runtime::{traits::Convert, BoundedSlice, RuntimeDebug};
use pezsp_weights::{Weight, WeightMeter};
use scale_info::TypeInfo;
/// Errors that can happen when attempting to process a message with
/// [`ProcessMessage::process_message()`].
@@ -185,7 +185,10 @@ impl StorageVersion {
/// See [`STORAGE_VERSION_STORAGE_KEY_POSTFIX`] on how this key is built.
pub fn storage_key<P: PalletInfoAccess>() -> [u8; 32] {
let pezpallet_name = P::name();
crate::storage::storage_prefix(pezpallet_name.as_bytes(), STORAGE_VERSION_STORAGE_KEY_POSTFIX)
crate::storage::storage_prefix(
pezpallet_name.as_bytes(),
STORAGE_VERSION_STORAGE_KEY_POSTFIX,
)
}
/// Put this storage version for the given pezpallet into the storage.
@@ -268,8 +271,8 @@ impl Add<u16> for StorageVersion {
/// If you (the reader) end up here, it probably means that you tried to compare
/// [`GetStorageVersion::on_chain_storage_version`] against
/// [`GetStorageVersion::in_code_storage_version`]. This basically means that the
/// [`storage_version`](crate::pezpallet_macros::storage_version) is missing from the pezpallet where the
/// mentioned functions are being called, and needs to be defined.
/// [`storage_version`](crate::pezpallet_macros::storage_version) is missing from the pezpallet
/// where the mentioned functions are being called, and needs to be defined.
#[derive(Debug, Default)]
pub struct NoStorageVersionSet;
@@ -279,8 +282,8 @@ pub struct NoStorageVersionSet;
/// 1. An in-code storage version
/// 2. An on-chain storage version
///
/// The in-code storage version is the version of the pezpallet as defined in the runtime blob, and the
/// on-chain storage version is the version of the pezpallet stored on-chain.
/// The in-code storage version is the version of the pezpallet as defined in the runtime blob, and
/// the on-chain storage version is the version of the pezpallet stored on-chain.
///
/// Storage versions should be only ever be out of sync when a pezpallet has been updated to a new
/// version and the in-code version is incremented, but the migration has not yet been executed
@@ -291,16 +294,17 @@ pub struct NoStorageVersionSet;
pub trait GetStorageVersion {
/// This type is generated by the [`pezpallet`](crate::pezpallet) macro.
///
/// If the [`storage_version`](crate::pezpallet_macros::storage_version) attribute isn't specified,
/// this is set to [`NoStorageVersionSet`] to signify that it is missing.
/// If the [`storage_version`](crate::pezpallet_macros::storage_version) attribute isn't
/// specified, this is set to [`NoStorageVersionSet`] to signify that it is missing.
///
/// If the [`storage_version`](crate::pezpallet_macros::storage_version) attribute is specified,
/// this is be set to a [`StorageVersion`] corresponding to the attribute.
///
/// The intention of using [`NoStorageVersionSet`] instead of defaulting to a [`StorageVersion`]
/// of zero is to prevent developers from forgetting to set
/// [`storage_version`](crate::pezpallet_macros::storage_version) when it is required, like in the
/// case that they wish to compare the in-code storage version to the on-chain storage version.
/// [`storage_version`](crate::pezpallet_macros::storage_version) when it is required, like in
/// the case that they wish to compare the in-code storage version to the on-chain storage
/// version.
type InCodeStorageVersion;
#[deprecated(
@@ -21,9 +21,9 @@ use crate::dispatch::{DispatchResult, Parameter};
use alloc::{vec, vec::Vec};
use codec::{CompactLen, Decode, DecodeLimit, Encode, EncodeLike, Input, MaxEncodedLen};
use impl_trait_for_tuples::impl_for_tuples;
use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter};
use pezsp_arithmetic::traits::{CheckedAdd, CheckedMul, CheckedSub, One, Saturating};
use pezsp_core::bounded::bounded_vec::TruncateFrom;
use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter};
use core::cmp::Ordering;
#[doc(hidden)]
@@ -19,12 +19,12 @@
use alloc::borrow::Cow;
use codec::{Decode, DecodeWithMemTracking, Encode, EncodeLike, MaxEncodedLen};
use scale_info::TypeInfo;
use pezsp_core::RuntimeDebug;
use pezsp_runtime::{
traits::{ConstU32, Hash},
DispatchError,
};
use scale_info::TypeInfo;
pub type BoundedInline = crate::BoundedVec<u8, ConstU32<128>>;
@@ -21,9 +21,9 @@ use core::marker::PhantomData;
use codec::{Decode, DecodeWithMemTracking, Encode, FullCodec, MaxEncodedLen};
use pezframe_support::{CloneNoBound, EqNoBound, Parameter, PartialEqNoBound};
use scale_info::TypeInfo;
use pezsp_core::ConstU32;
use pezsp_runtime::{traits::Member, BoundedVec, DispatchError, DispatchResult, RuntimeDebug};
use scale_info::TypeInfo;
/// Identity of personhood.
///
@@ -22,8 +22,8 @@ use super::PreimageProvider;
use alloc::vec::Vec;
use codec::{Codec, Decode, DecodeWithMemTracking, Encode, EncodeLike, MaxEncodedLen};
use core::{fmt::Debug, result::Result};
use scale_info::TypeInfo;
use pezsp_runtime::{traits::Saturating, DispatchError, RuntimeDebug};
use scale_info::TypeInfo;
/// Information relating to the period of a scheduled task. First item is the length of the
/// period and the second is the number of times it should be executed in total before the task
@@ -20,20 +20,20 @@
use alloc::{collections::btree_set::BTreeSet, vec, vec::Vec};
use codec::{Decode, DecodeWithMemTracking, Encode, FullCodec, MaxEncodedLen};
use core::{marker::PhantomData, mem, ops::Drop};
use pezframe_support::CloneNoBound;
use impl_trait_for_tuples::impl_for_tuples;
use scale_info::TypeInfo;
use pezframe_support::CloneNoBound;
pub use pezsp_core::storage::TrackedStorageKey;
use pezsp_core::Get;
use pezsp_runtime::{
traits::{Convert, Member},
DispatchError, RuntimeDebug,
};
use scale_info::TypeInfo;
/// An instance of a pezpallet in the storage.
///
/// It is required that these instances are unique, to support multiple instances per pezpallet in the
/// same runtime!
/// It is required that these instances are unique, to support multiple instances per pezpallet in
/// the same runtime!
///
/// E.g. for module MyModule default instance will have prefix "MyModule" and other instances
/// "InstanceNMyModule".
@@ -21,9 +21,9 @@
use alloc::{vec, vec::IntoIter};
use codec::FullCodec;
use core::{fmt::Debug, iter::Iterator};
use scale_info::TypeInfo;
use pezsp_runtime::DispatchError;
use pezsp_weights::Weight;
use scale_info::TypeInfo;
/// Contain's re-exports of all the supporting types for the [`Task`] trait. Used in the macro
/// expansion of `RuntimeTask`.
@@ -32,9 +32,9 @@ pub mod __private {
pub use alloc::{vec, vec::IntoIter};
pub use codec::FullCodec;
pub use core::{fmt::Debug, iter::Iterator};
pub use scale_info::TypeInfo;
pub use pezsp_runtime::DispatchError;
pub use pezsp_weights::Weight;
pub use scale_info::TypeInfo;
}
/// A general-purpose trait which defines a type of service work (i.e., work to performed by an
@@ -37,11 +37,12 @@
//!
//! ### Usage Example
//!
//! This example shows how to interact with pezpallet-uniques (assuming the pezpallet called Uniques in
//! the chains Runtime) via the asset ops.
//! This example shows how to interact with pezpallet-uniques (assuming the pezpallet called Uniques
//! in the chains Runtime) via the asset ops.
//!
//! If you are interested in the implementation example, you can look at the pezpallet-uniques
//! implementation. You can check out the pezpallet-uniques tests if you want more examples of usage.
//! implementation. You can check out the pezpallet-uniques tests if you want more examples of
//! usage.
//!
//! ```rust,ignore
//! type Collection = pezpallet_uniques::asset_ops::Collection<Uniques>;
@@ -19,9 +19,9 @@
use super::*;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use pezsp_core::RuntimeDebug;
use pezsp_runtime::traits::Convert;
use scale_info::TypeInfo;
/// The `CheckState` is a strategy that accepts an `Inspect` value and the `Inner` strategy.
///
@@ -17,8 +17,8 @@
//! The reservable currency trait.
use scale_info::TypeInfo;
use pezsp_core::Get;
use scale_info::TypeInfo;
use super::{super::misc::BalanceStatus, Currency};
use crate::{
@@ -20,12 +20,12 @@
//! See the [`crate::traits::fungible`] doc for more information about fungible traits
//! including the place of the Freezes in FRAME.
use scale_info::TypeInfo;
use pezsp_arithmetic::{
traits::{CheckedAdd, CheckedSub},
ArithmeticError,
};
use pezsp_runtime::{DispatchResult, TokenError};
use scale_info::TypeInfo;
use crate::{ensure, traits::tokens::Fortitude};
@@ -31,12 +31,12 @@ use crate::{
Restriction::{self, Free, OnHold},
},
};
use scale_info::TypeInfo;
use pezsp_arithmetic::{
traits::{CheckedAdd, CheckedSub, Zero},
ArithmeticError,
};
use pezsp_runtime::{DispatchError, DispatchResult, Saturating, TokenError};
use scale_info::TypeInfo;
use super::*;
@@ -181,7 +181,8 @@ impl<B: Balance, OnDrop: HandleImbalanceDrop<B>, OppositeOnDrop: HandleImbalance
/// Converts a `fungibles` `imbalance` instance to an instance of a `fungible` imbalance type.
///
/// This function facilitates imbalance conversions within the implementations of
/// [`pezframe_support::traits::fungibles::UnionOf`], [`pezframe_support::traits::fungible::UnionOf`], and
/// [`pezframe_support::traits::fungibles::UnionOf`],
/// [`pezframe_support::traits::fungible::UnionOf`], and
/// [`pezframe_support::traits::fungible::ItemOf`] adapters. It is intended only for internal use
/// within the current crate.
pub(crate) fn from_fungibles<
@@ -17,8 +17,8 @@
//! Adapter to use `fungibles::*` implementations as `fungible::*`.
//!
//! This allows for a `fungibles` asset, e.g. from the `pezpallet_assets` pezpallet, to be used when a
//! `fungible` asset is expected.
//! This allows for a `fungibles` asset, e.g. from the `pezpallet_assets` pezpallet, to be used when
//! a `fungible` asset is expected.
//!
//! See the [`crate::traits::fungible`] doc for more information about fungible traits.
@@ -52,8 +52,8 @@
//! transfer.
//!
//! - **Held Balance**: Held balance still belongs to the account holder, but is suspended — it
//! cannot be transferred or used for most operations. It may be slashed by the pezpallet that placed
//! the hold.
//! cannot be transferred or used for most operations. It may be slashed by the pezpallet that
//! placed the hold.
//!
//! Multiple holds stack rather than overlay. This means that if an account has
//! 3 holds for 100 units, the account can spend its funds for any reason down to 300 units, at
@@ -164,9 +164,9 @@ mod union_of;
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use core::marker::PhantomData;
use pezframe_support_procedural::{CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound};
use scale_info::TypeInfo;
#[cfg(feature = "runtime-benchmarks")]
use pezsp_runtime::Saturating;
use scale_info::TypeInfo;
use super::{
Fortitude::{Force, Polite},
@@ -179,12 +179,12 @@ pub use hold::{
};
pub use imbalance::{Credit, Debt, HandleImbalanceDrop, Imbalance};
pub use item_of::ItemOf;
pub use regular::{
Balanced, DecreaseIssuance, Dust, IncreaseIssuance, Inspect, Mutate, Unbalanced,
};
use pezsp_arithmetic::traits::Zero;
use pezsp_core::Get;
use pezsp_runtime::{traits::Convert, DispatchError};
pub use regular::{
Balanced, DecreaseIssuance, Dust, IncreaseIssuance, Inspect, Mutate, Unbalanced,
};
pub use union_of::{NativeFromLeft, NativeOrWithId, UnionOf};
#[cfg(feature = "experimental")]
@@ -30,13 +30,13 @@ use pezframe_support::traits::{
},
AccountTouch,
};
use scale_info::TypeInfo;
use pezsp_runtime::{
traits::Convert,
DispatchError, DispatchResult, Either,
Either::{Left, Right},
RuntimeDebug,
};
use scale_info::TypeInfo;
/// The `NativeOrWithId` enum classifies an asset as either `Native` to the current chain or as an
/// asset with a specific ID.
@@ -20,12 +20,12 @@
//! See the [`crate::traits::fungibles`] doc for more information about fungibles traits.
use crate::{ensure, traits::tokens::Fortitude};
use scale_info::TypeInfo;
use pezsp_arithmetic::{
traits::{CheckedAdd, CheckedSub},
ArithmeticError,
};
use pezsp_runtime::{DispatchResult, TokenError};
use scale_info::TypeInfo;
/// Trait for inspecting a fungible asset which can be frozen. Freezing is essentially setting a
/// minimum balance below which the total balance (inclusive of any funds placed on hold) may not
@@ -30,12 +30,12 @@ use crate::{
Restriction::{self, Free, OnHold},
},
};
use scale_info::TypeInfo;
use pezsp_arithmetic::{
traits::{CheckedAdd, CheckedSub, Zero},
ArithmeticError,
};
use pezsp_runtime::{DispatchError, DispatchResult, Saturating, TokenError};
use scale_info::TypeInfo;
use super::*;
@@ -195,7 +195,8 @@ impl<
/// a specified `asset`.
///
/// This function facilitates imbalance conversions within the implementations of
/// [`pezframe_support::traits::fungibles::UnionOf`], [`pezframe_support::traits::fungible::UnionOf`], and
/// [`pezframe_support::traits::fungibles::UnionOf`],
/// [`pezframe_support::traits::fungible::UnionOf`], and
/// [`pezframe_support::traits::fungible::ItemOf`] adapters. It is intended only for internal use
/// within the current crate.
pub(crate) fn from_fungible<
@@ -217,7 +218,8 @@ pub(crate) fn from_fungible<
/// Converts a `fungibles` `imbalance` instance of one type to another using a specified `asset`.
///
/// This function facilitates imbalance conversions within the implementations of
/// [`pezframe_support::traits::fungibles::UnionOf`], [`pezframe_support::traits::fungible::UnionOf`], and
/// [`pezframe_support::traits::fungibles::UnionOf`],
/// [`pezframe_support::traits::fungible::UnionOf`], and
/// [`pezframe_support::traits::fungible::ItemOf`] adapters. It is intended only for internal use
/// within the current crate.
pub(crate) fn from_fungibles<
@@ -19,9 +19,9 @@
use codec::{FullCodec, MaxEncodedLen};
use core::fmt::Debug;
use scale_info::TypeInfo;
use pezsp_core::TypedGet;
use pezsp_runtime::DispatchError;
use scale_info::TypeInfo;
use super::{fungible, fungibles, Balance, Preservation::Expendable};
@@ -20,9 +20,9 @@
use crate::pezpallet_prelude::{Decode, Encode};
use core::fmt::Debug;
use pezframe_support::traits::tokens::PaymentStatus;
use scale_info::TypeInfo;
use pezsp_debug_derive::RuntimeDebug;
use pezsp_runtime::codec::{FullCodec, MaxEncodedLen};
use scale_info::TypeInfo;
/// Is intended to be implemented using a `fungible` impl, but can also be implemented with
/// XCM/Asset and made generic over assets.
@@ -49,8 +49,8 @@ pub trait VoteTally<Votes, Class> {
/// A function that should be called before any use of the `runtime-benchmarks` gated functions
/// of the `VoteTally` trait.
///
/// Should be used to set up any needed state in a Pezpallet which implements `VoteTally` so that
/// benchmarks that execute will complete successfully. `class` can be used to set up a
/// Should be used to set up any needed state in a Pezpallet which implements `VoteTally` so
/// that benchmarks that execute will complete successfully. `class` can be used to set up a
/// particular class of voters, and `granularity` is used to determine the weight of one vote
/// relative to total unanimity.
///
@@ -19,8 +19,8 @@
use alloc::vec::Vec;
use codec::{Decode, DecodeAll, Encode, Output};
use scale_info::TypeInfo;
use pezsp_runtime::RuntimeDebug;
use scale_info::TypeInfo;
/// The unique identifier for a view function.
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
@@ -28,7 +28,8 @@ pub struct ViewFunctionId {
/// The part of the id for dispatching view functions from the top level of the runtime.
///
/// Specifies which view function grouping this view function belongs to. This could be a group
/// of view functions associated with a pezpallet, or a pezpallet agnostic group of view functions.
/// of view functions associated with a pezpallet, or a pezpallet agnostic group of view
/// functions.
pub prefix: [u8; 16],
/// The part of the id for dispatching to a view function within a group.
pub suffix: [u8; 16],
@@ -61,8 +62,8 @@ impl From<codec::Error> for ViewFunctionDispatchError {
}
/// Implemented by both pallets and the runtime. The runtime is dispatching by prefix using the
/// pezpallet implementation of `ViewFunctionIdPrefix` then the pezpallet is dispatching by suffix using
/// the methods implementation of `ViewFunctionIdSuffix`.
/// pezpallet implementation of `ViewFunctionIdPrefix` then the pezpallet is dispatching by suffix
/// using the methods implementation of `ViewFunctionIdSuffix`.
///
/// In more details, `ViewFunctionId` = `ViewFunctionIdPrefix` ++ `ViewFunctionIdSuffix`, where
/// `ViewFunctionIdPrefix=twox_128(pezpallet_name)` and
@@ -15,8 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test that `construct_runtime!` also works when `pezframe-support` or `pezframe-system` are renamed in
//! the `Cargo.toml`.
//! Test that `construct_runtime!` also works when `pezframe-support` or `pezframe-system` are
//! renamed in the `Cargo.toml`.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -35,7 +35,9 @@ use pezsp_version::RuntimeVersion;
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("pezframe-support-test-compile-pass"),
impl_name: alloc::borrow::Cow::Borrowed("bizinikiwi-pezframe-support-test-compile-pass-runtime"),
impl_name: alloc::borrow::Cow::Borrowed(
"bizinikiwi-pezframe-support-test-compile-pass-runtime",
),
authoring_version: 0,
spec_version: 0,
impl_version: 0,
+2 -2
View File
@@ -125,8 +125,8 @@ pub mod pezpallet_prelude {
pub type BlockNumberFor<T> = <T as super::Config>::BlockNumber;
}
/// Provides an implementation of [`pezframe_support::traits::Randomness`] that should only be used in
/// tests!
/// Provides an implementation of [`pezframe_support::traits::Randomness`] that should only be used
/// in tests!
pub struct TestRandomness<T>(core::marker::PhantomData<T>);
impl<Output: codec::Decode + Default, T>
@@ -412,8 +412,9 @@ fn valid_call_weight_test() {
let info = tx.get_dispatch_info();
let len = tx.using_encoded(|e| e.len());
let checked = Checkable::check(tx, &pezframe_system::ChainContext::<Runtime>::default())
.expect("Transaction is general so signature is good");
let checked =
Checkable::check(tx, &pezframe_system::ChainContext::<Runtime>::default())
.expect("Transaction is general so signature is good");
checked
.validate::<Runtime>(TransactionSource::External, &info, len)
@@ -498,8 +499,9 @@ fn call_validity() {
let info = tx.get_dispatch_info();
let len = tx.using_encoded(|e| e.len());
let checked = Checkable::check(tx, &pezframe_system::ChainContext::<Runtime>::default())
.expect("Transaction is general so signature is good");
let checked =
Checkable::check(tx, &pezframe_system::ChainContext::<Runtime>::default())
.expect("Transaction is general so signature is good");
let res = checked.validate::<Runtime>(TransactionSource::External, &info, len);
assert_eq!(res, validate_res);
@@ -61,7 +61,8 @@ pub mod pezpallet {
type Balance: Parameter + Default + TypeInfo;
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::pezpallet]
@@ -97,7 +97,8 @@ pub mod module {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::call]
@@ -21,8 +21,8 @@ use pezframe_support::{
assert_ok, derive_impl,
dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Parameter, Pays},
dispatch_context::with_context,
pezpallet_prelude::{StorageInfoTrait, ValueQuery},
parameter_types,
pezpallet_prelude::{StorageInfoTrait, ValueQuery},
storage::{unhashed, unhashed::contains_prefixed_key},
traits::{
ConstU32, GetCallIndex, GetCallName, GetStorageVersion, OnFinalize, OnGenesis,
@@ -33,7 +33,6 @@ use pezframe_support::{
OrdNoBound, PartialOrdNoBound,
};
use pezframe_system::offchain::{CreateSignedTransaction, CreateTransactionBase, SigningTypes};
use scale_info::{meta_type, TypeInfo};
use pezsp_io::{
hashing::{blake2_128, twox_128, twox_64},
TestExternalities,
@@ -43,6 +42,7 @@ use pezsp_runtime::{
traits::{Block as BlockT, Dispatchable},
DispatchError, ModuleError,
};
use scale_info::{meta_type, TypeInfo};
parameter_types! {
/// Used to control if the storage version should be updated.
@@ -149,7 +149,8 @@ pub mod pezpallet {
type Balance: Parameter + Default + TypeInfo;
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::extra_constants]
@@ -678,7 +679,8 @@ pub mod pallet2 {
}
}
/// Test that the supertrait check works when we pass some parameter to the `pezframe_system::Config`.
/// Test that the supertrait check works when we pass some parameter to the
/// `pezframe_system::Config`.
#[pezframe_support::pezpallet]
pub mod pallet3 {
#[pezpallet::config]
@@ -704,7 +706,8 @@ pub mod pallet4 {
impl<T: Config> Pezpallet<T> {}
}
/// Test that the supertrait check works when we pass some parameter to the `pezframe_system::Config`.
/// Test that the supertrait check works when we pass some parameter to the
/// `pezframe_system::Config`.
#[pezframe_support::pezpallet]
pub mod pallet5 {
#[pezpallet::config]
@@ -973,7 +976,10 @@ fn error_expand() {
);
assert_eq!(<pezpallet::Error::<Runtime> as PalletError>::MAX_ENCODED_SIZE, 3);
#[cfg(feature = "frame-feature-testing")]
assert_eq!(format!("{:?}", pezpallet::Error::<Runtime>::FeatureTest), String::from("FeatureTest"),);
assert_eq!(
format!("{:?}", pezpallet::Error::<Runtime>::FeatureTest),
String::from("FeatureTest"),
);
}
#[test]
@@ -993,8 +999,9 @@ fn inherent_expand() {
let inherents = InherentData::new().create_extrinsics();
let expected =
vec![UncheckedExtrinsic::new_bare(RuntimeCall::Example(pezpallet::Call::foo_no_post_info {}))];
let expected = vec![UncheckedExtrinsic::new_bare(RuntimeCall::Example(
pezpallet::Call::foo_no_post_info {},
))];
assert_eq!(expected, inherents);
let block = Block::new(
@@ -1006,7 +1013,9 @@ fn inherent_expand() {
Digest::default(),
),
vec![
UncheckedExtrinsic::new_bare(RuntimeCall::Example(pezpallet::Call::foo_no_post_info {})),
UncheckedExtrinsic::new_bare(RuntimeCall::Example(
pezpallet::Call::foo_no_post_info {},
)),
UncheckedExtrinsic::new_bare(RuntimeCall::Example(pezpallet::Call::foo {
foo: 1,
bar: 0,
@@ -1025,7 +1034,9 @@ fn inherent_expand() {
Digest::default(),
),
vec![
UncheckedExtrinsic::new_bare(RuntimeCall::Example(pezpallet::Call::foo_no_post_info {})),
UncheckedExtrinsic::new_bare(RuntimeCall::Example(
pezpallet::Call::foo_no_post_info {},
)),
UncheckedExtrinsic::new_bare(RuntimeCall::Example(pezpallet::Call::foo {
foo: 0,
bar: 0,
@@ -1043,9 +1054,9 @@ fn inherent_expand() {
BlakeTwo256::hash(b"test"),
Digest::default(),
),
vec![UncheckedExtrinsic::new_bare(RuntimeCall::Example(pezpallet::Call::foo_storage_layer {
foo: 0,
}))],
vec![UncheckedExtrinsic::new_bare(RuntimeCall::Example(
pezpallet::Call::foo_storage_layer { foo: 0 },
))],
);
let mut inherent = InherentData::new();
@@ -1081,12 +1092,14 @@ fn validate_unsigned_expand() {
};
let call = pezpallet::Call::<Runtime>::foo_no_post_info {};
let validity = pezpallet::Pezpallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err();
let validity =
pezpallet::Pezpallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err();
assert_eq!(validity, TransactionValidityError::Invalid(InvalidTransaction::Call));
let call = pezpallet::Call::<Runtime>::foo_storage_layer { foo: 0 };
let validity = pezpallet::Pezpallet::validate_unsigned(TransactionSource::External, &call).unwrap();
let validity =
pezpallet::Pezpallet::validate_unsigned(TransactionSource::External, &call).unwrap();
assert_eq!(validity, ValidTransaction::default());
}
@@ -1332,7 +1345,10 @@ fn pezpallet_hooks_expand() {
#[test]
fn pezpallet_on_genesis() {
TestExternalities::default().execute_with(|| {
assert_eq!(pezpallet::Pezpallet::<Runtime>::on_chain_storage_version(), StorageVersion::new(0));
assert_eq!(
pezpallet::Pezpallet::<Runtime>::on_chain_storage_version(),
StorageVersion::new(0)
);
pezpallet::Pezpallet::<Runtime>::on_genesis();
assert_eq!(
pezpallet::Pezpallet::<Runtime>::in_code_storage_version(),
@@ -1346,7 +1362,10 @@ fn migrate_from_pallet_version_to_storage_version() {
const PALLET_VERSION_STORAGE_KEY_POSTFIX: &[u8] = b":__PALLET_VERSION__:";
fn pezpallet_version_key(name: &str) -> [u8; 32] {
pezframe_support::storage::storage_prefix(name.as_bytes(), PALLET_VERSION_STORAGE_KEY_POSTFIX)
pezframe_support::storage::storage_prefix(
name.as_bytes(),
PALLET_VERSION_STORAGE_KEY_POSTFIX,
)
}
TestExternalities::default().execute_with(|| {
@@ -2335,8 +2354,8 @@ fn pezpallet_on_chain_storage_version_initializes_correctly() {
AllPalletsWithSystem,
>;
// Simple example of a pezpallet with in-code version 10 being added to the runtime for the first
// time.
// Simple example of a pezpallet with in-code version 10 being added to the runtime for the
// first time.
TestExternalities::default().execute_with(|| {
let in_code_version = Example::in_code_storage_version();
@@ -2345,8 +2364,8 @@ fn pezpallet_on_chain_storage_version_initializes_correctly() {
let exists = contains_prefixed_key(&pezpallet_hashed_prefix);
assert_eq!(exists, false);
// [`pezframe_support::traits::BeforeAllRuntimeMigrations`] hook should initialize the storage
// version.
// [`pezframe_support::traits::BeforeAllRuntimeMigrations`] hook should initialize the
// storage version.
Executive::execute_on_runtime_upgrade();
// Check that the storage version was initialized to the in-code version
@@ -2533,7 +2552,9 @@ fn test_error_feature_parsing() {
#[test]
fn pezpallet_metadata() {
use pezsp_metadata_ir::{EnumDeprecationInfoIR, ItemDeprecationInfoIR, VariantDeprecationInfoIR};
use pezsp_metadata_ir::{
EnumDeprecationInfoIR, ItemDeprecationInfoIR, VariantDeprecationInfoIR,
};
let pallets = Runtime::metadata_ir().pallets;
let example = pallets[0].clone();
let example2 = pallets[1].clone();
@@ -16,8 +16,8 @@
// limitations under the License.
use pezframe_support::{derive_impl, traits::ConstU32};
use scale_info::meta_type;
use pezsp_metadata_ir::PalletAssociatedTypeMetadataIR;
use scale_info::meta_type;
pub type BlockNumber = u64;
pub type Header = pezsp_runtime::generic::Header<u32, pezsp_runtime::traits::BlakeTwo256>;
@@ -36,7 +36,8 @@ pub mod pezpallet {
pub trait Config: pezframe_system::Config {
// Runtime events already propagated to the metadata.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
// Constants are already propagated.
#[pezpallet::constant]
@@ -61,7 +62,8 @@ pub mod pallet2 {
pub trait Config: pezframe_system::Config {
// Runtime events already propagated to the metadata.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
// Constants are already propagated.
#[pezpallet::constant]
@@ -98,7 +100,8 @@ pub mod pallet3 {
pub trait Config: pezframe_system::Config {
// Runtime events already propagated to the metadata.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
// Constants are already propagated.
#[pezpallet::constant]
@@ -193,7 +196,11 @@ fn associated_types_metadata() {
pretty_assertions::assert_eq!(pezpallet.associated_types, vec![]);
// Collect by default types that implement TypeInfo or Parameter.
let pezpallet = ir.pallets.iter().find(|pezpallet| pezpallet.name == "DefaultInclusion").unwrap();
let pezpallet = ir
.pallets
.iter()
.find(|pezpallet| pezpallet.name == "DefaultInclusion")
.unwrap();
pretty_assertions::assert_eq!(
pezpallet.associated_types,
vec![
@@ -211,7 +218,11 @@ fn associated_types_metadata() {
);
// Explicitly include associated types.
let pezpallet = ir.pallets.iter().find(|pezpallet| pezpallet.name == "ExplicitInclusion").unwrap();
let pezpallet = ir
.pallets
.iter()
.find(|pezpallet| pezpallet.name == "ExplicitInclusion")
.unwrap();
pretty_assertions::assert_eq!(
pezpallet.associated_types,
vec![PalletAssociatedTypeMetadataIR {
@@ -19,8 +19,8 @@ use core::any::TypeId;
use pezframe_support::{
derive_impl,
dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays},
pezpallet_prelude::ValueQuery,
parameter_types,
pezpallet_prelude::ValueQuery,
storage::unhashed,
traits::{
ConstU32, GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade,
@@ -409,7 +409,10 @@ fn error_expand() {
);
assert_eq!(
format!("{:?}", pezpallet::Error::<Runtime, pezpallet::Instance1>::InsufficientProposersBalance),
format!(
"{:?}",
pezpallet::Error::<Runtime, pezpallet::Instance1>::InsufficientProposersBalance
),
String::from("InsufficientProposersBalance"),
);
assert_eq!(
@@ -613,21 +616,30 @@ fn storage_expand() {
k.extend(1u8.using_encoded(blake2_128_concat));
k.extend(2u16.using_encoded(twox_64_concat));
assert_eq!(unhashed::get::<u32>(&k), Some(3u32));
assert_eq!(&k[..32], &<pezpallet::DoubleMap<Runtime, pezpallet::Instance1>>::final_prefix());
assert_eq!(
&k[..32],
&<pezpallet::DoubleMap<Runtime, pezpallet::Instance1>>::final_prefix()
);
<pezpallet::DoubleMap2<Runtime, pezpallet::Instance1>>::insert(&1, &2, &3);
let mut k = [twox_128(b"Instance1Example"), twox_128(b"DoubleMap2")].concat();
k.extend(1u16.using_encoded(twox_64_concat));
k.extend(2u32.using_encoded(blake2_128_concat));
assert_eq!(unhashed::get::<u64>(&k), Some(3u64));
assert_eq!(&k[..32], &<pezpallet::DoubleMap2<Runtime, pezpallet::Instance1>>::final_prefix());
assert_eq!(
&k[..32],
&<pezpallet::DoubleMap2<Runtime, pezpallet::Instance1>>::final_prefix()
);
<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::insert(&1, &2, &3);
let mut k = [twox_128(b"Instance1Example"), twox_128(b"DoubleMap3")].concat();
k.extend(1u32.using_encoded(blake2_128_concat));
k.extend(2u64.using_encoded(twox_64_concat));
assert_eq!(unhashed::get::<u128>(&k), Some(3u128));
assert_eq!(&k[..32], &<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::final_prefix());
assert_eq!(
&k[..32],
&<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::final_prefix()
);
assert_eq!(
<pezpallet::DoubleMap3<Runtime, pezpallet::Instance1>>::get(2, 3),
Err(pezpallet::Error::<Runtime, pezpallet::Instance1>::NonExistentStorageValue),
@@ -902,14 +914,18 @@ fn metadata() {
],
}),
calls: Some(scale_info::meta_type::<pezpallet::Call<Runtime>>().into()),
event: Some(PalletEventMetadata { ty: scale_info::meta_type::<pezpallet::Event<Runtime>>() }),
event: Some(PalletEventMetadata {
ty: scale_info::meta_type::<pezpallet::Event<Runtime>>(),
}),
constants: vec![PalletConstantMetadata {
name: "MyGetParam",
ty: scale_info::meta_type::<u32>(),
value: vec![10, 0, 0, 0],
docs: vec![],
}],
error: Some(PalletErrorMetadata { ty: scale_info::meta_type::<pezpallet::Error<Runtime>>() }),
error: Some(PalletErrorMetadata {
ty: scale_info::meta_type::<pezpallet::Error<Runtime>>(),
}),
};
let mut example_pallet_instance1_metadata = example_pallet_metadata.clone();
@@ -917,19 +933,22 @@ fn metadata() {
example_pallet_instance1_metadata.index = 2;
match example_pallet_instance1_metadata.calls {
Some(ref mut calls_meta) => {
calls_meta.ty = scale_info::meta_type::<pezpallet::Call<Runtime, pezpallet::Instance1>>();
calls_meta.ty =
scale_info::meta_type::<pezpallet::Call<Runtime, pezpallet::Instance1>>();
},
_ => unreachable!(),
}
match example_pallet_instance1_metadata.event {
Some(ref mut event_meta) => {
event_meta.ty = scale_info::meta_type::<pezpallet::Event<Runtime, pezpallet::Instance1>>();
event_meta.ty =
scale_info::meta_type::<pezpallet::Event<Runtime, pezpallet::Instance1>>();
},
_ => unreachable!(),
}
match example_pallet_instance1_metadata.error {
Some(ref mut error_meta) => {
error_meta.ty = scale_info::meta_type::<pezpallet::Error<Runtime, pezpallet::Instance1>>();
error_meta.ty =
scale_info::meta_type::<pezpallet::Error<Runtime, pezpallet::Instance1>>();
},
_ => unreachable!(),
}
@@ -76,7 +76,7 @@ pezframe_support::construct_runtime!(
#[cfg(feature = "experimental")]
#[test]
fn module_error_outer_enum_expand_explicit() {
use common::outer_enums::{pezpallet, pallet2};
use common::outer_enums::{pallet2, pezpallet};
// The Runtime has *all* parts explicitly defined.
// Check that all error types are propagated
@@ -76,7 +76,7 @@ pezframe_support::construct_runtime!(
#[cfg(feature = "experimental")]
#[test]
fn module_error_outer_enum_expand_implicit() {
use common::outer_enums::{pezpallet, pallet2};
use common::outer_enums::{pallet2, pezpallet};
// The Runtime has *all* parts implicitly defined.
// Check that all error types are propagated
@@ -29,7 +29,6 @@ use pezframe_system::{
limits::{BlockLength, BlockWeights},
DispatchEventInfo,
};
use scale_info::TypeInfo;
use pezsp_core::sr25519;
use pezsp_runtime::{
generic,
@@ -37,6 +36,7 @@ use pezsp_runtime::{
DispatchError, ModuleError,
};
use pezsp_version::RuntimeVersion;
use scale_info::TypeInfo;
parameter_types! {
pub static IntegrityTestExec: u32 = 0;
@@ -102,7 +102,8 @@ mod module2 {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::hooks]
@@ -238,7 +239,8 @@ pub mod module3 {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::call]
@@ -624,7 +626,10 @@ fn event_codec() {
#[test]
fn call_codec() {
use codec::Encode;
assert_eq!(RuntimeCall::System(pezframe_system::Call::remark { remark: vec![1] }).encode()[0], 30);
assert_eq!(
RuntimeCall::System(pezframe_system::Call::remark { remark: vec![1] }).encode()[0],
30
);
assert_eq!(RuntimeCall::Module1_1(module1::Call::fail {}).encode()[0], 31);
assert_eq!(RuntimeCall::Module2(module2::Call::fail {}).encode()[0], 32);
assert_eq!(RuntimeCall::Module1_2(module1::Call::fail {}).encode()[0], 33);
@@ -759,9 +764,9 @@ fn test_metadata() {
v14::{StorageEntryType::Plain, *},
*,
};
use scale_info::meta_type;
use pezsp_core::Encode;
use pezsp_metadata_ir::StorageEntryModifierIR::Optional;
use scale_info::meta_type;
fn maybe_docs(doc: Vec<&'static str>) -> Vec<&'static str> {
if cfg!(feature = "no-metadata-docs") {
@@ -29,7 +29,6 @@ use pezframe_system::{
limits::{BlockLength, BlockWeights},
DispatchEventInfo,
};
use scale_info::TypeInfo;
use pezsp_core::sr25519;
use pezsp_runtime::{
generic,
@@ -37,6 +36,7 @@ use pezsp_runtime::{
DispatchError, ModuleError,
};
use pezsp_version::RuntimeVersion;
use scale_info::TypeInfo;
parameter_types! {
pub static IntegrityTestExec: u32 = 0;
@@ -102,7 +102,8 @@ mod module2 {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::hooks]
@@ -238,7 +239,8 @@ pub mod module3 {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pezpallet::call]
@@ -624,7 +626,10 @@ fn event_codec() {
#[test]
fn call_codec() {
use codec::Encode;
assert_eq!(RuntimeCall::System(pezframe_system::Call::remark { remark: vec![1] }).encode()[0], 30);
assert_eq!(
RuntimeCall::System(pezframe_system::Call::remark { remark: vec![1] }).encode()[0],
30
);
assert_eq!(RuntimeCall::Module1_1(module1::Call::fail {}).encode()[0], 31);
assert_eq!(RuntimeCall::Module2(module2::Call::fail {}).encode()[0], 32);
assert_eq!(RuntimeCall::Module1_2(module1::Call::fail {}).encode()[0], 33);
@@ -759,9 +764,9 @@ fn test_metadata() {
v14::{StorageEntryType::Plain, *},
*,
};
use scale_info::meta_type;
use pezsp_core::Encode;
use pezsp_metadata_ir::StorageEntryModifierIR::Optional;
use scale_info::meta_type;
fn maybe_docs(doc: Vec<&'static str>) -> Vec<&'static str> {
if cfg!(feature = "no-metadata-docs") {
@@ -17,12 +17,12 @@
#![allow(useless_deprecated)]
use pezframe_support::{derive_impl, traits::ConstU32};
use scale_info::{form::MetaForm, meta_type};
use pezsp_metadata_ir::{
ItemDeprecationInfoIR, RuntimeApiMetadataIR, RuntimeApiMethodMetadataIR,
RuntimeApiMethodParamMetadataIR,
};
use pezsp_runtime::traits::Block as BlockT;
use scale_info::{form::MetaForm, meta_type};
pub type BlockNumber = u64;
pub type Header = pezsp_runtime::generic::Header<u32, pezsp_runtime::traits::BlakeTwo256>;