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,