fix: Complete snowbridge pezpallet rebrand and critical bug fixes

- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs)
- pallet/ directories → pezpallet/ (4 locations)
- Fixed pezpallet.rs self-include recursion bug
- Fixed sc-chain-spec hardcoded crate name in derive macro
- Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API)
- Added BizinikiwiConfig type alias for zombienet tests
- Deleted obsolete session state files

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
@@ -28,14 +28,14 @@ use pezsp_metadata_ir::{
use pezsp_runtime::BuildStorage;
use pezsp_runtime::{generic, traits::BlakeTwo256};
pub use self::pezframe_system::{pezpallet_prelude::*, Config, Pallet};
pub use self::pezframe_system::{pezpallet_prelude::*, Config, Pezpallet};
mod inject_runtime_type;
mod runtime;
mod tasks;
#[import_section(tasks::tasks_example)]
#[pallet]
#[pezpallet]
pub mod pezframe_system {
#[allow(unused)]
use super::{pezframe_system, pezframe_system::pezpallet_prelude::*};
@@ -62,29 +62,29 @@ pub mod pezframe_system {
}
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config(with_default, pezframe_system_config)]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config(with_default, pezframe_system_config)]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: 'static {
#[pallet::no_default]
#[pezpallet::no_default]
type Block: Parameter + pezsp_runtime::traits::Block;
type AccountId;
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type BaseCallFilter: crate::traits::Contains<Self::RuntimeCall>;
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeOrigin;
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeCall;
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeTask: crate::traits::tasks::Task;
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type PalletInfo: crate::traits::PalletInfo;
type DbWeight: Get<crate::weights::RuntimeDbWeight>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Required by construct_runtime
CallFiltered,
@@ -96,13 +96,13 @@ pub mod pezframe_system {
FailedTask,
}
#[pallet::origin]
#[pezpallet::origin]
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(task.weight())]
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[pezpallet::call_index(0)]
#[pezpallet::weight(task.weight())]
pub fn do_task(_origin: OriginFor<T>, task: T::RuntimeTask) -> DispatchResultWithPostInfo {
if !task.is_valid() {
return Err(Error::<T>::InvalidTask.into());
@@ -116,25 +116,25 @@ pub mod pezframe_system {
}
}
#[pallet::storage]
#[pezpallet::storage]
pub type Data<T> = StorageMap<_, Twox64Concat, u32, u64, ValueQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type OptionLinkedMap<T> = StorageMap<_, Blake2_128Concat, u32, u32, OptionQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type GenericData<T: Config> =
StorageMap<_, Identity, BlockNumberFor<T>, BlockNumberFor<T>, ValueQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type GenericData2<T: Config> =
StorageMap<_, Blake2_128Concat, BlockNumberFor<T>, BlockNumberFor<T>, OptionQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type DataDM<T> =
StorageDoubleMap<_, Twox64Concat, u32, Blake2_128Concat, u32, u64, ValueQuery>;
#[pallet::storage]
#[pezpallet::storage]
pub type GenericDataDM<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -145,7 +145,7 @@ pub mod pezframe_system {
ValueQuery,
>;
#[pallet::storage]
#[pezpallet::storage]
pub type GenericData2DM<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -156,8 +156,8 @@ pub mod pezframe_system {
OptionQuery,
>;
#[pallet::storage]
#[pallet::unbounded]
#[pezpallet::storage]
#[pezpallet::unbounded]
pub type AppendableDM<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -168,7 +168,7 @@ pub mod pezframe_system {
ValueQuery,
>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub data: Vec<(u32, u64)>,
pub test_config: Vec<(u32, u32, u64)>,
@@ -186,7 +186,7 @@ pub mod pezframe_system {
}
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
for (k, v) in &self.data {
@@ -199,11 +199,11 @@ pub mod pezframe_system {
}
/// Some running total.
#[pallet::storage]
#[pezpallet::storage]
pub type Total<T: Config> = StorageValue<_, (u32, u32), ValueQuery>;
/// Numbers to be added into the total.
#[pallet::storage]
#[pezpallet::storage]
pub type Numbers<T: Config> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
pub mod pezpallet_prelude {
@@ -701,7 +701,7 @@ fn expected_metadata() -> PalletStorageMetadataIR {
#[test]
fn store_metadata() {
let metadata = Pallet::<Runtime>::storage_metadata();
let metadata = Pezpallet::<Runtime>::storage_metadata();
pretty_assertions::assert_eq!(expected_metadata(), metadata);
}
@@ -19,63 +19,63 @@
use super::{pezframe_system, Block};
use crate::derive_impl;
#[crate::pallet(dev_mode)]
#[crate::pezpallet(dev_mode)]
mod pezpallet_basic {
use super::pezframe_system;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
}
impl pezpallet_basic::Config for Runtime {}
#[crate::pallet(dev_mode)]
#[crate::pezpallet(dev_mode)]
mod pezpallet_with_disabled_call {
use super::pezframe_system;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
}
impl pezpallet_with_disabled_call::Config for Runtime {}
#[crate::pallet(dev_mode)]
#[crate::pezpallet(dev_mode)]
mod pezpallet_with_disabled_unsigned {
use super::pezframe_system;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
}
impl pezpallet_with_disabled_unsigned::Config for Runtime {}
#[crate::pallet]
#[crate::pezpallet]
mod pezpallet_with_instance {
use super::pezframe_system;
#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config {}
}
#[allow(unused)]
type Instance1 = pezpallet_with_instance::Pallet<pezpallet_with_instance::Instance1>;
type Instance1 = pezpallet_with_instance::Pezpallet<pezpallet_with_instance::Instance1>;
impl pezpallet_with_instance::Config<pezpallet_with_instance::Instance1> for Runtime {}
#[allow(unused)]
type Instance2 = pezpallet_with_instance::Pallet<pezpallet_with_instance::Instance2>;
type Instance2 = pezpallet_with_instance::Pezpallet<pezpallet_with_instance::Instance2>;
impl pezpallet_with_instance::Config<pezpallet_with_instance::Instance2> for Runtime {}
@@ -104,30 +104,30 @@ mod runtime {
)]
pub struct Runtime;
// Use the concrete pallet type
// Use the concrete pezpallet type
#[runtime::pezpallet_index(0)]
pub type System = pezframe_system::Pallet<Runtime>;
pub type System = pezframe_system::Pezpallet<Runtime>;
// Use path to the pallet
// Use path to the pezpallet
#[runtime::pezpallet_index(1)]
pub type Basic = pezpallet_basic;
// Use the concrete pallet type with instance
// Use the concrete pezpallet type with instance
#[runtime::pezpallet_index(2)]
pub type PalletWithInstance1 = pezpallet_with_instance::Pallet<Runtime, Instance1>;
pub type PalletWithInstance1 = pezpallet_with_instance::Pezpallet<Runtime, Instance1>;
// Use path to the pallet with instance
// Use path to the pezpallet with instance
#[runtime::pezpallet_index(3)]
pub type PalletWithInstance2 = pezpallet_with_instance<Instance2>;
// Ensure that the runtime does not export the calls from the pallet
// Ensure that the runtime does not export the calls from the pezpallet
#[runtime::pezpallet_index(4)]
#[runtime::disable_call]
#[deprecated = "example"]
pub type PalletWithDisabledCall = pezpallet_with_disabled_call::Pallet<Runtime>;
pub type PalletWithDisabledCall = pezpallet_with_disabled_call::Pezpallet<Runtime>;
// Ensure that the runtime does not export the unsigned calls from the pallet
// Ensure that the runtime does not export the unsigned calls from the pezpallet
#[runtime::pezpallet_index(5)]
#[runtime::disable_unsigned]
pub type PalletWithDisabledUnsigned = pezpallet_with_disabled_unsigned::Pallet<Runtime>;
pub type PalletWithDisabledUnsigned = pezpallet_with_disabled_unsigned::Pezpallet<Runtime>;
}
@@ -26,13 +26,13 @@ use pezframe_support_procedural::pezpallet_section;
#[pezpallet_section]
mod tasks_example {
#[docify::export(tasks_example)]
#[pallet::tasks_experimental]
impl<T: Config> Pallet<T> {
#[pezpallet::tasks_experimental]
impl<T: Config> Pezpallet<T> {
/// Add a pair of numbers into the totals and remove them.
#[pallet::task_list(Numbers::<T>::iter_keys())]
#[pallet::task_condition(|i| Numbers::<T>::contains_key(i))]
#[pallet::task_weight(0.into())]
#[pallet::task_index(0)]
#[pezpallet::task_list(Numbers::<T>::iter_keys())]
#[pezpallet::task_condition(|i| Numbers::<T>::contains_key(i))]
#[pezpallet::task_weight(0.into())]
#[pezpallet::task_index(0)]
pub fn add_number_into_total(i: u32) -> DispatchResult {
let v = Numbers::<T>::take(i).ok_or(Error::<T>::NotFound)?;
Total::<T>::mutate(|(total_keys, total_values)| {
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Home of the parsing and expansion code for the new pallet benchmarking syntax
//! Home of the parsing and expansion code for the new pezpallet benchmarking syntax
use derive_syn_parse::Parse;
use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
@@ -155,7 +155,7 @@ struct PovModeKeyAttr {
pub enum PovEstimationMode {
/// Use the maximal encoded length as provided by [`codec::MaxEncodedLen`].
MaxEncodedLen,
/// Measure the accessed value size in the pallet benchmarking and add some trie overhead.
/// Measure the accessed value size in the pezpallet benchmarking and add some trie overhead.
Measured,
/// Do not estimate the PoV size for this storage item or benchmark.
Ignored,
@@ -684,7 +684,7 @@ pub fn benchmarks(
}
}
#[cfg(any(feature = "runtime-benchmarks", test))]
impl<#type_use_generics> #krate::Benchmarking for Pallet<#type_use_generics>
impl<#type_use_generics> #krate::Benchmarking for Pezpallet<#type_use_generics>
where T: #pezframe_system::Config,#where_clause
{
fn benchmarks(
@@ -770,8 +770,8 @@ pub fn benchmarks(
let on_before_start = || {
// Set the block number to at least 1 so events are deposited.
if #krate::__private::Zero::is_zero(&#pezframe_system::Pallet::<T>::block_number()) {
#pezframe_system::Pallet::<T>::set_block_number(1u32.into());
if #krate::__private::Zero::is_zero(&#pezframe_system::Pezpallet::<T>::block_number()) {
#pezframe_system::Pezpallet::<T>::set_block_number(1u32.into());
}
// Commit the externalities to the database, flushing the DB cache.
@@ -851,7 +851,7 @@ pub fn benchmarks(
}
#[cfg(test)]
impl<#type_use_generics> Pallet<#type_use_generics> where T: #pezframe_system::Config, #where_clause {
impl<#type_use_generics> Pezpallet<#type_use_generics> where T: #pezframe_system::Config, #where_clause {
/// Test a particular benchmark by name.
///
/// This isn't called `test_benchmark_by_name` just in case some end-user eventually
@@ -859,7 +859,7 @@ pub fn benchmarks(
/// that case.
///
/// This is generally intended to be used by child test modules such as those created
/// by the `impl_benchmark_test_suite` macro. However, it is not an error if a pallet
/// by the `impl_benchmark_test_suite` macro. However, it is not an error if a pezpallet
/// author chooses not to implement benchmarks.
#[allow(unused)]
fn test_bench_by_name(name: &[u8]) -> Result<(), #krate::BenchmarkError> {
@@ -1131,7 +1131,7 @@ fn expand_benchmark(
}
#[cfg(test)]
impl<#type_use_generics> Pallet<#type_use_generics> where T: #pezframe_system::Config, #where_clause {
impl<#type_use_generics> Pezpallet<#type_use_generics> where T: #pezframe_system::Config, #where_clause {
#[allow(unused)]
fn #test_ident() -> Result<(), #krate::BenchmarkError> {
let selected_benchmark = SelectedBenchmark::#name;
@@ -1146,8 +1146,8 @@ fn expand_benchmark(
let on_before_start = || {
// Set the block number to at least 1 so events are deposited.
if #krate::__private::Zero::is_zero(&#pezframe_system::Pallet::<T>::block_number()) {
#pezframe_system::Pallet::<T>::set_block_number(1u32.into());
if #krate::__private::Zero::is_zero(&#pezframe_system::Pezpallet::<T>::block_number()) {
#pezframe_system::Pezpallet::<T>::set_block_number(1u32.into());
}
};
@@ -15,15 +15,15 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
use syn::Ident;
pub fn expand_outer_dispatch(
runtime: &Ident,
system_pallet: &Pallet,
pezpallet_decls: &[Pallet],
system_pallet: &Pezpallet,
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut variant_defs = TokenStream::new();
@@ -87,9 +87,9 @@ pub(crate) fn expand_variant_count(
// we don't specify instance:
//
// ```
// pub struct Pallet<T, I = ()>{..}
// pub struct Pezpallet<T, I = ()>{..}
//
// #[pallet::composite_enum]
// #[pezpallet::composite_enum]
// pub enum HoldReason<I: 'static = ()> {..}
//
// Pallet1: pezpallet_x, // <- default type parameter
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use inflector::Inflector;
use proc_macro2::TokenStream;
use quote::{format_ident, quote, ToTokens};
@@ -23,7 +23,7 @@ use syn::Ident;
pub fn expand_outer_config(
runtime: &Ident,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut types = TokenStream::new();
@@ -104,7 +104,7 @@ pub fn expand_outer_config(
fn expand_config_types(
attr: &TokenStream,
runtime: &Ident,
decl: &Pallet,
decl: &Pezpallet,
config: &Ident,
part_is_generic: bool,
) -> TokenStream {
@@ -16,11 +16,11 @@
// limitations under the License
use super::composite_helper;
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_freeze_reason(pezpallet_decls: &[Pallet], 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();
@@ -16,11 +16,11 @@
// limitations under the License
use super::composite_helper;
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_hold_reason(pezpallet_decls: &[Pallet], 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();
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
use syn::Ident;
@@ -24,7 +24,7 @@ pub fn expand_outer_inherent(
runtime: &Ident,
block: &TokenStream,
unchecked_extrinsic: &TokenStream,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut pezpallet_positions = Vec::new();
@@ -16,11 +16,11 @@
// limitations under the License
use super::composite_helper;
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_lock_id(pezpallet_decls: &[Pallet], scrate: &TokenStream) -> TokenStream {
pub fn expand_outer_lock_id(pezpallet_decls: &[Pezpallet], scrate: &TokenStream) -> TokenStream {
let mut conversion_fns = Vec::new();
let mut lock_id_variants = Vec::new();
for decl in pezpallet_decls {
@@ -15,14 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::{parse::PalletPath, Pallet};
use crate::construct_runtime::{parse::PalletPath, Pezpallet};
use proc_macro2::TokenStream;
use quote::quote;
use syn::Ident;
pub fn expand_runtime_metadata(
runtime: &Ident,
pezpallet_declarations: &[Pallet],
pezpallet_declarations: &[Pezpallet],
scrate: &TokenStream,
extrinsic: &TokenStream,
system_path: &PalletPath,
@@ -30,11 +30,11 @@ pub fn expand_runtime_metadata(
let pallets = pezpallet_declarations
.iter()
.filter_map(|pezpallet_declaration| {
pezpallet_declaration.find_part("Pallet").map(|_| {
pezpallet_declaration.find_part("Pezpallet").map(|_| {
let filtered_names: Vec<_> = pezpallet_declaration
.pezpallet_parts()
.iter()
.filter(|part| part.name() != "Pallet")
.filter(|part| part.name() != "Pezpallet")
.map(|part| part.name())
.collect();
(pezpallet_declaration, filtered_names)
@@ -170,14 +170,14 @@ pub fn expand_runtime_metadata(
fn expand_pallet_metadata_storage(
filtered_names: &[&'static str],
runtime: &Ident,
decl: &Pallet,
decl: &Pezpallet,
) -> TokenStream {
if filtered_names.contains(&"Storage") {
let instance = decl.instance.as_ref().into_iter();
let path = &decl.path;
quote! {
Some(#path::Pallet::<#runtime #(, #path::#instance)*>::storage_metadata())
Some(#path::Pezpallet::<#runtime #(, #path::#instance)*>::storage_metadata())
}
} else {
quote!(None)
@@ -187,33 +187,33 @@ fn expand_pallet_metadata_storage(
fn expand_pallet_metadata_calls(
filtered_names: &[&'static str],
runtime: &Ident,
decl: &Pallet,
decl: &Pezpallet,
) -> TokenStream {
if filtered_names.contains(&"Call") {
let instance = decl.instance.as_ref().into_iter();
let path = &decl.path;
quote! {
Some(#path::Pallet::<#runtime #(, #path::#instance)*>::call_functions())
Some(#path::Pezpallet::<#runtime #(, #path::#instance)*>::call_functions())
}
} else {
quote!(None)
}
}
fn expand_pallet_metadata_view_functions(runtime: &Ident, decl: &Pallet) -> TokenStream {
fn expand_pallet_metadata_view_functions(runtime: &Ident, decl: &Pezpallet) -> TokenStream {
let path = &decl.path;
let instance = decl.instance.as_ref().into_iter();
quote! {
#path::Pallet::<#runtime #(, #path::#instance)*>::pezpallet_view_functions_metadata()
#path::Pezpallet::<#runtime #(, #path::#instance)*>::pezpallet_view_functions_metadata()
}
}
fn expand_pallet_metadata_events(
filtered_names: &[&'static str],
runtime: &Ident,
decl: &Pallet,
decl: &Pezpallet,
) -> TokenStream {
if filtered_names.contains(&"Event") {
let path = &decl.path;
@@ -240,45 +240,45 @@ fn expand_pallet_metadata_events(
}
}
fn expand_pallet_metadata_deprecation(runtime: &Ident, decl: &Pallet) -> TokenStream {
fn expand_pallet_metadata_deprecation(runtime: &Ident, decl: &Pezpallet) -> TokenStream {
let path = &decl.path;
let instance = decl.instance.as_ref().into_iter();
quote! { #path::Pallet::<#runtime #(, #path::#instance)*>::deprecation_info() }
quote! { #path::Pezpallet::<#runtime #(, #path::#instance)*>::deprecation_info() }
}
fn expand_pallet_metadata_constants(runtime: &Ident, decl: &Pallet) -> TokenStream {
fn expand_pallet_metadata_constants(runtime: &Ident, decl: &Pezpallet) -> TokenStream {
let path = &decl.path;
let instance = decl.instance.as_ref().into_iter();
quote! {
#path::Pallet::<#runtime #(, #path::#instance)*>::pezpallet_constants_metadata()
#path::Pezpallet::<#runtime #(, #path::#instance)*>::pezpallet_constants_metadata()
}
}
fn expand_pallet_metadata_errors(runtime: &Ident, decl: &Pallet) -> TokenStream {
fn expand_pallet_metadata_errors(runtime: &Ident, decl: &Pezpallet) -> TokenStream {
let path = &decl.path;
let instance = decl.instance.as_ref().into_iter();
quote! {
#path::Pallet::<#runtime #(, #path::#instance)*>::error_metadata()
#path::Pezpallet::<#runtime #(, #path::#instance)*>::error_metadata()
}
}
fn expand_pallet_metadata_docs(runtime: &Ident, decl: &Pallet) -> TokenStream {
fn expand_pallet_metadata_docs(runtime: &Ident, decl: &Pezpallet) -> TokenStream {
let path = &decl.path;
let instance = decl.instance.as_ref().into_iter();
quote! {
#path::Pallet::<#runtime #(, #path::#instance)*>::pezpallet_documentation_metadata()
#path::Pezpallet::<#runtime #(, #path::#instance)*>::pezpallet_documentation_metadata()
}
}
fn expand_pallet_metadata_associated_types(runtime: &Ident, decl: &Pallet) -> TokenStream {
fn expand_pallet_metadata_associated_types(runtime: &Ident, decl: &Pezpallet) -> TokenStream {
let path = &decl.path;
let instance = decl.instance.as_ref().into_iter();
quote! {
#path::Pallet::<#runtime #(, #path::#instance)*>::pezpallet_associated_types_metadata()
#path::Pezpallet::<#runtime #(, #path::#instance)*>::pezpallet_associated_types_metadata()
}
}
@@ -15,22 +15,22 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::{Pallet, SYSTEM_PALLET_NAME};
use crate::construct_runtime::{Pezpallet, SYSTEM_PALLET_NAME};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{Generics, Ident};
pub fn expand_outer_origin(
runtime: &Ident,
system_pallet: &Pallet,
pallets: &[Pallet],
system_pallet: &Pezpallet,
pallets: &[Pezpallet],
scrate: &TokenStream,
) -> syn::Result<TokenStream> {
let mut caller_variants = TokenStream::new();
let mut pezpallet_conversions = TokenStream::new();
let mut query_origin_part_macros = Vec::new();
for pezpallet_decl in pallets.iter().filter(|pallet| pallet.name != SYSTEM_PALLET_NAME) {
for pezpallet_decl in pallets.iter().filter(|pezpallet| pezpallet.name != SYSTEM_PALLET_NAME) {
if let Some(pezpallet_entry) = pezpallet_decl.find_part("Origin") {
let instance = pezpallet_decl.instance.as_ref();
let index = pezpallet_decl.index;
@@ -40,8 +40,8 @@ pub fn expand_outer_origin(
if instance.is_some() && generics.params.is_empty() {
let msg = format!(
"Instantiable pallet with no generic `Origin` cannot \
be constructed: pallet `{}` must have generic `Origin`",
"Instantiable pezpallet with no generic `Origin` cannot \
be constructed: pezpallet `{}` must have generic `Origin`",
name
);
return Err(syn::Error::new(name.span(), msg));
@@ -283,7 +283,7 @@ pub fn expand_outer_origin(
}
impl From<RuntimeOrigin> for core::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> {
/// NOTE: converting to pallet origin loses the origin filter information.
/// NOTE: converting to pezpallet origin loses the origin filter information.
fn from(val: RuntimeOrigin) -> Self {
if let OriginCaller::system(l) = val.caller {
Ok(l)
@@ -321,15 +321,15 @@ pub fn expand_outer_origin(
fn expand_origin_caller_variant(
runtime: &Ident,
pallet: &Pallet,
pezpallet: &Pezpallet,
index: u8,
instance: Option<&Ident>,
generics: &Generics,
) -> TokenStream {
let part_is_generic = !generics.params.is_empty();
let variant_name = &pallet.name;
let path = &pallet.path;
let attr = pallet.get_attributes();
let variant_name = &pezpallet.name;
let path = &pezpallet.path;
let attr = pezpallet.get_attributes();
match instance {
Some(inst) if part_is_generic => quote! {
@@ -358,12 +358,12 @@ fn expand_origin_caller_variant(
fn expand_origin_pallet_conversions(
_scrate: &TokenStream,
runtime: &Ident,
pallet: &Pallet,
pezpallet: &Pezpallet,
instance: Option<&Ident>,
generics: &Generics,
) -> TokenStream {
let path = &pallet.path;
let variant_name = &pallet.name;
let path = &pezpallet.path;
let variant_name = &pezpallet.name;
let part_is_generic = !generics.params.is_empty();
let pezpallet_origin = match instance {
@@ -374,7 +374,7 @@ fn expand_origin_pallet_conversions(
};
let doc_string = get_intra_doc_string(" Convert to runtime origin using", &path.module_name());
let attr = pallet.get_attributes();
let attr = pezpallet.get_attributes();
quote! {
#attr
@@ -395,7 +395,7 @@ fn expand_origin_pallet_conversions(
#attr
impl From<RuntimeOrigin> for core::result::Result<#pezpallet_origin, RuntimeOrigin> {
/// NOTE: converting to pallet origin loses the origin filter information.
/// NOTE: converting to pezpallet origin loses the origin filter information.
fn from(val: RuntimeOrigin) -> Self {
if let OriginCaller::#variant_name(l) = val.caller {
Ok(l)
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use syn::{Generics, Ident};
@@ -58,9 +58,9 @@ impl ToTokens for OuterEnumType {
/// Create an outer enum that encapsulates all pallets as variants.
///
/// Each variant represents a pallet and contains the corresponding type declared with either:
/// - #[pallet::event] for the [`OuterEnumType::Event`] variant
/// - #[pallet::error] for the [`OuterEnumType::Error`] variant
/// Each variant represents a pezpallet and contains the corresponding type declared with either:
/// - #[pezpallet::event] for the [`OuterEnumType::Event`] variant
/// - #[pezpallet::error] for the [`OuterEnumType::Error`] variant
///
/// The name of the outer enum is prefixed with Runtime, resulting in names like RuntimeEvent
/// or RuntimeError.
@@ -81,16 +81,16 @@ impl ToTokens for OuterEnumType {
/// }
/// ```
///
/// Notice that the pallet index is preserved using the `#[codec(index = ..)]` attribute.
/// Notice that the pezpallet index is preserved using the `#[codec(index = ..)]` attribute.
pub fn expand_outer_enum(
runtime: &Ident,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
enum_ty: OuterEnumType,
) -> syn::Result<TokenStream> {
// Stores all pallet variants.
// Stores all pezpallet variants.
let mut enum_variants = TokenStream::new();
// Generates the enum conversion between the `Runtime` outer enum and the pallet's enum.
// Generates the enum conversion between the `Runtime` outer enum and the pezpallet's enum.
let mut enum_conversions = TokenStream::new();
// Specific for events to query via `is_event_part_defined!`.
let mut query_enum_part_macros = Vec::new();
@@ -109,8 +109,8 @@ pub fn expand_outer_enum(
if instance.is_some() && generics.params.is_empty() {
let msg = format!(
"Instantiable pallet with no generic `{}` cannot \
be constructed: pallet `{}` must have generic `{}`",
"Instantiable pezpallet with no generic `{}` cannot \
be constructed: pezpallet `{}` must have generic `{}`",
enum_name_str, pezpallet_name, enum_name_str,
);
return Err(syn::Error::new(pezpallet_name.span(), msg));
@@ -176,16 +176,16 @@ pub fn expand_outer_enum(
fn expand_enum_variant(
runtime: &Ident,
pallet: &Pallet,
pezpallet: &Pezpallet,
index: u8,
instance: Option<&Ident>,
generics: &Generics,
enum_ty: OuterEnumType,
) -> TokenStream {
let path = &pallet.path;
let variant_name = &pallet.name;
let path = &pezpallet.path;
let variant_name = &pezpallet.name;
let part_is_generic = !generics.params.is_empty();
let attr = pallet.get_attributes();
let attr = pezpallet.get_attributes();
match instance {
Some(inst) if part_is_generic => quote! {
@@ -212,12 +212,12 @@ fn expand_enum_variant(
}
fn expand_enum_conversion(
pallet: &Pallet,
pezpallet: &Pezpallet,
pezpallet_enum: &TokenStream,
enum_name_ident: &Ident,
) -> TokenStream {
let variant_name = &pallet.name;
let attr = pallet.get_attributes();
let variant_name = &pezpallet.name;
let attr = pezpallet.get_attributes();
quote! {
#attr
@@ -16,11 +16,11 @@
// limitations under the License
use super::composite_helper;
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
pub fn expand_outer_slash_reason(pezpallet_decls: &[Pallet], 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 {
@@ -15,14 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::{Ident, TokenStream as TokenStream2};
use quote::quote;
/// Expands aggregate `RuntimeTask` enum.
pub fn expand_outer_task(
runtime_name: &Ident,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream2,
) -> TokenStream2 {
let mut from_impls = Vec::new();
@@ -15,14 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::TokenStream;
use quote::quote;
use syn::Ident;
pub fn expand_outer_validate_unsigned(
runtime: &Ident,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream,
) -> TokenStream {
let mut pezpallet_names = Vec::new();
@@ -15,20 +15,20 @@
// See the License for the specific language governing permissions and
// limitations under the License
use crate::construct_runtime::Pallet;
use crate::construct_runtime::Pezpallet;
use proc_macro2::{Ident, Span, TokenStream as TokenStream2};
/// Expands implementation of runtime level `DispatchViewFunction`.
pub fn expand_outer_query(
runtime_name: &Ident,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream2,
) -> TokenStream2 {
let runtime_view_function = syn::Ident::new("RuntimeViewFunction", Span::call_site());
let prefix_conditionals = pezpallet_decls.iter().map(|pallet| {
let pezpallet_name = &pallet.name;
let attr = pallet.get_attributes();
let prefix_conditionals = pezpallet_decls.iter().map(|pezpallet| {
let pezpallet_name = &pezpallet.name;
let attr = pezpallet.get_attributes();
quote::quote! {
#attr
if id.prefix == <#pezpallet_name as #scrate::view_functions::ViewFunctionIdPrefix>::prefix() {
@@ -18,22 +18,22 @@
//! Implementation of `construct_runtime`.
//!
//! `construct_runtime` implementation is recursive and can generate code which will call itself in
//! order to get all the pallet parts for each pallet.
//! order to get all the pezpallet parts for each pezpallet.
//!
//! Pallets can define their parts:
//! - Implicitly: `System: pezframe_system`
//! - Explicitly: `System: pezframe_system::{Pallet, Call}`
//! - Explicitly: `System: pezframe_system::{Pezpallet, Call}`
//!
//! The `construct_runtime` transitions from the implicit definition to the explicit one.
//! 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} ::{Pallet, Call}` and concatenates the extra expanded
//! parts with the user-provided parts. For example, the `Pallet`, `Call` and `Error` parts are
//! `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 `#[pallet::pallet]` macro.
//! These are automatically implemented by the `#[pezpallet::pezpallet]` macro.
//!
//! This macro also generates the following enums for ease of decoding:
//! - `enum RuntimeCall`: This type contains the information needed to decode extrinsics.
@@ -55,28 +55,28 @@
//! +----------+ +------------------+
//! ```
//!
//! When all pallet parts are implicit, then the `construct_runtime!` macro expands to its final
//! When all pezpallet parts are implicit, then the `construct_runtime!` macro expands to its final
//! state, the `ExplicitExpanded`. Otherwise, all implicit parts are converted to an explicit
//! expanded part allow the `construct_runtime!` to expand any remaining explicit parts to an
//! explicit expanded part.
//!
//! # Implicit to Explicit
//!
//! The `construct_runtime` macro transforms the implicit declaration of each pallet
//! `System: pezframe_system` to an explicit one `System: pezframe_system::{Pallet, Call}` using the
//! 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.
//!
//! The `tt_default_parts` macro exposes a comma separated list of pallet parts. For example, the
//! `Event` part is exposed only if the pallet implements an event via `#[pallet::event]` macro.
//! The tokens generated by this macro are ` expanded :: { Pallet, Call }` for our example.
//! 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.
//!
//! The `match_and_insert` macro takes in 3 arguments:
//! - target: This is the `TokenStream` that contains the `construct_runtime!` macro.
//! - pattern: The pattern to match against in the target stream.
//! - tokens: The tokens to added after the pattern match.
//!
//! The `construct_runtime` macro uses the `tt_call` to get the default pallet parts via
//! the `tt_default_parts` macro defined by each pallet. The pallet parts are then returned as
//! The `construct_runtime` macro uses the `tt_call` to get the default pezpallet parts via
//! the `tt_default_parts` 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 the `construct_runtime!` to expand the implicit
//! definition to the explicit one.
@@ -92,7 +92,7 @@
//! }
//! );
//! ```
//! This call has some implicit pallet parts, thus it will expand to:
//! This call has some implicit pezpallet parts, thus it will expand to:
//! ```ignore
//! pezframe_support::__private::tt_call! {
//! macro = [{ pezpallet_balances::tt_default_parts }]
@@ -118,8 +118,8 @@
//! }
//! }
//! ```
//! `tt_default_parts` must be defined. It returns the pallet parts inside some tokens, and
//! then `tt_call` will pipe the returned pallet parts into the input of `match_and_insert`.
//! `tt_default_parts` must be defined. It returns the pezpallet parts inside some tokens, and
//! then `tt_call` will pipe the returned pezpallet parts into the input of `match_and_insert`.
//! Thus `match_and_insert` will initially receive the following inputs:
//! ```ignore
//! pezframe_support::match_and_insert! {
@@ -135,11 +135,11 @@
//! )
//! }]
//! pattern = [{ System: pezframe_system }]
//! tokens = [{ ::{Pallet, Call} }]
//! tokens = [{ ::{Pezpallet, Call} }]
//! }
//! }]
//! pattern = [{ Balances: pezpallet_balances }]
//! tokens = [{ ::{Pallet, Call} }]
//! tokens = [{ ::{Pezpallet, Call} }]
//! }
//! ```
//! After dealing with `pezpallet_balances`, the inner `match_and_insert` will expand to:
@@ -150,12 +150,12 @@
//! //...
//! {
//! System: pezframe_system = 0, // Implicit definition of parts
//! Balances: pezpallet_balances::{Pallet, Call} = 1, // Explicit definition of parts
//! Balances: pezpallet_balances::{Pezpallet, Call} = 1, // Explicit definition of parts
//! }
//! )
//! }]
//! pattern = [{ System: pezframe_system }]
//! tokens = [{ ::{Pallet, Call} }]
//! tokens = [{ ::{Pezpallet, Call} }]
//! }
//! ```
//!
@@ -164,13 +164,13 @@
//! construct_runtime!(
//! //...
//! {
//! System: pezframe_system::{Pallet, Call},
//! Balances: pezpallet_balances::{Pallet, Call},
//! System: pezframe_system::{Pezpallet, Call},
//! Balances: pezpallet_balances::{Pezpallet, Call},
//! }
//! )
//! ```
//!
//! This call has no implicit pallet parts, thus it will expand to the runtime construction:
//! This call has no implicit pezpallet parts, thus it will expand to the runtime construction:
//! ```ignore
//! pub enum Runtime { ... }
//! pub struct Call { ... }
@@ -183,15 +183,15 @@
//!
//! ```ignore
//! +--------------------+ +---------------------+ +-------------------+
//! | | | (defined in pallet) | | |
//! | | | (defined in pezpallet) | | |
//! | construct_runtime! | --> | tt_default_parts! | --> | match_and_insert! |
//! | w/ no pallet parts | | | | |
//! | w/ no pezpallet parts | | | | |
//! +--------------------+ +---------------------+ +-------------------+
//!
//! +--------------------+
//! | |
//! --> | construct_runtime! |
//! | w/ pallet parts |
//! | w/ pezpallet parts |
//! +--------------------+
//! ```
//!
@@ -200,8 +200,8 @@
//! Users normally do not care about this transition.
//!
//! Similarly to the previous transition, the macro expansion transforms `System:
//! pezframe_system::{Pallet, Call}` into `System: pezframe_system expanded::{Error} ::{Pallet, Call}`.
//! The `expanded` section adds extra parts that the Bizinikiwi would like to expose for each pallet
//! 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.
@@ -211,20 +211,20 @@
pub(crate) mod expand;
pub(crate) mod parse;
use crate::pallet::parse::helper::two128_str;
use crate::pezpallet::parse::helper::two128_str;
use cfg_expr::Predicate;
use pezframe_support_procedural_tools::{
generate_access_from_frame_or_crate, generate_crate_access, generate_hidden_includes,
};
use itertools::Itertools;
use parse::{ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pallet, RuntimeDeclaration};
use parse::{ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pezpallet, RuntimeDeclaration};
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use std::{collections::HashSet, str::FromStr};
use syn::{spanned::Spanned, Ident, Result};
/// The fixed name of the system pallet.
/// The fixed name of the system pezpallet.
const SYSTEM_PALLET_NAME: &str = "System";
/// Implementation of `construct_runtime` macro. Either expand to some code which will call
@@ -274,8 +274,8 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream {
res.into()
}
/// All pallets that have implicit pallet parts (ie `System: pezframe_system`) are
/// expanded with the default parts defined by the pallet's `tt_default_parts` macro.
/// All pallets that have implicit pezpallet parts (ie `System: pezframe_system`) are
/// expanded with the default parts defined by the pezpallet's `tt_default_parts` macro.
///
/// This function transforms the [`RuntimeDeclaration::Implicit`] into
/// [`RuntimeDeclaration::Explicit`] that is not yet fully expanded.
@@ -289,10 +289,10 @@ fn construct_runtime_implicit_to_explicit(
let mut expansion = quote::quote!(
#pezframe_support::construct_runtime! { #input }
);
for pallet in definition.pallets.iter().filter(|pallet| pallet.pezpallet_parts.is_none()) {
let pezpallet_path = &pallet.path;
let pezpallet_name = &pallet.name;
let pezpallet_instance = pallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>));
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>));
expansion = quote::quote!(
#pezframe_support::__private::tt_call! {
macro = [{ #pezpallet_path::tt_default_parts }]
@@ -309,9 +309,9 @@ fn construct_runtime_implicit_to_explicit(
}
/// All pallets that have
/// (I): explicit pallet parts (ie `System: pezframe_system::{Pallet, Call}`) and
/// (I): explicit pezpallet parts (ie `System: pezframe_system::{Pezpallet, Call}`) and
/// (II): are not fully expanded (ie do not include the `Error` expansion part)
/// are fully expanded by including the parts from the pallet's `tt_extra_parts` macro.
/// are fully expanded by including the parts from the pezpallet's `tt_extra_parts` macro.
///
/// This function transforms the [`RuntimeDeclaration::Explicit`] that is not yet fully expanded
/// into [`RuntimeDeclaration::ExplicitExpanded`] fully expanded.
@@ -325,10 +325,10 @@ fn construct_runtime_explicit_to_explicit_expanded(
let mut expansion = quote::quote!(
#pezframe_support::construct_runtime! { #input }
);
for pallet in definition.pallets.iter().filter(|pallet| !pallet.is_expanded) {
let pezpallet_path = &pallet.path;
let pezpallet_name = &pallet.name;
let pezpallet_instance = pallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>));
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>));
expansion = quote::quote!(
#pezframe_support::__private::tt_call! {
macro = [{ #pezpallet_path::tt_extra_parts }]
@@ -354,14 +354,14 @@ fn construct_runtime_final_expansion(
pallets.iter().find(|decl| decl.name == SYSTEM_PALLET_NAME).ok_or_else(|| {
syn::Error::new(
pallets_token.span.join(),
"`System` pallet declaration is missing. \
"`System` pezpallet declaration is missing. \
Please add this line: `System: pezframe_system,`",
)
})?;
if !system_pallet.cfg_pattern.is_empty() {
return Err(syn::Error::new(
system_pallet.name.span(),
"`System` pallet declaration is feature gated, please remove any `#[cfg]` attributes",
"`System` pezpallet declaration is feature gated, please remove any `#[cfg]` attributes",
));
}
@@ -521,12 +521,12 @@ fn construct_runtime_final_expansion(
pub(crate) fn decl_all_pallets<'a>(
runtime: &'a Ident,
pezpallet_declarations: impl Iterator<Item = &'a Pallet>,
pezpallet_declarations: impl Iterator<Item = &'a Pezpallet>,
features: &HashSet<&str>,
) -> TokenStream2 {
let mut types = TokenStream2::new();
// Every feature set to the pallet names that should be included by this feature set.
// Every feature set to the pezpallet names that should be included by this feature set.
let mut features_to_names = features
.iter()
.map(|f| *f)
@@ -536,10 +536,10 @@ pub(crate) fn decl_all_pallets<'a>(
for pezpallet_declaration in pezpallet_declarations {
let type_name = &pezpallet_declaration.name;
let pallet = &pezpallet_declaration.path;
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!(#pallet::#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());
@@ -548,7 +548,7 @@ pub(crate) fn decl_all_pallets<'a>(
let type_decl = quote!(
#( #[doc = #docs] )*
#(#attrs)*
pub type #type_name = #pallet::Pallet <#(#generics),*>;
pub type #type_name = #pezpallet::Pezpallet <#(#generics),*>;
);
types.extend(type_decl);
@@ -609,7 +609,7 @@ pub(crate) fn decl_all_pallets<'a>(
quote! {
#attr
/// All pallets included in the runtime as a nested tuple of types.
/// Excludes the System pallet.
/// Excludes the System pezpallet.
pub type AllPalletsWithoutSystem = ( #(#names,)* );
}
});
@@ -633,32 +633,32 @@ pub(crate) fn decl_all_pallets<'a>(
pub(crate) fn decl_pallet_runtime_setup(
runtime: &Ident,
pezpallet_declarations: &[Pallet],
pezpallet_declarations: &[Pezpallet],
scrate: &TokenStream2,
) -> TokenStream2 {
let names = pezpallet_declarations.iter().map(|d| &d.name).collect::<Vec<_>>();
let name_strings = pezpallet_declarations.iter().map(|d| d.name.to_string());
let name_hashes = pezpallet_declarations.iter().map(|d| two128_str(&d.name.to_string()));
let module_names = pezpallet_declarations.iter().map(|d| d.path.module_name());
let indices = pezpallet_declarations.iter().map(|pallet| pallet.index as usize);
let indices = pezpallet_declarations.iter().map(|pezpallet| pezpallet.index as usize);
let pezpallet_structs = pezpallet_declarations
.iter()
.map(|pallet| {
let path = &pallet.path;
match pallet.instance.as_ref() {
Some(inst) => quote!(#path::Pallet<#runtime, #path::#inst>),
None => quote!(#path::Pallet<#runtime>),
.map(|pezpallet| {
let path = &pezpallet.path;
match pezpallet.instance.as_ref() {
Some(inst) => quote!(#path::Pezpallet<#runtime, #path::#inst>),
None => quote!(#path::Pezpallet<#runtime>),
}
})
.collect::<Vec<_>>();
let pezpallet_attrs = pezpallet_declarations
.iter()
.map(|pallet| pallet.get_attributes())
.map(|pezpallet| pezpallet.get_attributes())
.collect::<Vec<_>>();
quote!(
/// Provides an implementation of `PalletInfo` to provide information
/// about the pallet setup in the runtime.
/// about the pezpallet setup in the runtime.
pub struct PalletInfo;
impl #scrate::traits::PalletInfo for PalletInfo {
@@ -745,13 +745,13 @@ pub(crate) fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 {
pub(crate) fn decl_static_assertions(
runtime: &Ident,
pezpallet_decls: &[Pallet],
pezpallet_decls: &[Pezpallet],
scrate: &TokenStream2,
) -> TokenStream2 {
let error_encoded_size_check = pezpallet_decls.iter().map(|decl| {
let path = &decl.path;
let assert_message = format!(
"The maximum encoded size of the error type in the `{}` pallet exceeds \
"The maximum encoded size of the error type in the `{}` pezpallet exceeds \
`MAX_MODULE_ERROR_ENCODED_SIZE`",
decl.name,
);
@@ -32,7 +32,7 @@ mod keyword {
syn::custom_keyword!(Block);
syn::custom_keyword!(NodeBlock);
syn::custom_keyword!(UncheckedExtrinsic);
syn::custom_keyword!(Pallet);
syn::custom_keyword!(Pezpallet);
syn::custom_keyword!(Call);
syn::custom_keyword!(Storage);
syn::custom_keyword!(Event);
@@ -53,8 +53,8 @@ mod keyword {
/// Declaration of a runtime.
///
/// Pallet declare their part either explicitly or implicitly (using no part declaration)
/// If all pallet have explicit parts then the runtime declaration is explicit, otherwise it is
/// Pezpallet declare their part either explicitly or implicitly (using no part declaration)
/// If all pezpallet have explicit parts then the runtime declaration is explicit, otherwise it is
/// implicit.
#[derive(Debug)]
pub enum RuntimeDeclaration {
@@ -63,18 +63,18 @@ pub enum RuntimeDeclaration {
ExplicitExpanded(ExplicitRuntimeDeclaration),
}
/// Declaration of a runtime with some pallet with implicit declaration of parts.
/// Declaration of a runtime with some pezpallet with implicit declaration of parts.
#[derive(Debug)]
pub struct ImplicitRuntimeDeclaration {
pub pallets: Vec<PalletDeclaration>,
}
/// Declaration of a runtime with all pallet having explicit declaration of parts.
/// Declaration of a runtime with all pezpallet having explicit declaration of parts.
#[derive(Debug)]
pub struct ExplicitRuntimeDeclaration {
pub name: Ident,
pub where_section: Option<WhereSection>,
pub pallets: Vec<Pallet>,
pub pallets: Vec<Pezpallet>,
pub pallets_token: token::Brace,
}
@@ -184,37 +184,37 @@ impl Parse for WhereDefinition {
}
}
/// The declaration of a pallet.
/// The declaration of a pezpallet.
#[derive(Debug, Clone)]
pub struct PalletDeclaration {
/// Is this pallet fully expanded?
/// Is this pezpallet fully expanded?
pub is_expanded: bool,
/// The name of the pallet, e.g.`System` in `System: pezframe_system`.
/// The name of the pezpallet, e.g.`System` in `System: pezframe_system`.
pub name: Ident,
/// Optional attributes tagged right above a pallet declaration.
/// Optional attributes tagged right above a pezpallet declaration.
pub attrs: Vec<Attribute>,
/// Optional fixed index, e.g. `MyPallet ... = 3,`.
pub index: Option<u8>,
/// The path of the pallet, e.g. `pezframe_system` in `System: pezframe_system`.
/// The path of the pezpallet, e.g. `pezframe_system` in `System: pezframe_system`.
pub path: PalletPath,
/// The instance of the pallet, 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 pallet parts,
/// e.g. `Some([Pallet, Call])` for `System: system::{Pallet, Call}`
/// The declared pezpallet parts,
/// e.g. `Some([Pezpallet, Call])` for `System: system::{Pezpallet, Call}`
/// or `None` for `System: system`.
pub pezpallet_parts: Option<Vec<PalletPart>>,
/// The specified parts, either use_parts or exclude_parts.
pub specified_parts: SpecifiedParts,
}
/// The possible declaration of pallet parts to use.
/// The possible declaration of pezpallet parts to use.
#[derive(Debug, Clone)]
pub enum SpecifiedParts {
/// Use all the pallet parts except those specified.
/// Use all the pezpallet parts except those specified.
Exclude(Vec<PalletPartNoGeneric>),
/// Use only the specified pallet parts.
/// Use only the specified pezpallet parts.
Use(Vec<PalletPartNoGeneric>),
/// Use the all the pallet parts.
/// Use the all the pezpallet parts.
All,
}
@@ -248,7 +248,7 @@ impl Parse for PalletDeclaration {
None
};
// Check if the pallet is fully expanded.
// Check if the pezpallet is fully expanded.
let (is_expanded, extra_parts) = if input.peek(keyword::expanded) {
let _: keyword::expanded = input.parse()?;
let _: Token![::] = input.parse()?;
@@ -289,7 +289,7 @@ impl Parse for PalletDeclaration {
SpecifiedParts::All
};
// Parse for pallet index
// Parse for pezpallet index
let index = if input.peek(Token![=]) {
input.parse::<Token![=]>()?;
let index = input.parse::<syn::LitInt>()?;
@@ -305,7 +305,7 @@ impl Parse for PalletDeclaration {
}
}
/// A struct representing a path to a pallet. `PalletPath` is almost identical to the standard
/// A struct representing a path to a pezpallet. `PalletPath` is almost identical to the standard
/// Rust path with a few restrictions:
/// - No leading colons allowed
/// - Path segments can only consist of identifiers separated by colons
@@ -380,7 +380,7 @@ fn parse_pallet_parts(input: ParseStream) -> Result<Vec<PalletPart>> {
#[derive(Debug, Clone)]
pub enum PalletPartKeyword {
Pallet(keyword::Pallet),
Pezpallet(keyword::Pezpallet),
Call(keyword::Call),
Storage(keyword::Storage),
Event(keyword::Event),
@@ -400,8 +400,8 @@ impl Parse for PalletPartKeyword {
fn parse(input: ParseStream) -> Result<Self> {
let lookahead = input.lookahead1();
if lookahead.peek(keyword::Pallet) {
Ok(Self::Pallet(input.parse()?))
if lookahead.peek(keyword::Pezpallet) {
Ok(Self::Pezpallet(input.parse()?))
} else if lookahead.peek(keyword::Call) {
Ok(Self::Call(input.parse()?))
} else if lookahead.peek(keyword::Storage) {
@@ -438,7 +438,7 @@ impl PalletPartKeyword {
/// Returns the name of `Self`.
fn name(&self) -> &'static str {
match self {
Self::Pallet(_) => "Pallet",
Self::Pezpallet(_) => "Pezpallet",
Self::Call(_) => "Call",
Self::Storage(_) => "Storage",
Self::Event(_) => "Event",
@@ -455,12 +455,12 @@ impl PalletPartKeyword {
}
}
/// Returns `true` if this pallet part is allowed to have generic arguments.
/// Returns `true` if this pezpallet part is allowed to have generic arguments.
fn allows_generic(&self) -> bool {
Self::all_generic_arg().iter().any(|n| *n == self.name())
}
/// Returns the names of all pallet parts that allow to have a generic argument.
/// Returns the names of all pezpallet parts that allow to have a generic argument.
fn all_generic_arg() -> &'static [&'static str] {
&["Event", "Error", "Origin", "Config", "Task"]
}
@@ -469,7 +469,7 @@ impl PalletPartKeyword {
impl ToTokens for PalletPartKeyword {
fn to_tokens(&self, tokens: &mut TokenStream) {
match self {
Self::Pallet(inner) => inner.to_tokens(tokens),
Self::Pezpallet(inner) => inner.to_tokens(tokens),
Self::Call(inner) => inner.to_tokens(tokens),
Self::Storage(inner) => inner.to_tokens(tokens),
Self::Event(inner) => inner.to_tokens(tokens),
@@ -519,7 +519,7 @@ impl PalletPart {
res.join(", ")
}
/// The name of this pallet part.
/// The name of this pezpallet part.
pub fn name(&self) -> &'static str {
self.keyword.name()
}
@@ -574,20 +574,20 @@ fn parse_pallet_parts_no_generic(input: ParseStream) -> Result<Vec<PalletPartNoG
Ok(pezpallet_parts.content.inner.into_iter().collect())
}
/// The final definition of a pallet with the resulting fixed index and explicit parts.
/// The final definition of a pezpallet with the resulting fixed index and explicit parts.
#[derive(Debug, Clone)]
pub struct Pallet {
/// Is this pallet fully expanded?
pub struct Pezpallet {
/// Is this pezpallet fully expanded?
pub is_expanded: bool,
/// The name of the pallet, e.g.`System` in `System: pezframe_system`.
/// The name of the pezpallet, e.g.`System` in `System: pezframe_system`.
pub name: Ident,
/// Either automatically inferred, or defined (e.g. `MyPallet ... = 3,`).
pub index: u8,
/// The path of the pallet, e.g. `pezframe_system` in `System: pezframe_system`.
/// The path of the pezpallet, e.g. `pezframe_system` in `System: pezframe_system`.
pub path: PalletPath,
/// The instance of the pallet, 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 pallet parts to use for the pallet.
/// The pezpallet parts to use for the pezpallet.
pub pezpallet_parts: Vec<PalletPart>,
/// Expressions specified inside of a #[cfg] attribute.
pub cfg_pattern: Vec<cfg_expr::Expression>,
@@ -595,8 +595,8 @@ pub struct Pallet {
pub docs: Vec<syn::Expr>,
}
impl Pallet {
/// Get resolved pallet parts
impl Pezpallet {
/// Get resolved pezpallet parts
pub fn pezpallet_parts(&self) -> &[PalletPart] {
&self.pezpallet_parts
}
@@ -606,12 +606,12 @@ impl Pallet {
self.pezpallet_parts.iter().find(|part| part.name() == name)
}
/// Return whether pallet contains part
/// Return whether pezpallet contains part
pub fn exists_part(&self, name: &str) -> bool {
self.find_part(name).is_some()
}
// Get runtime attributes for the pallet, mostly used for macros
// Get runtime attributes for the pezpallet, mostly used for macros
pub fn get_attributes(&self) -> TokenStream {
self.cfg_pattern.iter().fold(TokenStream::new(), |acc, pattern| {
let attr = TokenStream::from_str(&format!("#[cfg({})]", pattern.original()))
@@ -640,29 +640,29 @@ enum PalletsConversion {
Implicit(Vec<PalletDeclaration>),
/// Pallets explicitly declare parts.
///
/// `System: pezframe_system::{Pallet, Call}`
/// `System: pezframe_system::{Pezpallet, Call}`
///
/// However, for backwards compatibility with Pezkuwi/Kusama
/// we must propagate some other parts to the pallet by default.
Explicit(Vec<Pallet>),
/// we must propagate some other parts to the pezpallet by default.
Explicit(Vec<Pezpallet>),
/// Pallets explicitly declare parts that are fully expanded.
///
/// This is the end state that contains extra parts included by
/// default by Bizinikiwi.
///
/// `System: pezframe_system expanded::{Error} ::{Pallet, Call}`
/// `System: pezframe_system expanded::{Error} ::{Pezpallet, Call}`
///
/// For this example, the `Pallet`, `Call` and `Error` parts are collected.
ExplicitExpanded(Vec<Pallet>),
/// For this example, the `Pezpallet`, `Call` and `Error` parts are collected.
ExplicitExpanded(Vec<Pezpallet>),
}
/// Convert from the parsed pallet declaration to their final information.
/// Convert from the parsed pezpallet declaration to their final information.
///
/// Check if all pallet have explicit declaration of their parts, if so then assign index to each
/// pallet using same rules as rust for fieldless enum. I.e. implicit are assigned number
/// Check if all pezpallet have explicit declaration of their parts, if so then assign index to each
/// pezpallet using same rules as rust for fieldless enum. I.e. implicit are assigned number
/// incrementally from last explicit or 0.
fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConversion> {
if pallets.iter().any(|pallet| pallet.pezpallet_parts.is_none()) {
if pallets.iter().any(|pezpallet| pezpallet.pezpallet_parts.is_none()) {
return Ok(PalletsConversion::Implicit(pallets));
}
@@ -673,49 +673,49 @@ fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConver
let pallets = pallets
.into_iter()
.map(|pallet| {
let final_index = match pallet.index {
.map(|pezpallet| {
let final_index = match pezpallet.index {
Some(i) => i,
None => last_index.map_or(Some(0), |i| i.checked_add(1)).ok_or_else(|| {
let msg = "Pallet index doesn't fit into u8, index is 256";
syn::Error::new(pallet.name.span(), msg)
let msg = "Pezpallet index doesn't fit into u8, index is 256";
syn::Error::new(pezpallet.name.span(), msg)
})?,
};
last_index = Some(final_index);
if let Some(used_pallet) = indices.insert(final_index, pallet.name.clone()) {
if let Some(used_pallet) = indices.insert(final_index, pezpallet.name.clone()) {
let msg = format!(
"Pallet indices are conflicting: Both pallets {} and {} are at index {}",
used_pallet, pallet.name, final_index,
"Pezpallet indices are conflicting: Both pallets {} and {} are at index {}",
used_pallet, pezpallet.name, final_index,
);
let mut err = syn::Error::new(used_pallet.span(), &msg);
err.combine(syn::Error::new(pallet.name.span(), msg));
err.combine(syn::Error::new(pezpallet.name.span(), msg));
return Err(err);
}
if let Some(used_pallet) = names.insert(pallet.name.clone(), pallet.name.span()) {
if let Some(used_pallet) = names.insert(pezpallet.name.clone(), pezpallet.name.span()) {
let msg = "Two pallets with the same name!";
let mut err = syn::Error::new(used_pallet, &msg);
err.combine(syn::Error::new(pallet.name.span(), &msg));
err.combine(syn::Error::new(pezpallet.name.span(), &msg));
return Err(err);
}
let mut pezpallet_parts = pallet.pezpallet_parts.expect("Checked above");
let mut pezpallet_parts = pezpallet.pezpallet_parts.expect("Checked above");
let available_parts =
pezpallet_parts.iter().map(|part| part.keyword.name()).collect::<HashSet<_>>();
// Check parts are correctly specified
match &pallet.specified_parts {
match &pezpallet.specified_parts {
SpecifiedParts::Exclude(parts) | SpecifiedParts::Use(parts) =>
for part in parts {
if !available_parts.contains(part.keyword.name()) {
let msg = format!(
"Invalid pallet part specified, the pallet `{}` doesn't have the \
"Invalid pezpallet part specified, the pezpallet `{}` doesn't have the \
`{}` part. Available parts are: {}.",
pallet.name,
pezpallet.name,
part.keyword.name(),
pezpallet_parts.iter().fold(String::new(), |fold, part| {
if fold.is_empty() {
@@ -732,7 +732,7 @@ fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConver
}
// Set only specified parts.
match pallet.specified_parts {
match pezpallet.specified_parts {
SpecifiedParts::Exclude(excluded_parts) => pezpallet_parts.retain(|part| {
!excluded_parts
.iter()
@@ -744,12 +744,12 @@ fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConver
SpecifiedParts::All => (),
}
let cfg_pattern = pallet
let cfg_pattern = pezpallet
.attrs
.iter()
.map(|attr| {
if attr.path().segments.first().map_or(false, |s| s.ident != "cfg") {
let msg = "Unsupported attribute, only #[cfg] is supported on pallet \
let msg = "Unsupported attribute, only #[cfg] is supported on pezpallet \
declarations in `construct_runtime`";
return Err(syn::Error::new(attr.span(), msg));
}
@@ -764,14 +764,14 @@ fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConver
})
.collect::<Result<Vec<_>>>()?;
is_expanded &= pallet.is_expanded;
is_expanded &= pezpallet.is_expanded;
Ok(Pallet {
is_expanded: pallet.is_expanded,
name: pallet.name,
Ok(Pezpallet {
is_expanded: pezpallet.is_expanded,
name: pezpallet.name,
index: final_index,
path: pallet.path,
instance: pallet.instance,
path: pezpallet.path,
instance: pezpallet.instance,
cfg_pattern,
pezpallet_parts,
docs: vec![],
+100 -100
View File
@@ -30,7 +30,7 @@ mod dynamic_params;
mod key_prefix;
mod match_and_insert;
mod no_bound;
mod pallet;
mod pezpallet;
mod pezpallet_error;
mod runtime;
mod storage_alias;
@@ -99,14 +99,14 @@ fn counter_prefix(prefix: &str) -> String {
/// NodeBlock = node::Block,
/// UncheckedExtrinsic = UncheckedExtrinsic
/// {
/// System: pezframe_system::{Pallet, Call, Event<T>, Config<T>} = 0,
/// Test: path::to::test::{Pallet, Call} = 1,
/// System: pezframe_system::{Pezpallet, Call, Event<T>, Config<T>} = 0,
/// Test: path::to::test::{Pezpallet, Call} = 1,
///
/// // Pallets with instances.
/// Test2_Instance1: test2::<Instance1>::{Pallet, Call, Storage, Event<T, I>, Config<T, I>, Origin<T, I>},
/// Test2_DefaultInstance: test2::{Pallet, Call, Storage, Event<T>, Config<T>, Origin<T>} = 4,
/// Test2_Instance1: test2::<Instance1>::{Pezpallet, Call, Storage, Event<T, I>, Config<T, I>, Origin<T, I>},
/// Test2_DefaultInstance: test2::{Pezpallet, Call, Storage, Event<T>, Config<T>, Origin<T>} = 4,
///
/// // Pallets declared with `pallet` attribute macro: no need to define the parts
/// // Pallets declared with `pezpallet` attribute macro: no need to define the parts
/// Test3_Instance1: test3::<Instance1>,
/// Test3_DefaultInstance: test3,
///
@@ -114,59 +114,59 @@ fn counter_prefix(prefix: &str) -> String {
/// Test4_Instance1: test4::<Instance1> exclude_parts { Call, Origin },
/// Test4_DefaultInstance: test4 exclude_parts { Storage },
///
/// // with `use_parts` keyword, a subset of the pallet parts can be specified.
/// Test4_Instance1: test4::<Instance1> use_parts { Pallet, Call},
/// Test4_DefaultInstance: test4 use_parts { Pallet },
/// // with `use_parts` keyword, a subset of the pezpallet parts can be specified.
/// Test4_Instance1: test4::<Instance1> use_parts { Pezpallet, Call},
/// Test4_DefaultInstance: test4 use_parts { Pezpallet },
/// }
/// )
/// ```
///
/// Each pallet is declared as such:
/// * `Identifier`: name given to the pallet that uniquely identifies it.
/// Each pezpallet is declared as such:
/// * `Identifier`: name given to the pezpallet that uniquely identifies it.
///
/// * `:`: colon separator
///
/// * `path::to::pallet`: identifiers separated by colons which declare the path to a pallet
/// * `path::to::pezpallet`: identifiers separated by colons which declare the path to a pezpallet
/// definition.
///
/// * `::<InstanceN>` optional: specify the instance of the pallet to use. If not specified it will
/// * `::<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 pallet declared with `pezframe_support::pallet`: Comma
/// separated parts declared with their generic. If a pallet is declared with
/// `pezframe_support::pallet` macro then the parts can be automatically derived if not explicitly
/// provided. We provide support for the following module parts in a pallet:
/// * `::{ 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:
///
/// - `Pallet` - Required for all pallets
/// - `Call` - If the pallet has callable functions
/// - `Storage` - If the pallet uses storage
/// - `Event` or `Event<T>` (if the event is generic) - If the pallet emits events
/// - `Origin` or `Origin<T>` (if the origin is generic) - If the pallet has instantiable origins
/// - `Config` or `Config<T>` (if the config is generic) - If the pallet builds the genesis
/// - `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
/// - `Config` or `Config<T>` (if the config is generic) - If the pezpallet builds the genesis
/// storage with `GenesisConfig`
/// - `Inherent` - If the pallet provides/can check inherents.
/// - `ValidateUnsigned` - If the pallet validates unsigned extrinsics.
/// - `Inherent` - If the pezpallet provides/can check inherents.
/// - `ValidateUnsigned` - If the pezpallet validates unsigned extrinsics.
///
/// It is important to list these parts here to export them correctly in the metadata or to make
/// the pallet usable in the runtime.
/// the pezpallet usable in the runtime.
///
/// * `exclude_parts { Part1, Part2 }` optional: comma separated parts without generics. I.e. one of
/// `Pallet`, `Call`, `Storage`, `Event`, `Origin`, `Config`, `Inherent`, `ValidateUnsigned`. It
/// `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 pallet parts.
/// subset of the pezpallet parts.
///
/// For example excluding the part `Call` can be useful if the runtime doesn't want to make the
/// pallet calls available.
/// pezpallet calls available.
///
/// * `use_parts { Part1, Part2 }` optional: comma separated parts without generics. I.e. one of
/// `Pallet`, `Call`, `Storage`, `Event`, `Origin`, `Config`, `Inherent`, `ValidateUnsigned`. It
/// `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 pallet parts.
/// subset of the pezpallet parts.
///
/// For example not using the part `Call` can be useful if the runtime doesn't want to make the
/// pallet calls available.
/// pezpallet calls available.
///
/// * `= $n` optional: number to define at which index the pallet variants in `OriginCaller`, `Call`
/// * `= $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
@@ -181,13 +181,13 @@ fn counter_prefix(prefix: &str) -> String {
/// # Note
///
/// The population of the genesis storage depends on the order of pallets. So, if one of your
/// pallets depends on another pallet, the pallet that is depended upon needs to come before
/// the pallet depending on it.
/// pallets depends on another pezpallet, the pezpallet that is depended upon needs to come before
/// the pezpallet depending on it.
///
/// # Type definitions
///
/// * The macro generates a type alias for each pallet to their `Pallet`. E.g. `type System =
/// pezframe_system::Pallet<Runtime>`
/// * The macro generates a type alias for each pezpallet to their `Pezpallet`. E.g. `type System =
/// pezframe_system::Pezpallet<Runtime>`
#[proc_macro]
pub fn construct_runtime(input: TokenStream) -> TokenStream {
construct_runtime::construct_runtime(input)
@@ -196,10 +196,10 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream {
///
/// ---
///
/// Documentation for this macro can be found at `pezframe_support::pallet`.
/// Documentation for this macro can be found at `pezframe_support::pezpallet`.
#[proc_macro_attribute]
pub fn pallet(attr: TokenStream, item: TokenStream) -> TokenStream {
pallet::pallet(attr, item)
pub fn pezpallet(attr: TokenStream, item: TokenStream) -> TokenStream {
pezpallet::pezpallet(attr, item)
}
/// An attribute macro that can be attached to a (non-empty) module declaration. Doing so will
@@ -403,7 +403,7 @@ pub fn derive_default_no_bound(input: TokenStream) -> TokenStream {
no_bound::default::derive_default_no_bound(input)
}
/// Macro used internally in FRAME to generate the crate version for a pallet.
/// Macro used internally in FRAME to generate the crate version for a pezpallet.
#[proc_macro]
pub fn crate_to_crate_version(input: TokenStream) -> TokenStream {
crate_version::crate_to_crate_version(input)
@@ -424,7 +424,7 @@ pub fn impl_key_prefix_for_tuples(input: TokenStream) -> TokenStream {
.into()
}
/// Internal macro use by pezframe_support to generate dummy part checker for old pallet 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)
@@ -537,28 +537,28 @@ 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 `#[pallet::no_default]` on specific items in your default impl that you
/// 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 pallet (or context) in which it is defined.
/// context of the foreign impl and the pezpallet (or context) in which it is defined.
///
/// ## Use-Case Example: Auto-Derive Test Pallet Config Traits
/// ## Use-Case Example: Auto-Derive Test Pezpallet Config Traits
///
/// The `#[derive_imp(..)]` attribute can be used to derive a test pallet `Config` based on an
/// existing pallet `Config` that has been marked with
/// [`#[pallet::config(with_default)]`](`macro@config`) (which under the hood, generates a
/// `DefaultConfig` trait in the pallet in which the macro was invoked).
/// The `#[derive_imp(..)]` attribute can be used to derive a test pezpallet `Config` based on an
/// existing pezpallet `Config` that has been marked with
/// [`#[pezpallet::config(with_default)]`](`macro@config`) (which under the hood, generates a
/// `DefaultConfig` trait in the pezpallet in which the macro was invoked).
///
/// In this case, the `#[derive_impl(..)]` attribute should be attached to an `impl` block that
/// 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 pallet `Config` we want to base our
/// 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 pallet 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::pallet::DefaultConfig)]
/// #[derive_impl(pezframe_system::config_preludes::TestDefaultConfig as pezframe_system::pezpallet::DefaultConfig)]
/// impl pezframe_system::Config for Test {
/// // These are all defined by system as mandatory.
/// type BaseCallFilter = pezframe_support::traits::Everything;
@@ -603,7 +603,7 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// ```ignore
/// impl pezframe_system::Config for Test {
/// use pezframe_system::config_preludes::TestDefaultConfig;
/// use pezframe_system::pallet::DefaultConfig;
/// use pezframe_system::pezpallet::DefaultConfig;
///
/// type BaseCallFilter = pezframe_support::traits::Everything;
/// type RuntimeEvent = RuntimeEvent;
@@ -637,10 +637,10 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// Note that items that are _not_ present in our local `DefaultConfig` are automatically copied
/// from the foreign trait (in this case `TestDefaultConfig`) into the local trait impl (in this
/// case `Test`), unless the trait item in the local trait impl is marked with
/// [`#[pallet::no_default]`](`macro@no_default`), in which case it cannot be overridden, and any
/// [`#[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 pallet that makes
/// 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
@@ -649,7 +649,7 @@ 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 pallet. This is the convention we follow for `pezframe_system`'s `TestDefaultConfig` which, as
/// 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.
@@ -836,11 +836,11 @@ pub fn inject_runtime_type(_: TokenStream, tokens: TokenStream) -> TokenStream {
tokens
}
/// Used internally to decorate pallet attribute macro stubs when they are erroneously used
/// outside of a pallet module
/// Used internally to decorate pezpallet attribute macro stubs when they are erroneously used
/// outside of a pezpallet module
fn pezpallet_macro_stub() -> TokenStream {
quote!(compile_error!(
"This attribute can only be used from within a pallet module marked with `#[pezframe_support::pallet]`"
"This attribute can only be used from within a pezpallet module marked with `#[pezframe_support::pezpallet]`"
))
.into()
}
@@ -927,7 +927,7 @@ pub fn call(_: TokenStream, _: TokenStream) -> TokenStream {
pezpallet_macro_stub()
}
/// Each dispatchable may also be annotated with the `#[pallet::call_index($idx)]` attribute,
/// Each dispatchable may also be annotated with the `#[pezpallet::call_index($idx)]` attribute,
/// which explicitly defines the codec index for the dispatchable function in the `Call` enum.
///
/// ---
@@ -1125,16 +1125,16 @@ 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`). [`pallet:tasks_experimental`](macro@tasks_experimental) when
/// attached to an `impl` block inside a pallet, will generate an enum `Task<T>` whose variants
/// `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:
///
/// * [`pallet::task_list`](macro@task_list)
/// * [`pallet::task_condition`](macro@task_condition)
/// * [`pallet::task_weight`](macro@task_weight)
/// * [`pallet::task_index`](macro@task_index)
/// * [`pezpallet::task_list`](macro@task_list)
/// * [`pezpallet::task_condition`](macro@task_condition)
/// * [`pezpallet::task_weight`](macro@task_weight)
/// * [`pezpallet::task_index`](macro@task_index)
///
/// All of such Tasks are then aggregated into a `RuntimeTask` by
/// [`construct_runtime`](macro@construct_runtime).
@@ -1157,7 +1157,7 @@ pub fn tasks_experimental(_: TokenStream, _: TokenStream) -> TokenStream {
/// Allows defining an iterator over available work items for a task.
///
/// This attribute is attached to a function inside an `impl` block annotated with
/// [`pallet::tasks_experimental`](macro@tasks_experimental).
/// [`pezpallet::tasks_experimental`](macro@tasks_experimental).
///
/// It takes an iterator as input that yields a tuple with same types as the function
/// arguments.
@@ -1169,7 +1169,7 @@ pub fn task_list(_: TokenStream, _: TokenStream) -> TokenStream {
/// Allows defining conditions for a task to run.
///
/// This attribute is attached to a function inside an `impl` block annotated with
/// [`pallet::tasks_experimental`](macro@tasks_experimental) to define the conditions for a
/// [`pezpallet::tasks_experimental`](macro@tasks_experimental) to define the conditions for a
/// given work item to be valid.
///
/// It takes a closure as input, which is then used to define the condition. The closure
@@ -1183,7 +1183,7 @@ pub fn task_condition(_: TokenStream, _: TokenStream) -> TokenStream {
/// Allows defining the weight of a task.
///
/// This attribute is attached to a function inside an `impl` block annotated with
/// [`pallet::tasks_experimental`](macro@tasks_experimental) define the weight of a given work
/// [`pezpallet::tasks_experimental`](macro@tasks_experimental) define the weight of a given work
/// item.
///
/// It takes a closure as input, which should return a `Weight` value.
@@ -1195,7 +1195,7 @@ pub fn task_weight(_: TokenStream, _: TokenStream) -> TokenStream {
/// Allows defining an index for a task.
///
/// This attribute is attached to a function inside an `impl` block annotated with
/// [`pallet::tasks_experimental`](macro@tasks_experimental) to define the index of a given
/// [`pezpallet::tasks_experimental`](macro@tasks_experimental) to define the index of a given
/// work item.
///
/// It takes an integer literal as input, which is then used to define the index. This
@@ -1245,17 +1245,17 @@ pub fn import_section(attr: TokenStream, tokens: TokenStream) -> TokenStream {
let foreign_mod = parse_macro_input!(attr as ItemMod);
let mut internal_mod = parse_macro_input!(tokens as ItemMod);
// check that internal_mod is a pallet module
// check that internal_mod is a pezpallet module
if !internal_mod.attrs.iter().any(|attr| {
if let Some(last_seg) = attr.path().segments.last() {
last_seg.ident == "pallet"
last_seg.ident == "pezpallet"
} else {
false
}
}) {
return Error::new(
internal_mod.ident.span(),
"`#[import_section]` can only be applied to a valid pallet module",
"`#[import_section]` can only be applied to a valid pezpallet module",
)
.to_compile_error()
.into();
@@ -1289,13 +1289,13 @@ pub fn import_section(attr: TokenStream, tokens: TokenStream) -> TokenStream {
/// # Note
///
/// The population of the genesis storage depends on the order of pallets. So, if one of your
/// pallets depends on another pallet, the pallet that is depended upon needs to come before
/// the pallet depending on it.
/// pallets depends on another pezpallet, the pezpallet that is depended upon needs to come before
/// the pezpallet depending on it.
///
/// # Type definitions
///
/// * The macro generates a type alias for each pallet to their `Pallet`. E.g. `type System =
/// pezframe_system::Pallet<Runtime>`
/// * The macro generates a type alias for each pezpallet to their `Pezpallet`. E.g. `type System =
/// pezframe_system::Pezpallet<Runtime>`
#[proc_macro_attribute]
pub fn runtime(attr: TokenStream, item: TokenStream) -> TokenStream {
runtime::runtime(attr, item)
@@ -1367,51 +1367,51 @@ pub fn dynamic_aggregated_params_internal(attrs: TokenStream, input: TokenStream
/// `pezframe_system::CreateAuthorizedTransaction`. This trait allows to specify which transaction
/// extension to use when creating a transaction for an authorized call.
///
/// # Usage in the pallet
/// # Usage in the pezpallet
///
/// ## Example/Overview:
///
/// ```
/// # #[allow(unused)]
/// #[pezframe_support::pallet]
/// pub mod pallet {
/// #[pezframe_support::pezpallet]
/// pub mod pezpallet {
/// use pezframe_support::pezpallet_prelude::*;
/// use pezframe_system::pezpallet_prelude::*;
///
/// #[pallet::pallet]
/// pub struct Pallet<T>(_);
/// #[pezpallet::pezpallet]
/// pub struct Pezpallet<T>(_);
///
/// #[pallet::config]
/// #[pezpallet::config]
/// pub trait Config: pezframe_system::Config {}
///
/// #[pallet::call]
/// impl<T: Config> Pallet<T> {
/// #[pallet::weight(Weight::zero())]
/// #[pallet::authorize(|_source, foo| if *foo == 42 {
/// #[pezpallet::call]
/// impl<T: Config> Pezpallet<T> {
/// #[pezpallet::weight(Weight::zero())]
/// #[pezpallet::authorize(|_source, foo| if *foo == 42 {
/// // The amount to refund, here we refund nothing
/// let refund = Weight::zero();
/// // The validity, here we accept the call and it provides itself.
/// // See `ValidTransaction` for more information.
/// let validity = ValidTransaction::with_tag_prefix("my-pallet")
/// let validity = ValidTransaction::with_tag_prefix("my-pezpallet")
/// .and_provides("some_call")
/// .into();
/// Ok((validity, refund))
/// } else {
/// Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
/// })]
/// #[pallet::weight_of_authorize(Weight::zero())]
/// #[pallet::call_index(0)]
/// #[pezpallet::weight_of_authorize(Weight::zero())]
/// #[pezpallet::call_index(0)]
/// pub fn some_call(origin: OriginFor<T>, arg: u32) -> DispatchResult {
/// ensure_authorized(origin)?;
///
/// Ok(())
/// }
///
/// #[pallet::weight(Weight::zero())]
/// #[pezpallet::weight(Weight::zero())]
/// // We can also give the callback as a function
/// #[pallet::authorize(Self::authorize_some_other_call)]
/// #[pallet::weight_of_authorize(Weight::zero())]
/// #[pallet::call_index(1)]
/// #[pezpallet::authorize(Self::authorize_some_other_call)]
/// #[pezpallet::weight_of_authorize(Weight::zero())]
/// #[pezpallet::call_index(1)]
/// pub fn some_other_call(origin: OriginFor<T>, arg: u32) -> DispatchResult {
/// ensure_authorized(origin)?;
///
@@ -1419,7 +1419,7 @@ pub fn dynamic_aggregated_params_internal(attrs: TokenStream, input: TokenStream
/// }
/// }
///
/// impl<T: Config> Pallet<T> {
/// impl<T: Config> Pezpallet<T> {
/// fn authorize_some_other_call(
/// source: TransactionSource,
/// foo: &u32
@@ -1460,15 +1460,15 @@ pub fn dynamic_aggregated_params_internal(attrs: TokenStream, input: TokenStream
///
/// Authorize process comes with 2 attributes macro on top of the authorized call:
///
/// * `#[pallet::authorize($authorized_function)]` - defines the function that authorizes the 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`.
/// * `#[pallet::weight_of_authorize($weight)]` - defines the value of the weight of the authorize
/// function. This attribute is similar to `#[pallet::weight]`:
/// * `#[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
/// call attribute: `#[pallet::call(weight = T::WeightInfo)]`).
/// call attribute: `#[pezpallet::call(weight = T::WeightInfo)]`).
/// * it can be a fixed value like `Weight::from_all(0)` (not recommended in production).
///
/// The weight must be small enough so that nodes don't get DDOS by validating transactions.
@@ -1498,7 +1498,7 @@ pub fn authorize(_: TokenStream, _: TokenStream) -> TokenStream {
/// See [`authorize`](macro@authorize) for more information on how authorization works.
///
/// Defines the value of the weight of the authorize function. This attribute is similar to
/// `#[pallet::weight]`:
/// `#[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.
@@ -17,7 +17,7 @@
use crate::{
deprecation::extract_or_return_allow_attrs,
pallet::{
pezpallet::{
expand::warnings::{weight_constant_warning, weight_witness_warning},
parse::{
call::{CallVariantDef, CallWeightDef},
@@ -61,7 +61,7 @@ fn expand_weight(
///
/// * Generate enum call and implement various trait on it.
/// * Implement Callable and call_function on `Pallet`
/// * Implement Callable and call_function on `Pezpallet`
pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
let (span, where_clause, methods, docs) = match def.call.as_ref() {
Some(call) => {
@@ -80,7 +80,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
let type_decl_bounded_gen = &def.type_decl_bounded_generics(span);
let type_use_gen = &def.type_use_generics(span);
let call_ident = syn::Ident::new("Call", span);
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let fn_name = methods.iter().map(|method| &method.name).collect::<Vec<_>>();
let call_index = methods.iter().map(|method| method.call_index).collect::<Vec<_>>();
@@ -104,7 +104,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
let warning = Warning::new_deprecated("ImplicitCallIndex")
.index(call_index_warnings.len())
.old("use implicit call indices")
.new("ensure that all calls have a `pallet::call_index` attribute or put the pallet into `dev` mode")
.new("ensure that all calls have a `pezpallet::call_index` attribute or put the pezpallet into `dev` mode")
.help_links(&[
"https://github.com/pezkuwichain/kurdistan-sdk/issues/39",
"https://github.com/pezkuwichain/kurdistan-sdk/issues/36"
@@ -192,7 +192,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
});
let default_docs =
[syn::parse_quote!(r"Contains a variant per dispatchable extrinsic that this pallet has.")];
[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() {
@@ -200,7 +200,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
compile_error!(concat!(
"`",
stringify!($pezpallet_name),
"` does not have #[pallet::call] defined, perhaps you should remove `Call` from \
"` does not have #[pezpallet::call] defined, perhaps you should remove `Call` from \
construct_runtime?",
));
}
@@ -289,7 +289,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
// Implementation of the authorize function for each call
// `authorize_fn_pallet_impl` writes the user-defined authorize function as a function
// implementation for the pallet.
// implementation for the pezpallet.
// `authorize_impl` is the call to this former function to implement `Authorize` trait.
let (authorize_fn_pallet_impl, authorize_impl) = methods
.iter()
@@ -310,10 +310,10 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
// be any implementation of a specific function.
// This allows to have good type inference on the closure.
//
// Then we wrap this into an implementation for `Pallet` in order to get access
// to `Self` as `Pallet` instead of `Call`.
// Then we wrap this into an implementation for `Pezpallet` in order to get access
// to `Self` as `Pezpallet` instead of `Call`.
#cfg_attr
impl<#type_impl_gen> Pallet<#type_use_gen> #where_clause {
impl<#type_impl_gen> Pezpallet<#type_use_gen> #where_clause {
#[doc(hidden)]
fn #attr_fn_getter() -> impl Fn(
#pezframe_support::pezpallet_prelude::TransactionSource,
@@ -327,7 +327,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
// `source` is from outside this block, so we can't use the authorize_fn span.
let authorize_impl = quote::quote!(
{
let authorize_fn = Pallet::<#type_use_gen>::#attr_fn_getter();
let authorize_fn = Pezpallet::<#type_use_gen>::#attr_fn_getter();
let res = authorize_fn(#source, #( #arg_name, )*);
Some(res)
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::Def;
use crate::pezpallet::Def;
use proc_macro2::TokenStream;
/// Expands `composite_enum` and adds the `VariantCount` implementation for it.
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::{parse::GenericKind, Def};
use crate::pezpallet::{parse::GenericKind, Def};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{parse_quote, Item};
@@ -37,13 +37,13 @@ pub fn expand_config(def: &mut Def) -> TokenStream {
0,
parse_quote!(
#[doc = r"
Configuration trait of this pallet.
Configuration trait of this pezpallet.
The main purpose of this trait is to act as an interface between this pallet and the runtime in
The main purpose of this trait is to act as an interface between this pezpallet and the runtime in
which it is embedded in. A type, function, or constant in this trait is essentially left to be
configured by the runtime that includes this pallet.
configured by the runtime that includes this pezpallet.
Consequently, a runtime that wants to include this pallet must implement this trait."
Consequently, a runtime that wants to include this pezpallet must implement this trait."
]
),
);
@@ -104,11 +104,11 @@ Consequently, a runtime that wants to include this pallet must implement this tr
quote!(
/// Based on [`Config`]. Auto-generated by
/// [`#[pallet::config(with_default)]`](`pezframe_support::pezpallet_macros::config`).
/// [`#[pezpallet::config(with_default)]`](`pezframe_support::pezpallet_macros::config`).
/// Can be used in tandem with
/// [`#[register_default_config]`](`pezframe_support::register_default_config`) and
/// [`#[derive_impl]`](`pezframe_support::derive_impl`) to derive test config traits
/// based on existing pallet config traits in a safe and developer-friendly way.
/// based on existing pezpallet config traits in a safe and developer-friendly way.
///
/// See [here](`pezframe_support::pezpallet_macros::config`) for more information and caveats about
/// the auto-generated `DefaultConfig` trait and how it is generated.
@@ -123,12 +123,12 @@ Consequently, a runtime that wants to include this pallet must implement this tr
/// Generate the metadata for the associated types of the config trait.
///
/// Implements the `pezpallet_associated_types_metadata` function for the pallet.
/// Implements the `pezpallet_associated_types_metadata` function for the pezpallet.
pub fn expand_config_metadata(def: &Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let type_impl_gen = &def.type_impl_generics(proc_macro2::Span::call_site());
let type_use_gen = &def.type_use_generics(proc_macro2::Span::call_site());
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let trait_use_gen = &def.trait_use_generics(proc_macro2::Span::call_site());
let mut where_clauses = vec![&def.config.where_clause];
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{deprecation::extract_or_return_allow_attrs, pallet::Def};
use crate::{deprecation::extract_or_return_allow_attrs, pezpallet::Def};
struct ConstDef {
/// Name of the associated type.
@@ -32,12 +32,12 @@ struct ConstDef {
pub deprecation_info: proc_macro2::TokenStream,
}
/// Implement the `pezpallet_constants_metadata` function for the pallet.
/// Implement the `pezpallet_constants_metadata` function for the pezpallet.
pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let type_impl_gen = &def.type_impl_generics(proc_macro2::Span::call_site());
let type_use_gen = &def.type_use_generics(proc_macro2::Span::call_site());
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let trait_use_gen = &def.trait_use_generics(proc_macro2::Span::call_site());
let mut where_clauses = vec![&def.config.where_clause];
@@ -93,7 +93,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
doc: const_.doc.clone(),
default_byte_impl: quote::quote!(
#(#maybe_allow_attrs)*
let value = <Pallet<#type_use_gen>>::#ident();
let value = <Pezpallet<#type_use_gen>>::#ident();
#pezframe_support::__private::codec::Encode::encode(&value)
),
metadata_name: const_.metadata_name.clone(),
@@ -17,7 +17,7 @@
use proc_macro2::Span;
use crate::pallet::Def;
use crate::pezpallet::Def;
pub fn expand_doc_only(def: &mut Def) -> proc_macro2::TokenStream {
let dispatchables = if let Some(call_def) = &def.call {
@@ -34,7 +34,7 @@ pub fn expand_doc_only(def: &mut Def) -> proc_macro2::TokenStream {
.collect::<proc_macro2::TokenStream>();
let docs = &method.docs;
let real = format!(" [`Pallet::{}`].", name);
let real = format!(" [`Pezpallet::{}`].", name);
quote::quote!(
#( #[doc = #docs] )*
///
@@ -57,7 +57,7 @@ pub fn expand_doc_only(def: &mut Def) -> proc_macro2::TokenStream {
.map(|storage| {
let storage_name = &storage.ident;
let storage_type_docs = &storage.docs;
let real = format!("[`pallet::{}`].", storage_name);
let real = format!("[`pezpallet::{}`].", storage_name);
quote::quote!(
#( #[doc = #storage_type_docs] )*
///
@@ -72,7 +72,7 @@ pub fn expand_doc_only(def: &mut Def) -> proc_macro2::TokenStream {
quote::quote!(
/// Auto-generated docs-only module listing all (public and private) defined storage types
/// for this pallet.
/// for this pezpallet.
///
/// # Warning: Doc-Only
///
@@ -80,19 +80,19 @@ pub fn expand_doc_only(def: &mut Def) -> proc_macro2::TokenStream {
/// purposes.
///
/// To see the actual storage type, find a struct with the same name at the root of the
/// pallet, in the list of [*Type Definitions*](../index.html#types).
/// pezpallet, in the list of [*Type Definitions*](../index.html#types).
#[cfg(doc)]
pub mod storage_types {
use super::*;
#storage_types
}
/// Auto-generated docs-only module listing all defined dispatchables for this pallet.
/// Auto-generated docs-only module listing all defined dispatchables for this pezpallet.
///
/// # Warning: Doc-Only
///
/// Members of this module cannot be used directly and are only provided for documentation
/// purposes. To see the real version of each dispatchable, look for them in [`Pallet`] or
/// purposes. To see the real version of each dispatchable, look for them in [`Pezpallet`] or
/// [`Call`].
#[cfg(doc)]
pub mod dispatchables {
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::Def;
use crate::pezpallet::Def;
use proc_macro2::TokenStream;
use quote::ToTokens;
use syn::{spanned::Spanned, Attribute, Lit, LitStr};
@@ -84,22 +84,22 @@ impl ToTokens for DocMetaValue {
}
}
/// Extract the documentation from the given pallet definition
/// Extract the documentation from the given pezpallet definition
/// to include in the runtime metadata.
///
/// Implement a `pezpallet_documentation_metadata` function to fetch the
/// documentation that is included in the metadata.
///
/// The documentation is placed on the pallet similar to:
/// The documentation is placed on the pezpallet similar to:
///
/// ```ignore
/// #[pallet]
/// /// Documentation for pallet
/// #[doc = "Documentation for pallet"]
/// #[pezpallet]
/// /// Documentation for pezpallet
/// #[doc = "Documentation for pezpallet"]
/// #[doc = include_str!("../README.md")]
/// #[pezpallet_doc("../documentation1.md")]
/// #[pezpallet_doc("../documentation2.md")]
/// pub mod pallet {}
/// pub mod pezpallet {}
/// ```
///
/// # pezpallet_doc
@@ -108,17 +108,17 @@ impl ToTokens for DocMetaValue {
/// which is the file path that holds the documentation to be added to the metadata.
///
/// Unlike the `doc` attribute, the documentation provided to the `proc_macro` attribute is
/// not added to the pallet.
/// not added to the pezpallet.
pub fn expand_documentation(def: &mut Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let type_impl_gen = &def.type_impl_generics(proc_macro2::Span::call_site());
let type_use_gen = &def.type_use_generics(proc_macro2::Span::call_site());
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let where_clauses = &def.config.where_clause;
// TODO: Use [drain_filter](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain_filter) when it is stable.
// The `pezpallet_doc` attributes are excluded from the generation of the pallet,
// The `pezpallet_doc` attributes are excluded from the generation of the pezpallet,
// but they are included in the runtime metadata.
let mut pezpallet_docs = Vec::with_capacity(def.item.attrs.len());
let mut index = 0;
@@ -17,7 +17,7 @@
use crate::{
deprecation::extract_or_return_allow_attrs,
pallet::{
pezpallet::{
parse::error::{VariantDef, VariantField},
Def,
},
@@ -132,7 +132,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
if get_doc_literals(&error_item.attrs).is_empty() {
error_item.attrs.push(syn::parse_quote!(
#[doc = "The `Error` enum of this pallet."]
#[doc = "The `Error` enum of this pezpallet."]
));
}
@@ -182,7 +182,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
let index = <
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::index::<Pallet<#type_use_gen>>()
>::index::<Pezpallet<#type_use_gen>>()
.expect("Every active module has an index in the runtime; qed") as u8;
let mut encoded = err.encode();
encoded.resize(#pezframe_support::MAX_MODULE_ERROR_ENCODED_SIZE, 0);
@@ -17,7 +17,7 @@
use crate::{
deprecation::extract_or_return_allow_attrs,
pallet::{parse::event::PalletEventDepositAttr, Def},
pezpallet::{parse::event::PalletEventDepositAttr, Def},
COUNTER,
};
use pezframe_support_procedural_tools::get_doc_literals;
@@ -47,7 +47,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream {
compile_error!(concat!(
"`",
stringify!($pezpallet_name),
"` does not have #[pallet::event] defined, perhaps you should \
"` does not have #[pezpallet::event] defined, perhaps you should \
remove `Event` from construct_runtime?",
));
}
@@ -111,7 +111,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream {
if get_doc_literals(&event_item.attrs).is_empty() {
event_item
.attrs
.push(syn::parse_quote!(#[doc = "The `Event` enum of this pallet"]));
.push(syn::parse_quote!(#[doc = "The `Event` enum of this pezpallet"]));
}
// derive some traits because system event require Clone, FullCodec, Eq, PartialEq and Debug
@@ -143,7 +143,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream {
let event_use_gen = &event.gen_kind.type_use_gen(event.attr_span);
let type_impl_gen = &def.type_impl_generics(event.attr_span);
let type_use_gen = &def.type_use_generics(event.attr_span);
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let PalletEventDepositAttr { fn_vis, fn_span, .. } = deposit_event;
@@ -161,7 +161,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream {
Into<<T as #pezframe_system::Config>::RuntimeEvent>
>::into(event);
<#pezframe_system::Pallet<T>>::deposit_event(event)
<#pezframe_system::Pezpallet<T>>::deposit_event(event)
}
}
)
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::Def;
use crate::pezpallet::Def;
///
/// * implement the trait `pezsp_runtime::BuildStorage`
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{pallet::Def, COUNTER};
use crate::{pezpallet::Def, COUNTER};
use pezframe_support_procedural_tools::get_doc_literals;
use quote::ToTokens;
use syn::{spanned::Spanned, Ident};
@@ -55,7 +55,7 @@ pub fn expand_genesis_config(def: &mut Def) -> proc_macro2::TokenStream {
compile_error!(concat!(
"`",
stringify!($pezpallet_name),
"` does not have #[pallet::genesis_config] defined, perhaps you should \
"` does not have #[pezpallet::genesis_config] defined, perhaps you should \
remove `Config` from construct_runtime?",
));
}
@@ -91,7 +91,7 @@ pub fn expand_genesis_config(def: &mut Def) -> proc_macro2::TokenStream {
#[doc = r"
Can be used to configure the
[genesis state](https://docs.pezkuwichain.io/build/genesis-configuration/)
of this pallet.
of this pezpallet.
"]
));
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::Def;
use crate::pezpallet::Def;
/// * implement the individual traits using the Hooks trait
pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
@@ -32,14 +32,14 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let type_impl_gen = &def.type_impl_generics(span);
let type_use_gen = &def.type_use_generics(span);
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let pezframe_system = &def.pezframe_system;
let pezpallet_name = quote::quote! {
<
<T as #pezframe_system::Config>::PalletInfo
as
#pezframe_support::traits::PalletInfo
>::name::<Self>().unwrap_or("<unknown pallet name>")
>::name::<Self>().unwrap_or("<unknown pezpallet name>")
};
let initialize_on_chain_storage_version = if let Some(in_code_version) =
@@ -48,7 +48,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
quote::quote! {
#pezframe_support::__private::log::info!(
target: #pezframe_support::LOG_TARGET,
"🐥 New pallet {:?} detected in the runtime. Initializing the on-chain storage version to match the storage version defined in the pallet: {:?}",
"🐥 New pezpallet {:?} detected in the runtime. Initializing the on-chain storage version to match the storage version defined in the pezpallet: {:?}",
#pezpallet_name,
#in_code_version
);
@@ -59,7 +59,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
let default_version = #pezframe_support::traits::StorageVersion::new(0);
#pezframe_support::__private::log::info!(
target: #pezframe_support::LOG_TARGET,
"🐥 New pallet {:?} detected in the runtime. The pallet has no defined storage version, so the on-chain version is being initialized to {:?}.",
"🐥 New pezpallet {:?} detected in the runtime. The pezpallet has no defined storage version, so the on-chain version is being initialized to {:?}.",
#pezpallet_name,
default_version
);
@@ -129,13 +129,13 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
#pezframe_support::__private::log::error!(
target: #pezframe_support::LOG_TARGET,
"{}: On chain storage version {:?} is set to non zero, \
while the pallet is missing the `#[pallet::storage_version(VERSION)]` attribute.",
while the pezpallet is missing the `#[pezpallet::storage_version(VERSION)]` attribute.",
#pezpallet_name,
on_chain_version,
);
return Err("On chain storage version set, while the pallet doesn't \
have the `#[pallet::storage_version(VERSION)]` attribute.".into());
return Err("On chain storage version set, while the pezpallet doesn't \
have the `#[pezpallet::storage_version(VERSION)]` attribute.".into());
}
}
};
@@ -221,8 +221,8 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
#pezframe_support::__private::pezsp_tracing::trace_span!("before_all")
);
// Check if the pallet has any keys set, including the storage version. If there are
// no keys set, the pallet was just added to the runtime and needs to have its
// Check if the pezpallet has any keys set, including the storage version. If there are
// no keys set, the pezpallet was just added to the runtime and needs to have its
// version initialized.
let pezpallet_hashed_prefix = <Self as PalletInfoAccess>::name_hash();
let exists = contains_prefixed_key(&pezpallet_hashed_prefix);
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{pallet::Def, COUNTER};
use crate::{pezpallet::Def, COUNTER};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{spanned::Spanned, Ident};
@@ -29,7 +29,7 @@ pub fn expand_inherents(def: &mut Def) -> TokenStream {
compile_error!(concat!(
"`",
stringify!($pezpallet_name),
"` does not have #[pallet::inherent] defined, perhaps you should \
"` does not have #[pezpallet::inherent] defined, perhaps you should \
remove `Inherent` from construct_runtime?",
));
}
@@ -15,12 +15,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{pallet::Def, NUMBER_OF_INSTANCE};
use crate::{pezpallet::Def, NUMBER_OF_INSTANCE};
use proc_macro2::Span;
///
/// * Provide inherent instance to be used by construct_runtime
/// * Provide Instance1 ..= Instance16 for instantiable pallet
/// * Provide Instance1 ..= Instance16 for instantiable pezpallet
pub fn expand_instances(def: &mut Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let inherent_ident = syn::Ident::new(crate::INHERENT_INSTANCE_NAME, Span::call_site());
@@ -38,7 +38,7 @@ mod validate_unsigned;
mod view_functions;
mod warnings;
use crate::pallet::Def;
use crate::pezpallet::Def;
use quote::ToTokens;
/// Merge where clause together, `where` token span is taken from the first not none one.
@@ -85,17 +85,17 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream {
def.item.attrs.insert(
0,
syn::parse_quote!(
#[doc = r"The `pallet` module in each FRAME pallet hosts the most important items needed
to construct this pallet.
#[doc = r"The `pezpallet` module in each FRAME pezpallet hosts the most important items needed
to construct this pezpallet.
The main components of this pallet are:
- [`Pallet`], which implements all of the dispatchable extrinsics of the pallet, among
The main components of this pezpallet are:
- [`Pezpallet`], which implements all of the dispatchable extrinsics of the pezpallet, among
other public functions.
- The subset of the functions that are dispatchable can be identified either in the
[`dispatchables`] module or in the [`Call`] enum.
- [`storage_types`], which contains the list of all types that are representing a
storage item. Otherwise, all storage items are listed among [*Type Definitions*](#types).
- [`Config`], which contains the configuration trait of this pallet.
- [`Config`], which contains the configuration trait of this pezpallet.
- [`Event`] and [`Error`], which are listed among the [*Enums*](#enums).
"]
),
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{pallet::Def, COUNTER};
use crate::{pezpallet::Def, COUNTER};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{spanned::Spanned, Ident};
@@ -30,7 +30,7 @@ pub fn expand_origin(def: &mut Def) -> TokenStream {
compile_error!(concat!(
"`",
stringify!($pezpallet_name),
"` does not have #[pallet::origin] defined, perhaps you should \
"` does not have #[pezpallet::origin] defined, perhaps you should \
remove `Origin` from construct_runtime?",
));
}
@@ -15,25 +15,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::{expand::merge_where_clauses, Def};
use crate::pezpallet::{expand::merge_where_clauses, Def};
use pezframe_support_procedural_tools::get_doc_literals;
///
/// * Add derive trait on Pallet
/// * Implement GetStorageVersion on Pallet
/// * Implement OnGenesis on Pallet
/// * Implement `fn error_metadata` on Pallet
/// * Add derive trait on Pezpallet
/// * Implement GetStorageVersion on Pezpallet
/// * Implement OnGenesis on Pezpallet
/// * Implement `fn error_metadata` on Pezpallet
/// * declare Module type alias for construct_runtime
/// * replace the first field type of `struct Pallet` with `PhantomData` if it is `_`
/// * replace the first field type of `struct Pezpallet` with `PhantomData` if it is `_`
/// * implementation of `PalletInfoAccess` information
/// * implementation of `StorageInfoTrait` on Pallet
/// * implementation of `StorageInfoTrait` on Pezpallet
pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let pezframe_system = &def.pezframe_system;
let type_impl_gen = &def.type_impl_generics(def.pezpallet_struct.attr_span);
let type_use_gen = &def.type_use_generics(def.pezpallet_struct.attr_span);
let type_decl_gen = &def.type_decl_generics(def.pezpallet_struct.attr_span);
let pezpallet_ident = &def.pezpallet_struct.pallet;
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)
@@ -52,7 +52,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
if let syn::Item::Struct(item) = item {
item
} else {
unreachable!("Checked by pallet struct parser")
unreachable!("Checked by pezpallet struct parser")
}
};
@@ -68,8 +68,8 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
if get_doc_literals(&pezpallet_item.attrs).is_empty() {
pezpallet_item.attrs.push(syn::parse_quote!(
#[doc = r"
The `Pallet` struct, the main type that implements traits and standalone
functions within the pallet.
The `Pezpallet` struct, the main type that implements traits and standalone
functions within the pezpallet.
"]
));
}
@@ -201,14 +201,14 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
quote::quote_spanned!(def.pezpallet_struct.attr_span =>
#pezpallet_error_metadata
/// Type alias to `Pallet`, to be used by `construct_runtime`.
/// Type alias to `Pezpallet`, to be used by `construct_runtime`.
///
/// Generated by `pallet` attribute macro.
#[deprecated(note = "use `Pallet` instead")]
/// Generated by `pezpallet` attribute macro.
#[deprecated(note = "use `Pezpallet` instead")]
#[allow(dead_code)]
pub type Module<#type_decl_gen> = #pezpallet_ident<#type_use_gen>;
// Implement `GetStorageVersion` for `Pallet`
// Implement `GetStorageVersion` for `Pezpallet`
impl<#type_impl_gen> #pezframe_support::traits::GetStorageVersion
for #pezpallet_ident<#type_use_gen>
#config_where_clause
@@ -224,7 +224,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
}
}
// Implement `OnGenesis` for `Pallet`
// Implement `OnGenesis` for `Pezpallet`
impl<#type_impl_gen> #pezframe_support::traits::OnGenesis
for #pezpallet_ident<#type_use_gen>
#config_where_clause
@@ -235,7 +235,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
}
}
// Implement `PalletInfoAccess` for `Pallet`
// Implement `PalletInfoAccess` for `Pezpallet`
impl<#type_impl_gen> #pezframe_support::traits::PalletInfoAccess
for #pezpallet_ident<#type_use_gen>
#config_where_clause
@@ -244,7 +244,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo as #pezframe_support::traits::PalletInfo
>::index::<Self>()
.expect("Pallet is part of the runtime because pallet `Config` trait is \
.expect("Pezpallet is part of the runtime because pezpallet `Config` trait is \
implemented by the runtime")
}
@@ -252,7 +252,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo as #pezframe_support::traits::PalletInfo
>::name::<Self>()
.expect("Pallet is part of the runtime because pallet `Config` trait is \
.expect("Pezpallet is part of the runtime because pezpallet `Config` trait is \
implemented by the runtime")
}
@@ -260,7 +260,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo as #pezframe_support::traits::PalletInfo
>::name_hash::<Self>()
.expect("Pallet is part of the runtime because pallet `Config` trait is \
.expect("Pezpallet is part of the runtime because pezpallet `Config` trait is \
implemented by the runtime")
}
@@ -268,7 +268,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo as #pezframe_support::traits::PalletInfo
>::module_name::<Self>()
.expect("Pallet is part of the runtime because pallet `Config` trait is \
.expect("Pezpallet is part of the runtime because pezpallet `Config` trait is \
implemented by the runtime")
}
@@ -18,7 +18,7 @@
use crate::{
counter_prefix,
deprecation::extract_or_return_allow_attrs,
pallet::{
pezpallet::{
parse::{
helper::two128_str,
storage::{Metadata, QueryKind, StorageDef, StorageGenerics},
@@ -47,7 +47,7 @@ fn counter_prefix_ident(storage_ident: &syn::Ident) -> syn::Ident {
}
/// Check for duplicated storage prefixes. This step is necessary since users can specify an
/// alternative storage prefix using the #[pallet::storage_prefix] syntax, and we need to ensure
/// alternative storage prefix using the #[pezpallet::storage_prefix] syntax, and we need to ensure
/// that the prefix specified by the user is not a duplicate of an existing one.
fn check_prefix_duplicates(
storage_def: &StorageDef,
@@ -96,7 +96,7 @@ pub struct ResultOnEmptyStructMetadata {
pub visibility: syn::Visibility,
/// The type of the storage item.
pub value_ty: syn::Type,
/// The name of the pallet error enum variant that is going to be returned.
/// The name of the pezpallet error enum variant that is going to be returned.
pub variant_name: syn::Ident,
/// The span used to report compilation errors about the OnEmpty struct.
pub span: proc_macro2::Span,
@@ -175,7 +175,7 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
}
} else {
let msg = format!(
"Invalid pallet::storage, unexpected type for query, expected ResultQuery \
"Invalid pezpallet::storage, unexpected type for query, expected ResultQuery \
with 1 type parameter, found `{}`",
query_type.to_token_stream().to_string()
);
@@ -408,7 +408,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
let pezframe_support = &def.pezframe_support;
let pezframe_system = &def.pezframe_system;
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let mut entries_builder = vec![];
for storage in def.storages.iter() {
let no_docs = vec![];
@@ -681,16 +681,16 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name::<Pallet<#type_use_gen>>()
.expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name::<Pezpallet<#type_use_gen>>()
.expect("No name found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
fn pezpallet_prefix_hash() -> [u8; 16] {
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name_hash::<Pallet<#type_use_gen>>()
.expect("No name_hash found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name_hash::<Pezpallet<#type_use_gen>>()
.expect("No name_hash found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
const STORAGE_PREFIX: &'static str = #counter_prefix_struct_const;
@@ -726,15 +726,15 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name::<Pallet<#type_use_gen>>()
.expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name::<Pezpallet<#type_use_gen>>()
.expect("No name found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
fn pezpallet_prefix_hash() -> [u8; 16] {
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name_hash::<Pallet<#type_use_gen>>()
.expect("No name_hash found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name_hash::<Pezpallet<#type_use_gen>>()
.expect("No name_hash found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
const STORAGE_PREFIX: &'static str = #counter_prefix_struct_const;
fn storage_prefix_hash() -> [u8; 16] {
@@ -771,16 +771,16 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name::<Pallet<#type_use_gen>>()
.expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name::<Pezpallet<#type_use_gen>>()
.expect("No name found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
fn pezpallet_prefix_hash() -> [u8; 16] {
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name_hash::<Pallet<#type_use_gen>>()
.expect("No name_hash found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name_hash::<Pezpallet<#type_use_gen>>()
.expect("No name_hash found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
const STORAGE_PREFIX: &'static str = #prefix_struct_const;
@@ -792,7 +792,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
});
let on_empty_structs = on_empty_struct_metadata.into_iter().map(|metadata| {
use crate::pallet::parse::GenericKind;
use crate::pezpallet::parse::GenericKind;
use syn::{GenericArgument, Path, PathArguments, PathSegment, Type, TypePath};
let ResultOnEmptyStructMetadata {
@@ -847,7 +847,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
)
});
// aggregated where clause of all storage types and the whole pallet.
// aggregated where clause of all storage types and the whole pezpallet.
let mut where_clauses = vec![&def.config.where_clause];
where_clauses.extend(def.storages.iter().map(|storage| &storage.where_clause));
let completed_where_clause = super::merge_where_clauses(&where_clauses);
@@ -882,9 +882,9 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
fn try_decode_entire_state() -> Result<usize, #pezframe_support::__private::Vec<#pezframe_support::traits::TryDecodeEntireStorageError>> {
let pezpallet_name = <<T as #pezframe_system::Config>::PalletInfo as #pezframe_support::traits::PalletInfo>
::name::<#pezpallet_ident<#type_use_gen>>()
.expect("Every active pallet has a name in the runtime; qed");
.expect("Every active pezpallet has a name in the runtime; qed");
#pezframe_support::__private::log::debug!(target: "runtime::try-decode-state", "trying to decode pallet: {pezpallet_name}");
#pezframe_support::__private::log::debug!(target: "runtime::try-decode-state", "trying to decode pezpallet: {pezpallet_name}");
// NOTE: for now, we have to exclude storage items that are feature gated.
let mut errors = #pezframe_support::__private::Vec::new();
@@ -926,7 +926,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
<T as #pezframe_system::Config>::PalletInfo as
#pezframe_support::traits::PalletInfo
>::name::<#pezpallet_ident<#type_use_gen>>()
.expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`."),
.expect("No name found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`."),
entries: {
#[allow(unused_mut)]
let mut entries = #pezframe_support::__private::vec![];
@@ -19,14 +19,14 @@
//! Home of the expansion code for the Tasks API
use crate::pallet::{parse::tasks::*, Def};
use crate::pezpallet::{parse::tasks::*, Def};
use inflector::Inflector;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote, ToTokens};
use syn::{parse_quote_spanned, spanned::Spanned};
impl TaskEnumDef {
/// Since we optionally allow users to manually specify a `#[pallet::task_enum]`, in the
/// Since we optionally allow users to manually specify a `#[pezpallet::task_enum]`, in the
/// event they _don't_ specify one (which is actually the most common behavior) we have to
/// generate one based on the existing [`TasksDef`]. This method performs that generation.
pub fn generate(tasks: &TasksDef, def: &Def) -> Self {
@@ -64,11 +64,11 @@ impl TaskEnumDef {
};
parse_quote_spanned! { span =>
/// Auto-generated enum that encapsulates all tasks defined by this pallet.
/// Auto-generated enum that encapsulates all tasks defined by this pezpallet.
///
/// Conceptually similar to the [`Call`] enum, but for tasks. This is only
/// generated if there are tasks present in this pallet.
#[pallet::task_enum]
/// generated if there are tasks present in this pezpallet.
#[pezpallet::task_enum]
pub enum Task<#type_decl_bounded_generics> {
#(
#variants,
@@ -16,7 +16,7 @@
// limitations under the License.
use crate::{
pallet::{CompositeKeyword, Def},
pezpallet::{CompositeKeyword, Def},
COUNTER,
};
use syn::spanned::Spanned;
@@ -137,7 +137,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
quote::quote!(
// This macro follows the conventions as laid out by the `tt-call` crate. It does not
// accept any arguments and simply returns the pallet parts, separated by commas, then
// accept any arguments and simply returns the pezpallet parts, separated by commas, then
// wrapped inside of braces and finally prepended with double colons, to the caller inside
// of a key named `tokens`.
//
@@ -154,7 +154,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
$caller
tokens = [{
expanded::{
Pallet, #call_part #storage_part #event_part #error_part #origin_part #config_part
Pezpallet, #call_part #storage_part #event_part #error_part #origin_part #config_part
#inherent_part #validate_unsigned_part #freeze_reason_part #task_part
#hold_reason_part #lock_id_part #slash_reason_part
}
@@ -167,10 +167,10 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
// This macro is similar to the `tt_default_parts!`. It expands the pallets that are declared
// explicitly (`System: pezframe_system::{Pallet, Call}`) with extra parts.
// explicitly (`System: pezframe_system::{Pezpallet, Call}`) with extra parts.
//
// For example, after expansion an explicit pallet would look like:
// `System: expanded::{Error} ::{Pallet, Call}`.
// For example, after expansion an explicit pezpallet would look like:
// `System: expanded::{Error} ::{Pezpallet, Call}`.
//
// The `expanded` keyword is a marker of the final state of the `construct_runtime!`.
#[macro_export]
@@ -203,7 +203,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
$my_tt_return! {
$caller
tokens = [{
+ Pallet #call_part_v2 #storage_part_v2 #event_part_v2 #error_part_v2 #origin_part_v2 #config_part_v2
+ Pezpallet #call_part_v2 #storage_part_v2 #event_part_v2 #error_part_v2 #origin_part_v2 #config_part_v2
#inherent_part_v2 #validate_unsigned_part_v2 #freeze_reason_part_v2 #task_part_v2
#hold_reason_part_v2 #lock_id_part_v2 #slash_reason_part_v2
}]
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::Def;
use crate::pezpallet::Def;
///
/// * Generate the struct
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{pallet::Def, COUNTER};
use crate::{pezpallet::Def, COUNTER};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{spanned::Spanned, Ident};
@@ -30,7 +30,7 @@ pub fn expand_validate_unsigned(def: &mut Def) -> TokenStream {
compile_error!(concat!(
"`",
stringify!($pezpallet_name),
"` does not have #[pallet::validate_unsigned] defined, perhaps you should \
"` does not have #[pezpallet::validate_unsigned] defined, perhaps you should \
remove `ValidateUnsigned` from construct_runtime?",
));
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::{parse::view_functions::ViewFunctionDef, Def};
use crate::pezpallet::{parse::view_functions::ViewFunctionDef, Def};
use proc_macro2::{Span, TokenStream};
use syn::spanned::Spanned;
@@ -50,7 +50,7 @@ fn expand_view_function_prefix_impl(
span: Span,
where_clause: Option<&syn::WhereClause>,
) -> TokenStream {
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let pezframe_support = &def.pezframe_support;
let pezframe_system = &def.pezframe_system;
let type_impl_gen = &def.type_impl_generics(span);
@@ -62,8 +62,8 @@ fn expand_view_function_prefix_impl(
<
<T as #pezframe_system::Config>::PalletInfo
as #pezframe_support::traits::PalletInfo
>::name_hash::<Pallet<#type_use_gen>>()
.expect("No name_hash found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.")
>::name_hash::<Pezpallet<#type_use_gen>>()
.expect("No name_hash found for the pezpallet in the runtime! This usually means that the pezpallet wasn't added to `construct_runtime!`.")
}
}
}
@@ -76,7 +76,7 @@ fn expand_view_function(
view_fn: &ViewFunctionDef,
) -> TokenStream {
let pezframe_support = &def.pezframe_support;
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let type_impl_gen = &def.type_impl_generics(span);
let type_decl_bounded_gen = &def.type_decl_bounded_generics(span);
let type_use_gen = &def.type_use_generics(span);
@@ -160,7 +160,7 @@ fn impl_dispatch_view_function(
view_fns: &[ViewFunctionDef],
) -> TokenStream {
let pezframe_support = &def.pezframe_support;
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let type_impl_gen = &def.type_impl_generics(span);
let type_use_gen = &def.type_use_generics(span);
@@ -200,7 +200,7 @@ fn impl_view_function_metadata(
view_fns: &[ViewFunctionDef],
) -> TokenStream {
let pezframe_support = &def.pezframe_support;
let pezpallet_ident = &def.pezpallet_struct.pallet;
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let type_impl_gen = &def.type_impl_generics(span);
let type_use_gen = &def.type_use_generics(span);
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Generates warnings for undesirable pallet code.
//! Generates warnings for undesirable pezpallet code.
use crate::pallet::parse::call::{CallVariantDef, CallWeightDef};
use crate::pezpallet::parse::call::{CallVariantDef, CallWeightDef};
use proc_macro_warning::Warning;
use syn::{
spanned::Spanned,
@@ -55,7 +55,7 @@ pub(crate) fn weight_witness_warning(
}
}
/// Warn if the weight is a constant and the pallet not in `dev_mode`.
/// Warn if the weight is a constant and the pezpallet not in `dev_mode`.
pub(crate) fn weight_constant_warning(
weight: &syn::Expr,
dev_mode: bool,
@@ -69,7 +69,7 @@ pub(crate) fn weight_constant_warning(
let warning = Warning::new_deprecated("ConstantWeight")
.index(warnings.len())
.old("use hard-coded constant as call weight")
.new("benchmark all calls or put the pallet into `dev` mode")
.new("benchmark all calls or put the pezpallet into `dev` mode")
.help_link("https://github.com/pezkuwichain/kurdistan-sdk/issues/48")
.span(lit.span())
.build_or_panic();
@@ -15,12 +15,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Implementation for pallet attribute macro.
//! Implementation for pezpallet attribute macro.
//!
//! General workflow:
//! 1 - parse all pallet attributes:
//! This step remove all attributes `#[pallet::*]` from the ItemMod and build the `Def` struct
//! which holds the ItemMod without `#[pallet::*]` and information given by those attributes
//! 1 - parse all pezpallet attributes:
//! This step remove all attributes `#[pezpallet::*]` from the ItemMod and build the `Def` struct
//! which holds the ItemMod without `#[pezpallet::*]` and information given by those attributes
//! 2 - expand from the parsed information
//! This step will modify the ItemMod by adding some derive attributes or phantom data variants
//! to user defined types. And also crate new types and implement block.
@@ -35,7 +35,7 @@ mod keyword {
syn::custom_keyword!(dev_mode);
}
pub fn pallet(
pub fn pezpallet(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
@@ -44,10 +44,10 @@ pub fn pallet(
if let Ok(_) = syn::parse::<keyword::dev_mode>(attr.clone()) {
dev_mode = true;
} else {
let msg = "Invalid pallet macro call: unexpected attribute. Macro call must be \
bare, such as `#[pezframe_support::pallet]` or `#[pallet]`, or must specify the \
`dev_mode` attribute, such as `#[pezframe_support::pallet(dev_mode)]` or \
#[pallet(dev_mode)].";
let msg = "Invalid pezpallet macro call: unexpected attribute. Macro call must be \
bare, such as `#[pezframe_support::pezpallet]` or `#[pezpallet]`, or must specify the \
`dev_mode` attribute, such as `#[pezframe_support::pezpallet(dev_mode)]` or \
#[pezpallet(dev_mode)].";
let span = proc_macro2::TokenStream::from(attr).span();
return syn::Error::new(span, msg).to_compile_error().into();
}
@@ -31,23 +31,23 @@ mod keyword {
syn::custom_keyword!(call_index);
syn::custom_keyword!(compact);
syn::custom_keyword!(T);
syn::custom_keyword!(pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(feeless_if);
syn::custom_keyword!(authorize);
syn::custom_keyword!(weight_of_authorize);
}
/// Definition of dispatchables typically `impl<T: Config> Pallet<T> { ... }`
/// Definition of dispatchables typically `impl<T: Config> Pezpallet<T> { ... }`
pub struct CallDef {
/// The where_clause used.
pub where_clause: Option<syn::WhereClause>,
/// A set of usage of instance, must be check for consistency with trait.
pub instances: Vec<helper::InstanceUsage>,
/// The index of call item in pallet module.
/// The index of call item in pezpallet module.
pub index: usize,
/// Information on methods (used for expansion).
pub methods: Vec<CallVariantDef>,
/// The span of the pallet::call attribute.
/// The span of the pezpallet::call attribute.
pub attr_span: proc_macro2::Span,
/// Docs, specified on the impl Block.
pub docs: Vec<syn::Expr>,
@@ -56,14 +56,14 @@ pub struct CallDef {
/// The weight of a call or the weight of authorize.
#[derive(Clone)]
pub enum CallWeightDef {
/// Explicitly set on the call itself with `#[pallet::weight(…)]` or
/// `#[pallet::weight_of_authorize(…)]`. This value is used.
/// Explicitly set on the call itself with `#[pezpallet::weight(…)]` or
/// `#[pezpallet::weight_of_authorize(…)]`. This value is used.
Immediate(syn::Expr),
/// The default value that should be set for dev-mode pallets. Usually zero.
DevModeDefault,
/// Inherits whatever value is configured on the pallet level.
/// Inherits whatever value is configured on the pezpallet level.
///
/// The concrete value is not known at this point.
Inherited(syn::Type),
@@ -103,7 +103,7 @@ pub struct CallVariantDef {
pub attrs: Vec<syn::Attribute>,
/// The `cfg` attributes.
pub cfg_attrs: Vec<syn::Attribute>,
/// The optional `feeless_if` attribute on the `pallet::call`.
/// The optional `feeless_if` attribute on the `pezpallet::call`.
pub feeless_check: Option<syn::ExprClosure>,
/// The return type of the call: `DispatchInfo` or `DispatchResultWithPostInfo`.
pub return_type: helper::CallReturnType,
@@ -118,21 +118,21 @@ pub struct AuthorizeDef {
/// The expression of the authorize attribute.
pub expr: syn::Expr,
/// The weight of the authorize attribute as define by the attribute
/// `[pallet::weight_of_authorize]`.
/// `[pezpallet::weight_of_authorize]`.
pub weight: CallWeightDef,
}
/// Attributes for functions in call impl block.
pub enum FunctionAttr {
/// Parse for `#[pallet::call_index(expr)]`
/// Parse for `#[pezpallet::call_index(expr)]`
CallIndex(u8),
/// Parse for `#[pallet::weight(expr)]`
/// Parse for `#[pezpallet::weight(expr)]`
Weight(syn::Expr),
/// Parse for `#[pallet::feeless_if(expr)]`
/// Parse for `#[pezpallet::feeless_if(expr)]`
FeelessIf(Span, syn::ExprClosure),
/// Parse for `#[pallet::authorize(expr)]`
/// Parse for `#[pezpallet::authorize(expr)]`
Authorize(syn::Expr),
/// Parse for `#[pallet::weight_of_authorize(expr)]`
/// Parse for `#[pezpallet::weight_of_authorize(expr)]`
WeightOfAuthorize(syn::Expr),
}
@@ -141,7 +141,7 @@ impl syn::parse::Parse for FunctionAttr {
input.parse::<syn::Token![#]>()?;
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
let lookahead = content.lookahead1();
@@ -190,7 +190,7 @@ impl syn::parse::Parse for FunctionAttr {
}
/// Attribute for arguments in function in call impl block.
/// Parse for `#[pallet::compact]|
/// Parse for `#[pezpallet::compact]|
pub struct ArgAttrIsCompact;
impl syn::parse::Parse for ArgAttrIsCompact {
@@ -198,7 +198,7 @@ impl syn::parse::Parse for ArgAttrIsCompact {
input.parse::<syn::Token![#]>()?;
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
content.parse::<keyword::compact>()?;
@@ -259,7 +259,7 @@ impl CallDef {
let item_impl = if let syn::Item::Impl(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pallet::call, expected item impl"));
return Err(syn::Error::new(item.span(), "Invalid pezpallet::call, expected item impl"));
};
crate::deprecation::prevent_deprecation_attr_on_outer_enum(&item_impl.attrs)?;
@@ -270,8 +270,8 @@ impl CallDef {
];
if let Some((_, _, for_)) = item_impl.trait_ {
let msg = "Invalid pallet::call, expected no trait ident as in \
`impl<..> Pallet<..> { .. }`";
let msg = "Invalid pezpallet::call, expected no trait ident as in \
`impl<..> Pezpallet<..> { .. }`";
return Err(syn::Error::new(for_.span(), msg));
}
@@ -281,7 +281,7 @@ impl CallDef {
for item in &mut item_impl.items {
if let syn::ImplItem::Fn(method) = item {
if !matches!(method.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::call, dispatchable function must be public: \
let msg = "Invalid pezpallet::call, dispatchable function must be public: \
`pub fn`";
let span = match method.vis {
@@ -294,11 +294,11 @@ impl CallDef {
match method.sig.inputs.first() {
None => {
let msg = "Invalid pallet::call, must have at least origin arg";
let msg = "Invalid pezpallet::call, must have at least origin arg";
return Err(syn::Error::new(method.sig.span(), msg));
},
Some(syn::FnArg::Receiver(_)) => {
let msg = "Invalid pallet::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));
},
@@ -321,7 +321,7 @@ impl CallDef {
FunctionAttr::CallIndex(idx) => {
if call_index.is_some() {
let msg =
"Invalid pallet::call, too many call_index attributes given";
"Invalid pezpallet::call, too many call_index attributes given";
return Err(syn::Error::new(method.sig.span(), msg));
}
@@ -329,7 +329,7 @@ impl CallDef {
},
FunctionAttr::Weight(w) => {
if weight.is_some() {
let msg = "Invalid pallet::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);
@@ -337,7 +337,7 @@ impl CallDef {
FunctionAttr::FeelessIf(span, closure) => {
if feeless_check.is_some() {
let msg =
"Invalid pallet::call, there can only be one feeless_if attribute";
"Invalid pezpallet::call, there can only be one feeless_if attribute";
return Err(syn::Error::new(span, msg));
}
@@ -346,7 +346,7 @@ impl CallDef {
FunctionAttr::Authorize(expr) => {
if authorize.is_some() {
let msg =
"Invalid pallet::call, there can only be one authorize attribute";
"Invalid pezpallet::call, there can only be one authorize attribute";
return Err(syn::Error::new(method.sig.span(), msg));
}
@@ -354,7 +354,7 @@ impl CallDef {
},
FunctionAttr::WeightOfAuthorize(expr) => {
if weight_of_authorize.is_some() {
let msg = "Invalid pallet::call, there can only be one weight_of_authorize attribute";
let msg = "Invalid pezpallet::call, there can only be one weight_of_authorize attribute";
return Err(syn::Error::new(method.sig.span(), msg));
}
@@ -364,7 +364,7 @@ impl CallDef {
}
if weight_of_authorize.is_some() && authorize.is_none() {
let msg = "Invalid pallet::call, weight_of_authorize attribute must be used with authorize attribute";
let msg = "Invalid pezpallet::call, weight_of_authorize attribute must be used with authorize attribute";
return Err(syn::Error::new(weight_of_authorize.unwrap().span(), msg));
}
@@ -377,9 +377,9 @@ impl CallDef {
.ok_or_else(|| {
syn::Error::new(
method.sig.span(),
"A pallet::call using authorize requires either a concrete \
`#[pallet::weight_of_authorize($expr)]` or an inherited weight from \
the `#[pallet:call(weight($type))]` attribute, but \
"A pezpallet::call using authorize requires either a concrete \
`#[pezpallet::weight_of_authorize($expr)]` or an inherited weight from \
the `#[pezpallet:call(weight($type))]` attribute, but \
none were given.",
)
})?;
@@ -392,8 +392,8 @@ impl CallDef {
.ok_or_else(|| {
syn::Error::new(
method.sig.span(),
"A pallet::call requires either a concrete `#[pallet::weight($expr)]` \
or an inherited weight from the `#[pallet:call(weight($type))]` \
"A pezpallet::call requires either a concrete `#[pezpallet::weight($expr)]` \
or an inherited weight from the `#[pezpallet:call(weight($type))]` \
attribute, but none were given.",
)
})?;
@@ -432,14 +432,14 @@ impl CallDef {
helper::take_item_pallet_attrs(&mut arg.attrs)?;
if arg_attrs.len() > 1 {
let msg = "Invalid pallet::call, argument has too many attributes";
let msg = "Invalid pezpallet::call, argument has too many attributes";
return Err(syn::Error::new(arg.span(), msg));
}
let arg_ident = if let syn::Pat::Ident(pat) = &*arg.pat {
pat.ident.clone()
} else {
let msg = "Invalid pallet::call, argument must be ident";
let msg = "Invalid pezpallet::call, argument must be ident";
return Err(syn::Error::new(arg.pat.span(), msg));
};
@@ -450,21 +450,21 @@ impl CallDef {
if let Some(ref feeless_check) = feeless_check {
if feeless_check.inputs.len() != args.len() + 1 {
let msg = "Invalid pallet::call, feeless_if closure must have same \
let msg = "Invalid pezpallet::call, feeless_if closure must have same \
number of arguments as the dispatchable function";
return Err(syn::Error::new(feeless_check.span(), msg));
}
match feeless_check.inputs.first() {
None => {
let msg = "Invalid pallet::call, feeless_if closure must have at least origin arg";
let msg = "Invalid pezpallet::call, feeless_if closure must have at least origin arg";
return Err(syn::Error::new(feeless_check.span(), msg));
},
Some(syn::Pat::Type(arg)) => {
check_dispatchable_first_arg_type(&arg.ty, true)?;
},
_ => {
let msg = "Invalid pallet::call, feeless_if closure first argument must be a typed argument, \
let msg = "Invalid pezpallet::call, feeless_if closure first argument must be a typed argument, \
e.g. `origin: OriginFor<T>`";
return Err(syn::Error::new(feeless_check.span(), msg));
},
@@ -477,17 +477,17 @@ impl CallDef {
if let syn::Type::Reference(pat) = *ty {
pat.elem.clone()
} else {
let msg = "Invalid pallet::call, feeless_if closure argument must be a reference";
let msg = "Invalid pezpallet::call, feeless_if closure argument must be a reference";
return Err(syn::Error::new(ty.span(), msg));
}
} else {
let msg = "Invalid pallet::call, feeless_if closure argument must be a type ascription pattern";
let msg = "Invalid pezpallet::call, feeless_if closure argument must be a type ascription pattern";
return Err(syn::Error::new(feeless_arg.span(), msg));
};
if feeless_arg_type != arg.2 {
let msg =
"Invalid pallet::call, feeless_if closure argument must have \
"Invalid pezpallet::call, feeless_if closure argument must have \
a reference to the same type as the dispatchable function argument";
return Err(syn::Error::new(feeless_arg.span(), msg));
}
@@ -501,7 +501,7 @@ impl CallDef {
_ => false,
};
if !valid_return {
let msg = "Invalid pallet::call, feeless_if closure must return `bool`";
let msg = "Invalid pezpallet::call, feeless_if closure must return `bool`";
return Err(syn::Error::new(feeless_check.output.span(), msg));
}
}
@@ -520,7 +520,7 @@ impl CallDef {
authorize,
});
} else {
let msg = "Invalid pallet::call, only method accepted";
let msg = "Invalid pezpallet::call, only method accepted";
return Err(syn::Error::new(item.span(), msg));
}
}
@@ -91,11 +91,11 @@ 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 pallet::composite_enum.
/// Type parameters and where clause attached to a declaration of the pezpallet::composite_enum.
pub generics: syn::Generics,
/// The span of the pallet::composite_enum attribute.
/// The span of the pezpallet::composite_enum attribute.
pub attr_span: proc_macro2::Span,
/// Variant count of the pallet::composite_enum.
/// Variant count of the pezpallet::composite_enum.
pub variant_count: u32,
}
@@ -123,12 +123,12 @@ impl CompositeDef {
} else {
return Err(syn::Error::new(
item.span(),
"Invalid pallet::composite_enum, expected enum item",
"Invalid pezpallet::composite_enum, expected enum item",
));
};
if !matches!(item.vis, syn::Visibility::Public(_)) {
let msg = format!("Invalid pallet::composite_enum, `{}` must be public", item.ident);
let msg = format!("Invalid pezpallet::composite_enum, `{}` must be public", item.ident);
return Err(syn::Error::new(item.span(), msg));
}
@@ -28,7 +28,7 @@ mod keyword {
syn::custom_keyword!(T);
syn::custom_keyword!(I);
syn::custom_keyword!(config);
syn::custom_keyword!(pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(IsType);
syn::custom_keyword!(RuntimeEvent);
syn::custom_keyword!(Event);
@@ -43,15 +43,15 @@ mod keyword {
#[derive(Default)]
pub struct DefaultTrait {
/// A bool for each sub-trait item indicates whether the item has
/// `#[pallet::no_default_bounds]` attached to it. If true, the item will not have any bounds
/// `#[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,
}
/// Input definition for the pallet config.
/// Input definition for the pezpallet config.
pub struct ConfigDef {
/// The index of item in pallet module.
/// The index of item in pezpallet module.
pub index: usize,
/// Whether the trait has instance (i.e. define with `Config<I = ()>`)
pub has_instance: bool,
@@ -63,15 +63,15 @@ pub struct ConfigDef {
pub where_clause: Option<syn::WhereClause>,
/// Whether a default sub-trait should be generated.
///
/// Contains default sub-trait items (instantiated by `#[pallet::config(with_default)]`).
/// Vec will be empty if `#[pallet::config(with_default)]` is not specified or if there are
/// Contains default sub-trait items (instantiated by `#[pezpallet::config(with_default)]`).
/// Vec will be empty if `#[pezpallet::config(with_default)]` is not specified or if there are
/// no trait items.
pub default_sub_trait: Option<DefaultTrait>,
/// Compile time warnings. Mainly for deprecated items.
pub warnings: Vec<Warning>,
}
/// Input definition for an associated type in pallet config.
/// Input definition for an associated type in pezpallet config.
pub struct AssociatedTypeMetadataDef {
/// Name of the associated type.
pub ident: syn::Ident,
@@ -91,7 +91,7 @@ impl From<&syn::TraitItemType> for AssociatedTypeMetadataDef {
}
}
/// Input definition for a constant in pallet config.
/// Input definition for a constant in pezpallet config.
pub struct ConstMetadataDef {
/// Name of the associated type.
pub ident: syn::Ident,
@@ -108,7 +108,7 @@ impl TryFrom<&syn::TraitItemType> for ConstMetadataDef {
fn try_from(trait_ty: &syn::TraitItemType) -> Result<Self, Self::Error> {
let err = |span, msg| {
syn::Error::new(span, format!("Invalid usage of `#[pallet::constant]`: {}", msg))
syn::Error::new(span, format!("Invalid usage of `#[pezpallet::constant]`: {}", msg))
};
let doc = get_doc_literals(&trait_ty.attrs);
let ident = trait_ty.ident.clone();
@@ -142,7 +142,7 @@ impl TryFrom<&syn::TraitItemType> for ConstMetadataDef {
}
}
/// Parse for `#[pallet::disable_pezframe_system_supertrait_check]`
/// Parse for `#[pezpallet::disable_pezframe_system_supertrait_check]`
pub struct DisableFrameSystemSupertraitCheck;
impl syn::parse::Parse for DisableFrameSystemSupertraitCheck {
@@ -171,14 +171,14 @@ pub enum PalletAttrType {
IncludeMetadata(keyword::include_metadata),
}
/// Parsing for `#[pallet::X]`
/// Parsing for `#[pezpallet::X]`
#[derive(derive_syn_parse::Parse)]
pub struct PalletAttr {
_pound: Token![#],
#[bracket]
_bracket: token::Bracket,
#[inside(_bracket)]
_pallet: keyword::pallet,
_pallet: keyword::pezpallet,
#[prefix(Token![::] in _bracket)]
#[inside(_bracket)]
typ: PalletAttrType,
@@ -374,12 +374,12 @@ impl ConfigDef {
is_pezframe_system: bool,
) -> syn::Result<Self> {
let syn::Item::Trait(item) = item else {
let msg = "Invalid pallet::config, expected trait definition";
let msg = "Invalid pezpallet::config, expected trait definition";
return Err(syn::Error::new(item.span(), msg));
};
if !matches!(item.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::config, trait must be public";
let msg = "Invalid pezpallet::config, trait must be public";
return Err(syn::Error::new(item.span(), msg));
}
@@ -394,7 +394,7 @@ impl ConfigDef {
};
if item.generics.params.len() > 1 {
let msg = "Invalid pallet::config, expected no more than one generic";
let msg = "Invalid pezpallet::config, expected no more than one generic";
return Err(syn::Error::new(item.generics.params[2].span(), msg));
}
@@ -421,7 +421,7 @@ impl ConfigDef {
let mut already_no_default_bounds = false;
let mut already_collected_associated_type = None;
// add deprecation notice for `RuntimeEvent`, iff pallet is not `pezframe_system`
// add deprecation notice for `RuntimeEvent`, iff pezpallet is not `pezframe_system`
if is_event && !is_pezframe_system {
if let syn::TraitItem::Type(type_event) = trait_item {
let allow_dep: syn::Attribute = parse_quote!(#[allow(deprecated)]);
@@ -429,7 +429,7 @@ impl ConfigDef {
// Check if the `#[allow(deprecated)]` attribute is present
if !type_event.attrs.iter().any(|attr| attr == &allow_dep) {
let warning = Warning::new_deprecated("RuntimeEvent")
.old("have `RuntimeEvent` associated type in the pallet config")
.old("have `RuntimeEvent` associated type in the pezpallet config")
.new("remove it as it is redundant since associated bound gets appended automatically: \n
pub trait Config: pezframe_system::Config<RuntimeEvent: From<Event<Self>>> { }")
.help_link("https://github.com/pezkuwichain/kurdistan-sdk/issues/125")
@@ -449,7 +449,7 @@ impl ConfigDef {
if already_constant {
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"Duplicate #[pallet::constant] attribute not allowed.",
"Duplicate #[pezpallet::constant] attribute not allowed.",
));
}
already_constant = true;
@@ -458,16 +458,16 @@ impl ConfigDef {
(PalletAttrType::Constant(_), _) =>
return Err(syn::Error::new(
trait_item.span(),
"Invalid #[pallet::constant] in #[pallet::config], expected type item",
"Invalid #[pezpallet::constant] in #[pezpallet::config], expected type item",
)),
// Pallet developer has explicitly requested to include metadata for this associated type.
// Pezpallet developer has explicitly requested to include metadata for this associated type.
//
// They must provide a type item that implements `TypeInfo`.
(PalletAttrType::IncludeMetadata(_), syn::TraitItem::Type(ref typ)) => {
if already_collected_associated_type.is_some() {
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"Duplicate #[pallet::include_metadata] attribute not allowed.",
"Duplicate #[pezpallet::include_metadata] attribute not allowed.",
));
}
already_collected_associated_type = Some(pezpallet_attr._bracket.span.join());
@@ -476,20 +476,20 @@ impl ConfigDef {
(PalletAttrType::IncludeMetadata(_), _) =>
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"Invalid #[pallet::include_metadata] in #[pallet::config], expected type item",
"Invalid #[pezpallet::include_metadata] in #[pezpallet::config], expected type item",
)),
(PalletAttrType::NoDefault(_), _) => {
if !enable_default {
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"`#[pallet::no_default]` can only be used if `#[pallet::config(with_default)]` \
"`#[pezpallet::no_default]` can only be used if `#[pezpallet::config(with_default)]` \
has been specified"
));
}
if already_no_default {
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"Duplicate #[pallet::no_default] attribute not allowed.",
"Duplicate #[pezpallet::no_default] attribute not allowed.",
));
}
@@ -499,14 +499,14 @@ impl ConfigDef {
if !enable_default {
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"`#[pallet:no_default_bounds]` can only be used if `#[pallet::config(with_default)]` \
"`#[pezpallet:no_default_bounds]` can only be used if `#[pezpallet::config(with_default)]` \
has been specified"
));
}
if already_no_default_bounds {
return Err(syn::Error::new(
pezpallet_attr._bracket.span.join(),
"Duplicate #[pallet::no_default_bounds] attribute not allowed.",
"Duplicate #[pezpallet::no_default_bounds] attribute not allowed.",
));
}
already_no_default_bounds = true;
@@ -519,7 +519,7 @@ impl ConfigDef {
if is_event {
return Err(syn::Error::new(
span,
"Invalid #[pallet::include_metadata] for `type RuntimeEvent`. \
"Invalid #[pezpallet::include_metadata] for `type RuntimeEvent`. \
The associated type `RuntimeEvent` is already collected in the metadata.",
));
}
@@ -527,15 +527,15 @@ impl ConfigDef {
if already_constant {
return Err(syn::Error::new(
span,
"Invalid #[pallet::include_metadata]: conflict with #[pallet::constant]. \
Pallet constant already collect the metadata for the type.",
"Invalid #[pezpallet::include_metadata]: conflict with #[pezpallet::constant]. \
Pezpallet constant already collect the metadata for the type.",
));
}
if let syn::TraitItem::Type(ref ty) = trait_item {
if !contains_type_info_bound(ty) {
let msg = format!(
"Invalid #[pallet::include_metadata] in #[pallet::config], collected type `{}` \
"Invalid #[pezpallet::include_metadata] in #[pezpallet::config], collected type `{}` \
does not implement `TypeInfo` or `Parameter`",
ty.ident,
);
@@ -587,11 +587,11 @@ impl ConfigDef {
};
let msg = format!(
"Invalid pallet::trait, expected explicit `{}::Config` as supertrait, \
"Invalid pezpallet::trait, expected explicit `{}::Config` as supertrait, \
found {}. \
(try `pub trait Config: pezframe_system::Config {{ ...` or \
`pub trait Config<I: 'static>: pezframe_system::Config {{ ...`). \
To disable this check, use `#[pallet::disable_pezframe_system_supertrait_check]`",
To disable this check, use `#[pezpallet::disable_pezframe_system_supertrait_check]`",
pezframe_system.to_token_stream(),
found,
);
@@ -46,7 +46,7 @@ pub struct VariantDef {
/// This checks error declaration as a enum declaration with only variants without fields nor
/// discriminant.
pub struct ErrorDef {
/// The index of error item in pallet module.
/// The index of error item in pezpallet module.
pub index: usize,
/// Variant definitions.
pub variants: Vec<VariantDef>,
@@ -54,7 +54,7 @@ pub struct ErrorDef {
pub instances: Vec<helper::InstanceUsage>,
/// The keyword error used (contains span).
pub error: keyword::Error,
/// The span of the pallet::error attribute.
/// The span of the pezpallet::error attribute.
pub attr_span: proc_macro2::Span,
}
@@ -67,10 +67,10 @@ impl ErrorDef {
let item = if let syn::Item::Enum(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pallet::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 pallet::error, `Error` must be public";
let msg = "Invalid pezpallet::error, `Error` must be public";
return Err(syn::Error::new(item.span(), msg));
}
@@ -80,7 +80,7 @@ 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 pallet::error, where clause is not allowed on pallet 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));
}
@@ -100,7 +100,7 @@ impl ErrorDef {
None |
Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
Some((_, expr)) => {
let msg = "Invalid pallet::error, only integer discriminants are supported";
let msg = "Invalid pezpallet::error, only integer discriminants are supported";
return Err(syn::Error::new(expr.span(), msg));
},
}
@@ -22,14 +22,14 @@ use syn::spanned::Spanned;
/// List of additional token to be used for parsing.
mod keyword {
syn::custom_keyword!(Event);
syn::custom_keyword!(pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(generate_deposit);
syn::custom_keyword!(deposit_event);
}
/// Definition for pallet event enum.
/// Definition for pezpallet event enum.
pub struct EventDef {
/// The index of event item in pallet module.
/// The index of event item in pezpallet module.
pub index: usize,
/// The keyword Event used (contains span).
pub event: keyword::Event,
@@ -41,14 +41,14 @@ pub struct EventDef {
pub deposit_event: Option<PalletEventDepositAttr>,
/// Where clause used in event definition.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::event attribute.
/// The span of the pezpallet::event attribute.
pub attr_span: proc_macro2::Span,
}
/// Attribute for a pallet's Event.
/// Attribute for a pezpallet's Event.
///
/// Syntax is:
/// * `#[pallet::generate_deposit($vis fn deposit_event)]`
/// * `#[pezpallet::generate_deposit($vis fn deposit_event)]`
pub struct PalletEventDepositAttr {
pub fn_vis: syn::Visibility,
// Span for the keyword deposit_event
@@ -62,7 +62,7 @@ impl syn::parse::Parse for PalletEventDepositAttr {
input.parse::<syn::Token![#]>()?;
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
let span = content.parse::<keyword::generate_deposit>()?.span();
@@ -104,7 +104,7 @@ impl EventDef {
let item = if let syn::Item::Enum(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pallet::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)?;
@@ -115,7 +115,7 @@ impl EventDef {
let deposit_event = attr_info.deposit_event;
if !matches!(item.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::event, `Event` must be public";
let msg = "Invalid pezpallet::event, `Event` must be public";
return Err(syn::Error::new(item.span(), msg));
}
@@ -127,7 +127,7 @@ impl EventDef {
if let Some(u) = helper::check_type_def_optional_gen(&item.generics, item.ident.span())? {
instances.push(u);
} else {
// construct_runtime only allow non generic event for non instantiable pallet.
// construct_runtime only allow non generic event for non instantiable pezpallet.
instances.push(helper::InstanceUsage { has_instance: false, span: item.ident.span() })
}
@@ -27,11 +27,11 @@ mod keyword {
syn::custom_keyword!(weight);
syn::custom_keyword!(compact);
syn::custom_keyword!(T);
syn::custom_keyword!(pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(constant_name);
}
/// Definition of extra constants typically `impl<T: Config> Pallet<T> { ... }`
/// Definition of extra constants typically `impl<T: Config> Pezpallet<T> { ... }`
pub struct ExtraConstantsDef {
/// The where_clause used.
pub where_clause: Option<syn::WhereClause>,
@@ -41,7 +41,7 @@ pub struct ExtraConstantsDef {
pub extra_constants: Vec<ExtraConstantDef>,
}
/// Input definition for an constant in pallet.
/// Input definition for an constant in pezpallet.
pub struct ExtraConstantDef {
/// Name of the function
pub ident: syn::Ident,
@@ -56,7 +56,7 @@ pub struct ExtraConstantDef {
}
/// Attributes for functions in extra_constants impl block.
/// Parse for `#[pallet::constant_name(ConstantName)]`
/// Parse for `#[pezpallet::constant_name(ConstantName)]`
pub struct ExtraConstAttr {
metadata_name: syn::Ident,
}
@@ -66,7 +66,7 @@ impl syn::parse::Parse for ExtraConstAttr {
input.parse::<syn::Token![#]>()?;
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
content.parse::<keyword::constant_name>()?;
@@ -83,7 +83,7 @@ impl ExtraConstantsDef {
} else {
return Err(syn::Error::new(
item.span(),
"Invalid pallet::extra_constants, expected item impl",
"Invalid pezpallet::extra_constants, expected item impl",
));
};
@@ -93,8 +93,8 @@ impl ExtraConstantsDef {
];
if let Some((_, _, for_)) = item.trait_ {
let msg = "Invalid pallet::call, expected no trait ident as in \
`impl<..> Pallet<..> { .. }`";
let msg = "Invalid pezpallet::call, expected no trait ident as in \
`impl<..> Pezpallet<..> { .. }`";
return Err(syn::Error::new(for_.span(), msg));
}
@@ -103,28 +103,28 @@ impl ExtraConstantsDef {
let method = if let syn::ImplItem::Fn(method) = impl_item {
method
} else {
let msg = "Invalid pallet::call, only method accepted";
let msg = "Invalid pezpallet::call, only method accepted";
return Err(syn::Error::new(impl_item.span(), msg));
};
if !method.sig.inputs.is_empty() {
let msg = "Invalid pallet::extra_constants, method must have 0 args";
let msg = "Invalid pezpallet::extra_constants, method must have 0 args";
return Err(syn::Error::new(method.sig.span(), msg));
}
if !method.sig.generics.params.is_empty() {
let msg = "Invalid pallet::extra_constants, method must have 0 generics";
let msg = "Invalid pezpallet::extra_constants, method must have 0 generics";
return Err(syn::Error::new(method.sig.generics.params[0].span(), msg));
}
if method.sig.generics.where_clause.is_some() {
let msg = "Invalid pallet::extra_constants, method must have no where clause";
let msg = "Invalid pezpallet::extra_constants, method must have no where clause";
return Err(syn::Error::new(method.sig.generics.where_clause.span(), msg));
}
let type_ = match &method.sig.output {
syn::ReturnType::Default => {
let msg = "Invalid pallet::extra_constants, method must have a return type";
let msg = "Invalid pezpallet::extra_constants, method must have a return type";
return Err(syn::Error::new(method.span(), msg));
},
syn::ReturnType::Type(_, type_) => *type_.clone(),
@@ -136,7 +136,7 @@ impl ExtraConstantsDef {
if extra_constant_attrs.len() > 1 {
let msg =
"Invalid attribute in pallet::constant_name, only one attribute is expected";
"Invalid attribute in pezpallet::constant_name, only one attribute is expected";
return Err(syn::Error::new(extra_constant_attrs[1].metadata_name.span(), msg));
}
@@ -18,13 +18,13 @@
use super::helper;
use syn::spanned::Spanned;
/// Definition for pallet genesis build implementation.
/// Definition for pezpallet genesis build implementation.
pub struct GenesisBuildDef {
/// A set of usage of instance, must be check for consistency with trait.
pub instances: Option<Vec<helper::InstanceUsage>>,
/// The where_clause used.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::genesis_build attribute.
/// The span of the pezpallet::genesis_build attribute.
pub attr_span: proc_macro2::Span,
}
@@ -33,7 +33,7 @@ impl GenesisBuildDef {
let item = if let syn::Item::Impl(item) = item {
item
} else {
let msg = "Invalid pallet::genesis_build, expected item impl";
let msg = "Invalid pezpallet::genesis_build, expected item impl";
return Err(syn::Error::new(item.span(), msg));
};
@@ -41,7 +41,7 @@ impl GenesisBuildDef {
.trait_
.as_ref()
.ok_or_else(|| {
let msg = "Invalid pallet::genesis_build, expected impl<..> GenesisBuild<..> \
let msg = "Invalid pezpallet::genesis_build, expected impl<..> GenesisBuild<..> \
for GenesisConfig<..>";
syn::Error::new(item.span(), msg)
})?
@@ -18,13 +18,13 @@
use super::helper;
use syn::spanned::Spanned;
/// Definition for pallet genesis config type.
/// Definition for pezpallet genesis config type.
///
/// Either:
/// * `struct GenesisConfig`
/// * `enum GenesisConfig`
pub struct GenesisConfigDef {
/// The index of item in pallet module.
/// The index of item in pezpallet module.
pub index: usize,
/// The kind of generic the type `GenesisConfig` has.
pub gen_kind: super::GenericKind,
@@ -41,7 +41,7 @@ impl GenesisConfigDef {
syn::Item::Enum(item) => (&item.vis, &item.ident, &item.generics),
syn::Item::Struct(item) => (&item.vis, &item.ident, &item.generics),
_ => {
let msg = "Invalid pallet::genesis_config, expected enum or struct";
let msg = "Invalid pezpallet::genesis_config, expected enum or struct";
return Err(syn::Error::new(item.span(), msg));
},
};
@@ -59,12 +59,12 @@ impl GenesisConfigDef {
.expect("Checked by `helper::check_type_def_optional_gen` above");
if !matches!(vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::genesis_config, GenesisConfig must be public";
let msg = "Invalid pezpallet::genesis_config, GenesisConfig must be public";
return Err(syn::Error::new(item_span, msg));
}
if ident != "GenesisConfig" {
let msg = "Invalid pallet::genesis_config, ident must `GenesisConfig`";
let msg = "Invalid pezpallet::genesis_config, ident must `GenesisConfig`";
return Err(syn::Error::new(ident.span(), msg));
}
@@ -27,7 +27,7 @@ mod keyword {
syn::custom_keyword!(BuildGenesisConfig);
syn::custom_keyword!(Config);
syn::custom_keyword!(T);
syn::custom_keyword!(Pallet);
syn::custom_keyword!(Pezpallet);
syn::custom_keyword!(origin);
syn::custom_keyword!(DispatchResult);
syn::custom_keyword!(DispatchResultWithPostInfo);
@@ -48,7 +48,7 @@ pub trait MutItemAttrs {
fn mut_item_attrs(&mut self) -> Option<&mut Vec<syn::Attribute>>;
}
/// Take the first pallet attribute (e.g. attribute like `#[pallet..]`) 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 +58,7 @@ 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 == "pallet")
attr.path().segments.first().map_or(false, |segment| segment.ident == "pezpallet")
}) else {
return Ok(None);
};
@@ -67,7 +67,7 @@ where
Ok(Some(syn::parse2(pezpallet_attr.into_token_stream())?))
}
/// Take all the pallet attributes (e.g. attribute like `#[pallet..]`) 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,
@@ -337,18 +337,18 @@ pub fn check_type_def_optional_gen(
}
/// Check the syntax:
/// * either `Pallet<T>`
/// * or `Pallet<T, I>`
/// * either `Pezpallet<T>`
/// * or `Pezpallet<T, I>`
///
/// return the instance if found.
pub fn check_pallet_struct_usage(type_: &Box<syn::Type>) -> syn::Result<InstanceUsage> {
let expected = "expected `Pallet<T>` or `Pallet<T, I>`";
let expected = "expected `Pezpallet<T>` or `Pezpallet<T, I>`";
pub struct Checker(InstanceUsage);
impl syn::parse::Parse for Checker {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
let mut instance_usage = InstanceUsage { span: input.span(), has_instance: false };
input.parse::<keyword::Pallet>()?;
input.parse::<keyword::Pezpallet>()?;
input.parse::<syn::Token![<]>()?;
input.parse::<keyword::T>()?;
if input.peek(syn::Token![,]) {
@@ -364,7 +364,7 @@ pub fn check_pallet_struct_usage(type_: &Box<syn::Type>) -> syn::Result<Instance
let i = syn::parse2::<Checker>(type_.to_token_stream())
.map_err(|e| {
let msg = format!("Invalid pallet struct: {}", expected);
let msg = format!("Invalid pezpallet struct: {}", expected);
let mut err = syn::Error::new(type_.span(), msg);
err.combine(e);
err
@@ -607,7 +607,7 @@ pub enum CallReturnType {
/// Check the keyword `DispatchResultWithPostInfo` or `DispatchResult`.
pub fn check_pallet_call_return_type(sig: &syn::Signature) -> syn::Result<CallReturnType> {
let syn::ReturnType::Type(_, type_) = &sig.output else {
let msg = "Invalid pallet::call, require return type \
let msg = "Invalid pezpallet::call, require return type \
DispatchResultWithPostInfo";
return Err(syn::Error::new(sig.span(), msg));
};
@@ -18,13 +18,13 @@
use super::helper;
use syn::spanned::Spanned;
/// Implementation of the pallet hooks.
/// Implementation of the pezpallet hooks.
pub struct HooksDef {
/// A set of usage of instance, must be check for consistency with trait.
pub instances: Vec<helper::InstanceUsage>,
/// The where_clause used.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::hooks attribute.
/// The span of the pezpallet::hooks attribute.
pub attr_span: proc_macro2::Span,
/// Boolean flag, set to true if the `on_runtime_upgrade` method of hooks was implemented.
pub has_runtime_upgrade: bool,
@@ -35,7 +35,7 @@ impl HooksDef {
let item = if let syn::Item::Impl(item) = item {
item
} else {
let msg = "Invalid pallet::hooks, expected item impl";
let msg = "Invalid pezpallet::hooks, expected item impl";
return Err(syn::Error::new(item.span(), msg));
};
@@ -48,15 +48,15 @@ impl HooksDef {
.trait_
.as_ref()
.ok_or_else(|| {
let msg = "Invalid pallet::hooks, expected impl<..> Hooks \
for Pallet<..>";
let msg = "Invalid pezpallet::hooks, expected impl<..> Hooks \
for Pezpallet<..>";
syn::Error::new(item.span(), msg)
})?
.1;
if item_trait.segments.len() != 1 || item_trait.segments[0].ident != "Hooks" {
let msg = format!(
"Invalid pallet::hooks, expected trait to be `Hooks` found `{}`\
"Invalid pezpallet::hooks, expected trait to be `Hooks` found `{}`\
, you can import from `pezframe_support::pezpallet_prelude`",
quote::quote!(#item_trait)
);
@@ -18,7 +18,7 @@
use super::helper;
use syn::spanned::Spanned;
/// The definition of the pallet inherent implementation.
/// The definition of the pezpallet inherent implementation.
pub struct InherentDef {
/// A set of usage of instance, must be check for consistency with trait.
pub instances: Vec<helper::InstanceUsage>,
@@ -29,22 +29,22 @@ impl InherentDef {
let item = if let syn::Item::Impl(item) = item {
item
} else {
let msg = "Invalid pallet::inherent, expected item impl";
let msg = "Invalid pezpallet::inherent, expected item impl";
return Err(syn::Error::new(item.span(), msg));
};
if item.trait_.is_none() {
let msg = "Invalid pallet::inherent, expected impl<..> ProvideInherent for Pallet<..>";
let msg = "Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
if let Some(last) = item.trait_.as_ref().unwrap().1.segments.last() {
if last.ident != "ProvideInherent" {
let msg = "Invalid pallet::inherent, expected trait ProvideInherent";
let msg = "Invalid pezpallet::inherent, expected trait ProvideInherent";
return Err(syn::Error::new(last.span(), msg));
}
} else {
let msg = "Invalid pallet::inherent, expected impl<..> ProvideInherent for Pallet<..>";
let msg = "Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Parse for pallet macro.
//! Parse for pezpallet macro.
//!
//! Parse the module into `Def` struct through `Def::try_from` function.
@@ -46,7 +46,7 @@ use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
use quote::ToTokens;
use syn::spanned::Spanned;
/// Parsed definition of a pallet.
/// Parsed definition of a pezpallet.
pub struct Def {
/// The module items.
/// (their order must not be modified because they are registered in individual definitions).
@@ -84,7 +84,7 @@ impl Def {
.content
.as_mut()
.ok_or_else(|| {
let msg = "Invalid pallet definition, expected mod to be inlined.";
let msg = "Invalid pezpallet definition, expected mod to be inlined.";
syn::Error::new(item_span, msg)
})?
.1;
@@ -124,7 +124,7 @@ impl Def {
is_pezframe_system,
)?);
},
Some(PalletAttr::Pallet(span)) if pezpallet_struct.is_none() => {
Some(PalletAttr::Pezpallet(span)) if pezpallet_struct.is_none() => {
let p = pezpallet_struct::PalletStructDef::try_from(span, index, item)?;
pezpallet_struct = Some(p);
},
@@ -139,7 +139,7 @@ impl Def {
// `TasksDef::parse` needs to know if attr was provided so we artificially
// re-insert it here
tasks = Some(syn::parse2::<tasks::TasksDef>(quote::quote_spanned! { span =>
#[pallet::tasks_experimental]
#[pezpallet::tasks_experimental]
#item_tokens
})?);
@@ -148,15 +148,15 @@ impl Def {
}
Some(PalletAttr::TaskCondition(span)) => return Err(syn::Error::new(
span,
"`#[pallet::task_condition]` can only be used on items within an `impl` statement."
"`#[pezpallet::task_condition]` can only be used on items within an `impl` statement."
)),
Some(PalletAttr::TaskIndex(span)) => return Err(syn::Error::new(
span,
"`#[pallet::task_index]` can only be used on items within an `impl` statement."
"`#[pezpallet::task_index]` can only be used on items within an `impl` statement."
)),
Some(PalletAttr::TaskList(span)) => return Err(syn::Error::new(
span,
"`#[pallet::task_list]` can only be used on items within an `impl` statement."
"`#[pezpallet::task_list]` can only be used on items within an `impl` statement."
)),
Some(PalletAttr::RuntimeTask(_)) if task_enum.is_none() =>
task_enum = Some(syn::parse2::<tasks::TaskEnumDef>(item.to_token_stream())?),
@@ -226,7 +226,7 @@ impl Def {
if genesis_config.is_some() != genesis_build.is_some() {
let msg = format!(
"`#[pallet::genesis_config]` and `#[pallet::genesis_build]` attributes must be \
"`#[pezpallet::genesis_config]` and `#[pezpallet::genesis_build]` attributes must be \
either both used or both not used, instead genesis_config is {} and genesis_build \
is {}",
genesis_config.as_ref().map_or("unused", |_| "used"),
@@ -240,9 +240,9 @@ impl Def {
let def = Def {
item,
config: config
.ok_or_else(|| syn::Error::new(item_span, "Missing `#[pallet::config]`"))?,
.ok_or_else(|| syn::Error::new(item_span, "Missing `#[pezpallet::config]`"))?,
pezpallet_struct: pezpallet_struct
.ok_or_else(|| syn::Error::new(item_span, "Missing `#[pallet::pallet]`"))?,
.ok_or_else(|| syn::Error::new(item_span, "Missing `#[pezpallet::pezpallet]`"))?,
hooks,
call,
tasks,
@@ -270,7 +270,7 @@ impl Def {
Ok(def)
}
/// Performs extra logic checks necessary for the `#[pallet::tasks_experimental]` feature.
/// Performs extra logic checks necessary for the `#[pezpallet::tasks_experimental]` feature.
fn resolve_tasks(
item_span: &proc_macro2::Span,
tasks: &mut Option<tasks::TasksDef>,
@@ -288,13 +288,13 @@ impl Def {
(Some(_), None) =>
return Err(syn::Error::new(
*item_span,
"Missing `#[pallet::tasks_experimental]` impl",
"Missing `#[pezpallet::tasks_experimental]` impl",
)),
(None, Some(tasks)) =>
if tasks.tasks_attr.is_none() {
return Err(syn::Error::new(
tasks.item_impl.impl_token.span(),
"A `#[pallet::tasks_experimental]` attribute must be attached to your `Task` impl if the \
"A `#[pezpallet::tasks_experimental]` attribute must be attached to your `Task` impl if the \
task enum has been omitted",
));
} else {
@@ -423,7 +423,7 @@ impl Def {
}
}
/// Depending on if pallet is instantiable:
/// Depending on if pezpallet is instantiable:
/// * either `T: Config`
/// * or `T: Config<I>, I: 'static`
pub fn type_impl_generics(&self, span: proc_macro2::Span) -> proc_macro2::TokenStream {
@@ -434,7 +434,7 @@ impl Def {
}
}
/// Depending on if pallet is instantiable:
/// Depending on if pezpallet is instantiable:
/// * either `T: Config`
/// * or `T: Config<I>, I: 'static = ()`
pub fn type_decl_bounded_generics(&self, span: proc_macro2::Span) -> proc_macro2::TokenStream {
@@ -445,7 +445,7 @@ impl Def {
}
}
/// Depending on if pallet is instantiable:
/// Depending on if pezpallet is instantiable:
/// * either `T`
/// * or `T, I = ()`
pub fn type_decl_generics(&self, span: proc_macro2::Span) -> proc_macro2::TokenStream {
@@ -456,10 +456,10 @@ impl Def {
}
}
/// Depending on if pallet is instantiable:
/// Depending on if pezpallet is instantiable:
/// * either ``
/// * or `<I>`
/// to be used when using pallet trait `Config`
/// to be used when using pezpallet trait `Config`
pub fn trait_use_generics(&self, span: proc_macro2::Span) -> proc_macro2::TokenStream {
if self.config.has_instance {
quote::quote_spanned!(span => <I>)
@@ -468,7 +468,7 @@ impl Def {
}
}
/// Depending on if pallet is instantiable:
/// Depending on if pezpallet is instantiable:
/// * either `T`
/// * or `T, I`
pub fn type_use_generics(&self, span: proc_macro2::Span) -> proc_macro2::TokenStream {
@@ -553,20 +553,20 @@ mod keyword {
syn::custom_keyword!(genesis_config);
syn::custom_keyword!(validate_unsigned);
syn::custom_keyword!(type_value);
syn::custom_keyword!(pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(extra_constants);
syn::custom_keyword!(composite_enum);
syn::custom_keyword!(view_functions);
}
/// The possible values for the `#[pallet::config]` attribute.
/// The possible values for the `#[pezpallet::config]` attribute.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum ConfigValue {
/// `#[pallet::config(with_default)]`
/// `#[pezpallet::config(with_default)]`
WithDefault(keyword::with_default),
/// `#[pallet::config(without_automatic_metadata)]`
/// `#[pezpallet::config(without_automatic_metadata)]`
WithoutAutomaticMetadata(keyword::without_automatic_metadata),
/// `#[pallet::config(pezframe_system_config)]`
/// `#[pezpallet::config(pezframe_system_config)]`
FrameSystemConfig(keyword::pezframe_system_config),
}
@@ -586,8 +586,8 @@ impl syn::parse::Parse for ConfigValue {
}
}
/// Parse attributes for item in pallet module
/// syntax must be `pallet::` (e.g. `#[pallet::config]`)
/// Parse attributes for item in pezpallet module
/// syntax must be `pezpallet::` (e.g. `#[pezpallet::config]`)
enum PalletAttr {
Config {
span: proc_macro2::Span,
@@ -595,34 +595,34 @@ enum PalletAttr {
without_automatic_metadata: bool,
pezframe_system_config: bool,
},
Pallet(proc_macro2::Span),
Pezpallet(proc_macro2::Span),
Hooks(proc_macro2::Span),
/// A `#[pallet::call]` with optional attributes to specialize the behaviour.
/// A `#[pezpallet::call]` with optional attributes to specialize the behaviour.
///
/// # Attributes
///
/// Each attribute `attr` can take the form of `#[pallet::call(attr = …)]` or
/// `#[pallet::call(attr(…))]`. The possible attributes are:
/// Each attribute `attr` can take the form of `#[pezpallet::call(attr = …)]` or
/// `#[pezpallet::call(attr(…))]`. The possible attributes are:
///
/// ## `weight`
///
/// 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 `#[pallet::weight]` but can instead use the
/// one from the `#[pallet::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
/// #[pallet::call]
/// impl<T: Config> Pallet<T> {
/// #[pallet::weight(T::WeightInfo::create())]
/// #[pezpallet::call]
/// impl<T: Config> Pezpallet<T> {
/// #[pezpallet::weight(T::WeightInfo::create())]
/// pub fn create(
/// ```
/// you can now omit it on the call itself, if the name of the weigh function matches the call:
///
/// ```ignore
/// #[pallet::call(weight = <T as crate::Config>::WeightInfo)]
/// impl<T: Config> Pallet<T> {
/// #[pezpallet::call(weight = <T as crate::Config>::WeightInfo)]
/// impl<T: Config> Pezpallet<T> {
/// pub fn create(
/// ```
///
@@ -631,8 +631,8 @@ enum PalletAttr {
///
/// ### Dev Mode
///
/// Normally the `dev_mode` sets all weights of calls without a `#[pallet::weight]` annotation
/// to zero. Now when there is a `weight` attribute on the `#[pallet::call]`, then that is used
/// 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),
@@ -658,7 +658,7 @@ impl PalletAttr {
fn span(&self) -> proc_macro2::Span {
match self {
Self::Config { span, .. } => *span,
Self::Pallet(span) => *span,
Self::Pezpallet(span) => *span,
Self::Hooks(span) => *span,
Self::Tasks(span) => *span,
Self::TaskCondition(span) => *span,
@@ -687,7 +687,7 @@ impl syn::parse::Parse for PalletAttr {
input.parse::<syn::Token![#]>()?;
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
let lookahead = content.lookahead1();
@@ -712,7 +712,7 @@ impl syn::parse::Parse for PalletAttr {
if with_default {
return Err(syn::Error::new(
span,
"Invalid duplicated attribute for `#[pallet::config]`. Please remove duplicates: with_default.",
"Invalid duplicated attribute for `#[pezpallet::config]`. Please remove duplicates: with_default.",
));
}
with_default = true;
@@ -721,7 +721,7 @@ impl syn::parse::Parse for PalletAttr {
if without_automatic_metadata {
return Err(syn::Error::new(
span,
"Invalid duplicated attribute for `#[pallet::config]`. Please remove duplicates: without_automatic_metadata.",
"Invalid duplicated attribute for `#[pezpallet::config]`. Please remove duplicates: without_automatic_metadata.",
));
}
without_automatic_metadata = true;
@@ -730,7 +730,7 @@ impl syn::parse::Parse for PalletAttr {
if pezframe_system_config {
return Err(syn::Error::new(
span,
"Invalid duplicated attribute for `#[pallet::config]`. Please remove duplicates: pezframe_system_config.",
"Invalid duplicated attribute for `#[pezpallet::config]`. Please remove duplicates: pezframe_system_config.",
));
}
pezframe_system_config = true;
@@ -752,8 +752,8 @@ impl syn::parse::Parse for PalletAttr {
pezframe_system_config: false,
})
}
} else if lookahead.peek(keyword::pallet) {
Ok(PalletAttr::Pallet(content.parse::<keyword::pallet>()?.span()))
} else if lookahead.peek(keyword::pezpallet) {
Ok(PalletAttr::Pezpallet(content.parse::<keyword::pezpallet>()?.span()))
} else if lookahead.peek(keyword::hooks) {
Ok(PalletAttr::Hooks(content.parse::<keyword::hooks>()?.span()))
} else if lookahead.peek(keyword::call) {
@@ -803,7 +803,7 @@ impl syn::parse::Parse for PalletAttr {
}
}
/// The optional weight annotation on a `#[pallet::call]` like `#[pallet::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,
@@ -18,7 +18,7 @@
use super::helper;
use syn::spanned::Spanned;
/// Definition of the pallet origin type.
/// Definition of the pezpallet origin type.
///
/// Either:
/// * `type Origin`
@@ -38,7 +38,7 @@ impl OriginDef {
syn::Item::Struct(item) => (&item.vis, &item.ident, &item.generics),
syn::Item::Type(item) => (&item.vis, &item.ident, &item.generics),
_ => {
let msg = "Invalid pallet::origin, expected enum or struct or type";
let msg = "Invalid pezpallet::origin, expected enum or struct or type";
return Err(syn::Error::new(item.span(), msg));
},
};
@@ -49,17 +49,17 @@ impl OriginDef {
if let Some(u) = helper::check_type_def_optional_gen(generics, item.span())? {
instances.push(u);
} else {
// construct_runtime only allow generic event for instantiable pallet.
// construct_runtime only allow generic event for instantiable pezpallet.
instances.push(helper::InstanceUsage { has_instance: false, span: ident.span() })
}
if !matches!(vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::origin, Origin must be public";
let msg = "Invalid pezpallet::origin, Origin must be public";
return Err(syn::Error::new(item_span, msg));
}
if ident != "Origin" {
let msg = "Invalid pallet::origin, ident must `Origin`";
let msg = "Invalid pezpallet::origin, ident must `Origin`";
return Err(syn::Error::new(ident.span(), msg));
}
@@ -21,32 +21,32 @@ use syn::spanned::Spanned;
/// List of additional token to be used for parsing.
mod keyword {
syn::custom_keyword!(pallet);
syn::custom_keyword!(Pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(Pezpallet);
syn::custom_keyword!(without_storage_info);
syn::custom_keyword!(storage_version);
}
/// Definition of the pallet pallet.
/// Definition of the pezpallet pezpallet.
pub struct PalletStructDef {
/// The index of item in pallet pallet.
/// The index of item in pezpallet pezpallet.
pub index: usize,
/// A set of usage of instance, must be check for consistency with config trait.
pub instances: Vec<helper::InstanceUsage>,
/// The keyword Pallet used (contains span).
pub pallet: keyword::Pallet,
/// The span of the pallet::pallet attribute.
/// The keyword Pezpallet used (contains span).
pub pezpallet: keyword::Pezpallet,
/// The span of the pezpallet::pezpallet attribute.
pub attr_span: proc_macro2::Span,
/// Whether to specify the storages max encoded len when implementing `StorageInfoTrait`.
/// Contains the span of the attribute.
pub without_storage_info: Option<proc_macro2::Span>,
/// The in-code storage version of the pallet.
/// The in-code storage version of the pezpallet.
pub storage_version: Option<syn::Path>,
}
/// Parse for one variant of:
/// * `#[pallet::without_storage_info]`
/// * `#[pallet::storage_version(STORAGE_VERSION)]`
/// * `#[pezpallet::without_storage_info]`
/// * `#[pezpallet::storage_version(STORAGE_VERSION)]`
pub enum PalletStructAttr {
WithoutStorageInfoTrait(proc_macro2::Span),
StorageVersion { storage_version: syn::Path, span: proc_macro2::Span },
@@ -65,7 +65,7 @@ impl syn::parse::Parse for PalletStructAttr {
input.parse::<syn::Token![#]>()?;
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
let lookahead = content.lookahead1();
@@ -95,7 +95,7 @@ impl PalletStructDef {
let item = if let syn::Item::Struct(item) = item {
item
} else {
let msg = "Invalid pallet::pallet, expected struct definition";
let msg = "Invalid pezpallet::pezpallet, expected struct definition";
return Err(syn::Error::new(item.span(), msg));
};
@@ -122,15 +122,15 @@ impl PalletStructDef {
}
}
let pallet = syn::parse2::<keyword::Pallet>(item.ident.to_token_stream())?;
let pezpallet = syn::parse2::<keyword::Pezpallet>(item.ident.to_token_stream())?;
if !matches!(item.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::pallet, Pallet must be public";
let msg = "Invalid pezpallet::pezpallet, Pezpallet must be public";
return Err(syn::Error::new(item.span(), msg));
}
if item.generics.where_clause.is_some() {
let msg = "Invalid pallet::pallet, where clause not supported on Pallet declaration";
let msg = "Invalid pezpallet::pezpallet, where clause not supported on Pezpallet declaration";
return Err(syn::Error::new(item.generics.where_clause.span(), msg));
}
@@ -140,7 +140,7 @@ impl PalletStructDef {
Ok(Self {
index,
instances,
pallet,
pezpallet,
attr_span,
without_storage_info,
storage_version: storage_version_found,
@@ -24,7 +24,7 @@ use syn::spanned::Spanned;
/// List of additional token to be used for parsing.
mod keyword {
syn::custom_keyword!(Error);
syn::custom_keyword!(pallet);
syn::custom_keyword!(pezpallet);
syn::custom_keyword!(getter);
syn::custom_keyword!(storage_prefix);
syn::custom_keyword!(unbounded);
@@ -36,11 +36,11 @@ mod keyword {
}
/// Parse for one of the following:
/// * `#[pallet::getter(fn dummy)]`
/// * `#[pallet::storage_prefix = "CustomName"]`
/// * `#[pallet::unbounded]`
/// * `#[pallet::whitelist_storage]
/// * `#[pallet::disable_try_decode_storage]`
/// * `#[pezpallet::getter(fn dummy)]`
/// * `#[pezpallet::storage_prefix = "CustomName"]`
/// * `#[pezpallet::unbounded]`
/// * `#[pezpallet::whitelist_storage]
/// * `#[pezpallet::disable_try_decode_storage]`
pub enum PalletStorageAttr {
Getter(syn::Ident, proc_macro2::Span),
StorageName(syn::LitStr, proc_macro2::Span),
@@ -67,7 +67,7 @@ impl syn::parse::Parse for PalletStorageAttr {
let attr_span = input.span();
let content;
syn::bracketed!(content in input);
content.parse::<keyword::pallet>()?;
content.parse::<keyword::pezpallet>()?;
content.parse::<syn::Token![::]>()?;
let lookahead = content.lookahead1();
@@ -168,7 +168,7 @@ pub enum QueryKind {
/// `type MyStorage = StorageValue<MyStorageP, u32>`
/// The keys and values types are parsed in order to get metadata
pub struct StorageDef {
/// The index of storage item in pallet module.
/// The index of storage item in pezpallet module.
pub index: usize,
/// Visibility of the storage type.
pub vis: syn::Visibility,
@@ -191,7 +191,7 @@ pub struct StorageDef {
pub query_kind: Option<QueryKind>,
/// Where clause of type definition.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::storage attribute.
/// The span of the pezpallet::storage attribute.
pub attr_span: proc_macro2::Span,
/// The `cfg` attributes.
pub cfg_attrs: Vec<syn::Attribute>,
@@ -332,7 +332,7 @@ fn check_generics(
!optional_generics.contains(&gen_name.as_str())
{
let msg = format!(
"Invalid pallet::storage, Unexpected generic `{}` for `{}`. {}",
"Invalid pezpallet::storage, Unexpected generic `{}` for `{}`. {}",
gen_name, storage_type_name, expectation,
);
errors.push(syn::Error::new(gen_binding.span(), msg));
@@ -342,7 +342,7 @@ fn check_generics(
for mandatory_generic in mandatory_generics {
if !map.contains_key(&mandatory_generic.to_string()) {
let msg = format!(
"Invalid pallet::storage, cannot find `{}` generic, required for `{}`.",
"Invalid pezpallet::storage, cannot find `{}` generic, required for `{}`.",
mandatory_generic, storage_type_name
);
errors.push(syn::Error::new(args_span, msg));
@@ -372,7 +372,7 @@ fn process_named_generics(
// Ensure no duplicate.
for arg in args {
if let Some(other) = parsed.get(&arg.ident.to_string()) {
let msg = "Invalid pallet::storage, Duplicated named generic";
let msg = "Invalid pezpallet::storage, Duplicated named generic";
let mut err = syn::Error::new(arg.ident.span(), msg);
err.combine(syn::Error::new(other.ident.span(), msg));
return Err(err);
@@ -567,7 +567,7 @@ fn process_unnamed_generics(
let retrieve_arg = |arg_pos| {
args.get(arg_pos).cloned().ok_or_else(|| {
let msg = format!(
"Invalid pallet::storage, unexpected number of generic argument, \
"Invalid pezpallet::storage, unexpected number of generic argument, \
expect at least {} args, found {}.",
arg_pos + 1,
args.len(),
@@ -578,7 +578,7 @@ fn process_unnamed_generics(
let prefix_arg = retrieve_arg(0)?;
syn::parse2::<syn::Token![_]>(prefix_arg.to_token_stream()).map_err(|e| {
let msg = "Invalid pallet::storage, for unnamed generic arguments the type \
let msg = "Invalid pezpallet::storage, for unnamed generic arguments the type \
first generic argument must be `_`, the argument is then replaced by macro.";
let mut err = syn::Error::new(prefix_arg.span(), msg);
err.combine(e);
@@ -663,7 +663,7 @@ fn process_generics(
"CountedStorageNMap" => StorageKind::CountedNMap,
found => {
let msg = format!(
"Invalid pallet::storage, expected ident: `StorageValue` or \
"Invalid pezpallet::storage, expected ident: `StorageValue` or \
`StorageMap` or `CountedStorageMap` or `StorageDoubleMap` or `StorageNMap` or `CountedStorageNMap` \
in order to expand metadata, found `{}`.",
found,
@@ -677,7 +677,7 @@ fn process_generics(
let args = match &segment.arguments {
syn::PathArguments::AngleBracketed(args) if !args.args.is_empty() => args,
_ => {
let msg = "Invalid pallet::storage, invalid number of generic generic arguments, \
let msg = "Invalid pezpallet::storage, invalid number of generic generic arguments, \
expect more that 0 generic arguments.";
return Err(syn::Error::new(segment.span(), msg));
},
@@ -704,7 +704,7 @@ fn process_generics(
.collect::<Vec<_>>();
process_named_generics(&storage_kind, args_span, &args, dev_mode)
} else {
let msg = "Invalid pallet::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))
@@ -725,29 +725,29 @@ fn extract_key(ty: &syn::Type) -> syn::Result<syn::Type> {
let typ = if let syn::Type::Path(typ) = ty {
typ
} else {
let msg = "Invalid pallet::storage, expected type path";
let msg = "Invalid pezpallet::storage, expected type path";
return Err(syn::Error::new(ty.span(), msg));
};
let key_struct = typ.path.segments.last().ok_or_else(|| {
let msg = "Invalid pallet::storage, expected type path with at least one segment";
let msg = "Invalid pezpallet::storage, expected type path with at least one segment";
syn::Error::new(typ.path.span(), msg)
})?;
if key_struct.ident != "Key" && key_struct.ident != "NMapKey" {
let msg = "Invalid pallet::storage, expected Key or NMapKey struct";
let msg = "Invalid pezpallet::storage, expected Key or NMapKey struct";
return Err(syn::Error::new(key_struct.ident.span(), msg));
}
let ty_params = if let syn::PathArguments::AngleBracketed(args) = &key_struct.arguments {
args
} else {
let msg = "Invalid pallet::storage, expected angle bracketed arguments";
let msg = "Invalid pezpallet::storage, expected angle bracketed arguments";
return Err(syn::Error::new(key_struct.arguments.span(), msg));
};
if ty_params.args.len() != 2 {
let msg = format!(
"Invalid pallet::storage, unexpected number of generic arguments \
"Invalid pezpallet::storage, unexpected number of generic arguments \
for Key struct, expected 2 args, found {}",
ty_params.args.len()
);
@@ -757,7 +757,7 @@ fn extract_key(ty: &syn::Type) -> syn::Result<syn::Type> {
let key = match &ty_params.args[1] {
syn::GenericArgument::Type(key_ty) => key_ty.clone(),
_ => {
let msg = "Invalid pallet::storage, expected type";
let msg = "Invalid pezpallet::storage, expected type";
return Err(syn::Error::new(ty_params.args[1].span(), msg));
},
};
@@ -792,7 +792,7 @@ impl StorageDef {
let item = if let syn::Item::Type(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pallet::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)?;
@@ -811,12 +811,12 @@ impl StorageDef {
let typ = if let syn::Type::Path(typ) = &*item.ty {
typ
} else {
let msg = "Invalid pallet::storage, expected type path";
let msg = "Invalid pezpallet::storage, expected type path";
return Err(syn::Error::new(item.ty.span(), msg));
};
if typ.path.segments.len() != 1 {
let msg = "Invalid pallet::storage, expected type path with one segment";
let msg = "Invalid pezpallet::storage, expected type path with one segment";
return Err(syn::Error::new(item.ty.span(), msg));
}
@@ -856,7 +856,7 @@ impl StorageDef {
}) => {
if args.len() != 1 {
let msg = format!(
"Invalid pallet::storage, unexpected number of generic arguments \
"Invalid pezpallet::storage, unexpected number of generic arguments \
for ResultQuery, expected 1 type argument, found {}",
args.len(),
);
@@ -867,7 +867,7 @@ impl StorageDef {
},
args => {
let msg = format!(
"Invalid pallet::storage, unexpected generic args for ResultQuery, \
"Invalid pezpallet::storage, unexpected generic args for ResultQuery, \
expected angle-bracketed arguments, found `{}`",
args.to_token_stream().to_string()
);
@@ -882,7 +882,7 @@ impl StorageDef {
})) => {
if err_variant.len() < 2 {
let msg = format!(
"Invalid pallet::storage, unexpected number of path segments for \
"Invalid pezpallet::storage, unexpected number of path segments for \
the generics in ResultQuery, expected a path with at least 2 \
segments, found {}",
err_variant.len(),
@@ -908,7 +908,7 @@ impl StorageDef {
},
gen_arg => {
let msg = format!(
"Invalid pallet::storage, unexpected generic argument kind, expected a \
"Invalid pezpallet::storage, unexpected generic argument kind, expected a \
type path to a `PalletError` enum variant, found `{}`",
gen_arg.to_token_stream().to_string(),
);
@@ -920,7 +920,7 @@ impl StorageDef {
.unwrap_or(Some(QueryKind::OptionQuery));
if let (None, Some(getter)) = (query_kind.as_ref(), getter.as_ref()) {
let msg = "Invalid pallet::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));
@@ -23,7 +23,7 @@ use std::collections::HashSet;
use crate::assert_parse_error_matches;
#[cfg(test)]
use crate::pallet::parse::tests::simulate_manifest_dir;
use crate::pezpallet::parse::tests::simulate_manifest_dir;
use super::helper;
use derive_syn_parse::Parse;
@@ -47,10 +47,10 @@ pub mod keywords {
custom_keyword!(task_condition);
custom_keyword!(task_index);
custom_keyword!(task_weight);
custom_keyword!(pallet);
custom_keyword!(pezpallet);
}
/// Represents the `#[pallet::tasks_experimental]` attribute and its attached item. Also includes
/// Represents the `#[pezpallet::tasks_experimental]` attribute and its attached item. Also includes
/// metadata about the linked [`TaskEnumDef`] if applicable.
#[derive(Clone, Debug)]
pub struct TasksDef {
@@ -72,7 +72,7 @@ impl syn::parse::Parse for TasksDef {
if let Some(extra_tasks_attr) = tasks_attrs.get(1) {
return Err(Error::new(
extra_tasks_attr.span(),
"unexpected extra `#[pallet::tasks_experimental]` attribute",
"unexpected extra `#[pezpallet::tasks_experimental]` attribute",
));
}
let tasks: Vec<TaskDef> = if tasks_attr.is_some() {
@@ -106,7 +106,7 @@ impl syn::parse::Parse for TasksDef {
return Err(Error::new(
enum_path.span(),
"if specified manually, the task enum must be defined locally in this \
pallet and cannot be a re-export",
pezpallet and cannot be a re-export",
));
};
let enum_ident = last_seg.ident.clone();
@@ -116,30 +116,30 @@ impl syn::parse::Parse for TasksDef {
}
}
/// Parsing for a `#[pallet::tasks_experimental]` attr.
/// Parsing for a `#[pezpallet::tasks_experimental]` attr.
pub type PalletTasksAttr = PalletTaskAttr<keywords::tasks_experimental>;
/// Parsing for any of the attributes that can be used within a `#[pallet::tasks_experimental]`
/// Parsing for any of the attributes that can be used within a `#[pezpallet::tasks_experimental]`
/// [`ItemImpl`].
pub type TaskAttr = PalletTaskAttr<TaskAttrMeta>;
/// Parsing for a `#[pallet::task_index]` attr.
/// Parsing for a `#[pezpallet::task_index]` attr.
pub type TaskIndexAttr = PalletTaskAttr<TaskIndexAttrMeta>;
/// Parsing for a `#[pallet::task_condition]` attr.
/// Parsing for a `#[pezpallet::task_condition]` attr.
pub type TaskConditionAttr = PalletTaskAttr<TaskConditionAttrMeta>;
/// Parsing for a `#[pallet::task_list]` attr.
/// Parsing for a `#[pezpallet::task_list]` attr.
pub type TaskListAttr = PalletTaskAttr<TaskListAttrMeta>;
/// Parsing for a `#[pallet::task_weight]` attr.
/// Parsing for a `#[pezpallet::task_weight]` attr.
pub type TaskWeightAttr = PalletTaskAttr<TaskWeightAttrMeta>;
/// Parsing for a `#[pallet:task_enum]` attr.
/// Parsing for a `#[pezpallet:task_enum]` attr.
pub type PalletTaskEnumAttr = PalletTaskAttr<keywords::task_enum>;
/// Parsing for a manually-specified (or auto-generated) task enum, optionally including the
/// attached `#[pallet::task_enum]` attribute.
/// attached `#[pezpallet::task_enum]` attribute.
#[derive(Clone)]
pub struct TaskEnumDef {
pub attr: Option<PalletTaskEnumAttr>,
@@ -193,7 +193,7 @@ impl syn::parse::Parse for TaskDef {
else {
return Err(Error::new(
item.sig.ident.span(),
"missing `#[pallet::task_index(..)]` attribute",
"missing `#[pezpallet::task_index(..)]` attribute",
));
};
@@ -204,7 +204,7 @@ impl syn::parse::Parse for TaskDef {
else {
return Err(Error::new(
item.sig.ident.span(),
"missing `#[pallet::task_condition(..)]` attribute",
"missing `#[pezpallet::task_condition(..)]` attribute",
));
};
@@ -215,7 +215,7 @@ impl syn::parse::Parse for TaskDef {
else {
return Err(Error::new(
item.sig.ident.span(),
"missing `#[pallet::task_list(..)]` attribute",
"missing `#[pezpallet::task_list(..)]` attribute",
));
};
@@ -226,7 +226,7 @@ impl syn::parse::Parse for TaskDef {
else {
return Err(Error::new(
item.sig.ident.span(),
"missing `#[pallet::task_weight(..)]` attribute",
"missing `#[pezpallet::task_weight(..)]` attribute",
));
};
@@ -238,7 +238,7 @@ impl syn::parse::Parse for TaskDef {
{
return Err(Error::new(
duplicate.span(),
"unexpected extra `#[pallet::task_condition(..)]` attribute",
"unexpected extra `#[pezpallet::task_condition(..)]` attribute",
));
}
@@ -250,7 +250,7 @@ impl syn::parse::Parse for TaskDef {
{
return Err(Error::new(
duplicate.span(),
"unexpected extra `#[pallet::task_list(..)]` attribute",
"unexpected extra `#[pezpallet::task_list(..)]` attribute",
));
}
@@ -262,7 +262,7 @@ impl syn::parse::Parse for TaskDef {
{
return Err(Error::new(
duplicate.span(),
"unexpected extra `#[pallet::task_index(..)]` attribute",
"unexpected extra `#[pezpallet::task_index(..)]` attribute",
));
}
@@ -289,17 +289,17 @@ impl syn::parse::Parse for TaskDef {
/// The contents of a [`TasksDef`]-related attribute.
#[derive(Parse, Debug, Clone)]
pub enum TaskAttrMeta {
#[peek(keywords::task_list, name = "#[pallet::task_list(..)]")]
#[peek(keywords::task_list, name = "#[pezpallet::task_list(..)]")]
TaskList(TaskListAttrMeta),
#[peek(keywords::task_index, name = "#[pallet::task_index(..)")]
#[peek(keywords::task_index, name = "#[pezpallet::task_index(..)")]
TaskIndex(TaskIndexAttrMeta),
#[peek(keywords::task_condition, name = "#[pallet::task_condition(..)")]
#[peek(keywords::task_condition, name = "#[pezpallet::task_condition(..)")]
TaskCondition(TaskConditionAttrMeta),
#[peek(keywords::task_weight, name = "#[pallet::task_weight(..)")]
#[peek(keywords::task_weight, name = "#[pezpallet::task_weight(..)")]
TaskWeight(TaskWeightAttrMeta),
}
/// The contents of a `#[pallet::task_list]` attribute.
/// The contents of a `#[pezpallet::task_list]` attribute.
#[derive(Parse, Debug, Clone)]
pub struct TaskListAttrMeta {
pub task_list: keywords::task_list,
@@ -309,7 +309,7 @@ pub struct TaskListAttrMeta {
pub expr: Expr,
}
/// The contents of a `#[pallet::task_index]` attribute.
/// The contents of a `#[pezpallet::task_index]` attribute.
#[derive(Parse, Debug, Clone)]
pub struct TaskIndexAttrMeta {
pub task_index: keywords::task_index,
@@ -319,7 +319,7 @@ pub struct TaskIndexAttrMeta {
pub index: LitInt,
}
/// The contents of a `#[pallet::task_condition]` attribute.
/// The contents of a `#[pezpallet::task_condition]` attribute.
#[derive(Parse, Debug, Clone)]
pub struct TaskConditionAttrMeta {
pub task_condition: keywords::task_condition,
@@ -329,7 +329,7 @@ pub struct TaskConditionAttrMeta {
pub expr: Expr,
}
/// The contents of a `#[pallet::task_weight]` attribute.
/// The contents of a `#[pezpallet::task_weight]` attribute.
#[derive(Parse, Debug, Clone)]
pub struct TaskWeightAttrMeta {
pub task_weight: keywords::task_weight,
@@ -339,14 +339,14 @@ pub struct TaskWeightAttrMeta {
pub expr: Expr,
}
/// The contents of a `#[pallet::task]` attribute.
/// The contents of a `#[pezpallet::task]` attribute.
#[derive(Parse, Debug, Clone)]
pub struct PalletTaskAttr<T: syn::parse::Parse + core::fmt::Debug + ToTokens> {
pub pound: Pound,
#[bracket]
_bracket: Bracket,
#[inside(_bracket)]
pub pallet: keywords::pallet,
pub pezpallet: keywords::pezpallet,
#[inside(_bracket)]
pub colons: PathSep,
#[inside(_bracket)]
@@ -399,10 +399,10 @@ impl ToTokens for TaskAttrMeta {
impl<T: syn::parse::Parse + core::fmt::Debug + ToTokens> ToTokens for PalletTaskAttr<T> {
fn to_tokens(&self, tokens: &mut TokenStream2) {
let pound = self.pound;
let pallet = self.pallet;
let pezpallet = self.pezpallet;
let colons = self.colons;
let meta = &self.meta;
tokens.extend(quote!(#pound[#pallet #colons #meta]));
tokens.extend(quote!(#pound[#pezpallet #colons #meta]));
}
}
@@ -411,10 +411,10 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskIndexAttr {
fn try_from(value: PalletTaskAttr<TaskAttrMeta>) -> Result<Self> {
let pound = value.pound;
let pallet = value.pallet;
let pezpallet = value.pezpallet;
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskIndex(meta) => parse2(quote!(#pound[#pallet #colons #meta])),
TaskAttrMeta::TaskIndex(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
return Err(Error::new(
value.span(),
@@ -429,10 +429,10 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskConditionAttr {
fn try_from(value: PalletTaskAttr<TaskAttrMeta>) -> Result<Self> {
let pound = value.pound;
let pallet = value.pallet;
let pezpallet = value.pezpallet;
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskCondition(meta) => parse2(quote!(#pound[#pallet #colons #meta])),
TaskAttrMeta::TaskCondition(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
return Err(Error::new(
value.span(),
@@ -447,10 +447,10 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskWeightAttr {
fn try_from(value: PalletTaskAttr<TaskAttrMeta>) -> Result<Self> {
let pound = value.pound;
let pallet = value.pallet;
let pezpallet = value.pezpallet;
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskWeight(meta) => parse2(quote!(#pound[#pallet #colons #meta])),
TaskAttrMeta::TaskWeight(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
return Err(Error::new(
value.span(),
@@ -465,10 +465,10 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskListAttr {
fn try_from(value: PalletTaskAttr<TaskAttrMeta>) -> Result<Self> {
let pound = value.pound;
let pallet = value.pallet;
let pezpallet = value.pezpallet;
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskList(meta) => parse2(quote!(#pound[#pallet #colons #meta])),
TaskAttrMeta::TaskList(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
return Err(Error::new(
value.span(),
@@ -494,7 +494,7 @@ fn extract_pallet_attr(item_enum: &mut ItemEnum) -> Result<Option<TokenStream2>>
let (Some(seg1), Some(_), None) = (segs.get(0), segs.get(1), segs.get(2)) else {
return true;
};
if seg1 != "pallet" {
if seg1 != "pezpallet" {
return true;
}
if attr.is_some() {
@@ -506,7 +506,7 @@ 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 `#[pallet::_]` attribute is supported on this item"));
return Err(Error::new(span, "only one `#[pezpallet::_]` attribute is supported on this item"));
}
Ok(attr)
}
@@ -519,7 +519,7 @@ fn partition_tasks_attrs(item_impl: &ItemImpl) -> (Vec<syn::Attribute>, Vec<syn:
else {
return false;
};
prefix.ident == "pallet" && suffix.ident == "tasks_experimental"
prefix.ident == "pezpallet" && suffix.ident == "tasks_experimental"
})
}
@@ -531,7 +531,7 @@ fn partition_task_attrs(item: &ImplItemFn) -> (Vec<syn::Attribute>, Vec<syn::Att
};
// N.B: the `PartialEq` impl between `Ident` and `&str` is more efficient than
// parsing and makes no stack or heap allocations
prefix.ident == "pallet" &&
prefix.ident == "pezpallet" &&
(suffix.ident == "tasks_experimental" ||
suffix.ident == "task_list" ||
suffix.ident == "task_condition" ||
@@ -542,63 +542,63 @@ fn partition_task_attrs(item: &ImplItemFn) -> (Vec<syn::Attribute>, Vec<syn::Att
#[test]
fn test_parse_task_list_() {
parse2::<TaskAttr>(quote!(#[pallet::task_list(Something::iter())])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_list(Numbers::<T, I>::iter_keys())])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_list(iter())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_list(Something::iter())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_list(Numbers::<T, I>::iter_keys())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_list(iter())])).unwrap();
assert_parse_error_matches!(
parse2::<TaskAttr>(quote!(#[pallet::task_list()])),
parse2::<TaskAttr>(quote!(#[pezpallet::task_list()])),
"expected an expression"
);
assert_parse_error_matches!(
parse2::<TaskAttr>(quote!(#[pallet::task_list])),
parse2::<TaskAttr>(quote!(#[pezpallet::task_list])),
"expected parentheses"
);
}
#[test]
fn test_parse_task_index() {
parse2::<TaskAttr>(quote!(#[pallet::task_index(3)])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_index(0)])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_index(17)])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_index(3)])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_index(0)])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_index(17)])).unwrap();
assert_parse_error_matches!(
parse2::<TaskAttr>(quote!(#[pallet::task_index])),
parse2::<TaskAttr>(quote!(#[pezpallet::task_index])),
"expected parentheses"
);
assert_parse_error_matches!(
parse2::<TaskAttr>(quote!(#[pallet::task_index("hey")])),
parse2::<TaskAttr>(quote!(#[pezpallet::task_index("hey")])),
"expected integer literal"
);
assert_parse_error_matches!(
parse2::<TaskAttr>(quote!(#[pallet::task_index(0.3)])),
parse2::<TaskAttr>(quote!(#[pezpallet::task_index(0.3)])),
"expected integer literal"
);
}
#[test]
fn test_parse_task_condition() {
parse2::<TaskAttr>(quote!(#[pallet::task_condition(|x| x.is_some())])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_condition(|_x| some_expr())])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_condition(|| some_expr())])).unwrap();
parse2::<TaskAttr>(quote!(#[pallet::task_condition(some_expr())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_condition(|x| x.is_some())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_condition(|_x| some_expr())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_condition(|| some_expr())])).unwrap();
parse2::<TaskAttr>(quote!(#[pezpallet::task_condition(some_expr())])).unwrap();
}
#[test]
fn test_parse_tasks_attr() {
parse2::<PalletTasksAttr>(quote!(#[pallet::tasks_experimental])).unwrap();
parse2::<PalletTasksAttr>(quote!(#[pezpallet::tasks_experimental])).unwrap();
assert_parse_error_matches!(
parse2::<PalletTasksAttr>(quote!(#[pallet::taskss])),
parse2::<PalletTasksAttr>(quote!(#[pezpallet::taskss])),
"expected `tasks_experimental`"
);
assert_parse_error_matches!(
parse2::<PalletTasksAttr>(quote!(#[pallet::tasks_])),
parse2::<PalletTasksAttr>(quote!(#[pezpallet::tasks_])),
"expected `tasks_experimental`"
);
assert_parse_error_matches!(
parse2::<PalletTasksAttr>(quote!(#[pal::tasks])),
"expected `pallet`"
"expected `pezpallet`"
);
assert_parse_error_matches!(
parse2::<PalletTasksAttr>(quote!(#[pallet::tasks_experimental()])),
parse2::<PalletTasksAttr>(quote!(#[pezpallet::tasks_experimental()])),
"unexpected token"
);
}
@@ -607,13 +607,13 @@ fn test_parse_tasks_attr() {
fn test_parse_tasks_def_basic() {
simulate_manifest_dir("../../examples/basic", || {
let parsed = parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Add a pair of numbers into the totals and remove them.
#[pallet::task_list(Numbers::<T, I>::iter_keys())]
#[pallet::task_condition(|i| Numbers::<T, I>::contains_key(i))]
#[pallet::task_index(0)]
#[pallet::task_weight(0)]
#[pezpallet::task_list(Numbers::<T, I>::iter_keys())]
#[pezpallet::task_condition(|i| Numbers::<T, I>::contains_key(i))]
#[pezpallet::task_index(0)]
#[pezpallet::task_weight(0)]
pub fn add_number_into_total(i: u32) -> DispatchResult {
let v = Numbers::<T, I>::take(i).ok_or(Error::<T, I>::NotFound)?;
Total::<T, I>::mutate(|(total_keys, total_values)| {
@@ -633,16 +633,16 @@ fn test_parse_tasks_def_basic() {
fn test_parse_tasks_def_basic_increment_decrement() {
simulate_manifest_dir("../../examples/basic", || {
let parsed = parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Get the value and check if it can be incremented
#[pallet::task_index(0)]
#[pallet::task_condition(|| {
#[pezpallet::task_index(0)]
#[pezpallet::task_condition(|| {
let value = Value::<T>::get().unwrap();
value < 255
})]
#[pallet::task_list(Vec::<Task<T>>::new())]
#[pallet::task_weight(0)]
#[pezpallet::task_list(Vec::<Task<T>>::new())]
#[pezpallet::task_weight(0)]
fn increment() -> DispatchResult {
let value = Value::<T>::get().unwrap_or_default();
if value >= 255 {
@@ -650,19 +650,19 @@ fn test_parse_tasks_def_basic_increment_decrement() {
} else {
let new_val = value.checked_add(1).ok_or(Error::<T>::ValueOverflow)?;
Value::<T>::put(new_val);
Pallet::<T>::deposit_event(Event::Incremented { new_val });
Pezpallet::<T>::deposit_event(Event::Incremented { new_val });
Ok(())
}
}
// Get the value and check if it can be decremented
#[pallet::task_index(1)]
#[pallet::task_condition(|| {
#[pezpallet::task_index(1)]
#[pezpallet::task_condition(|| {
let value = Value::<T>::get().unwrap();
value > 0
})]
#[pallet::task_list(Vec::<Task<T>>::new())]
#[pallet::task_weight(0)]
#[pezpallet::task_list(Vec::<Task<T>>::new())]
#[pezpallet::task_weight(0)]
fn decrement() -> DispatchResult {
let value = Value::<T>::get().unwrap_or_default();
if value == 0 {
@@ -670,7 +670,7 @@ fn test_parse_tasks_def_basic_increment_decrement() {
} else {
let new_val = value.checked_sub(1).ok_or(Error::<T>::ValueUnderflow)?;
Value::<T>::put(new_val);
Pallet::<T>::deposit_event(Event::Decremented { new_val });
Pezpallet::<T>::deposit_event(Event::Decremented { new_val });
Ok(())
}
}
@@ -686,20 +686,20 @@ fn test_parse_tasks_def_duplicate_index() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_list(Something::iter())]
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_index(0)]
#[pallet::task_weight(0)]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_list(Something::iter())]
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_index(0)]
#[pezpallet::task_weight(0)]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
#[pallet::task_list(Numbers::<T, I>::iter_keys())]
#[pallet::task_condition(|i| Numbers::<T, I>::contains_key(i))]
#[pallet::task_index(0)]
#[pallet::task_weight(0)]
#[pezpallet::task_list(Numbers::<T, I>::iter_keys())]
#[pezpallet::task_condition(|i| Numbers::<T, I>::contains_key(i))]
#[pezpallet::task_index(0)]
#[pezpallet::task_weight(0)]
pub fn bar(i: u32) -> DispatchResult {
Ok(())
}
@@ -715,16 +715,16 @@ fn test_parse_tasks_def_missing_task_list() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_index(0)]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_index(0)]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"missing `#\[pallet::task_list\(\.\.\)\]`"
r"missing `#\[pezpallet::task_list\(\.\.\)\]`"
);
});
}
@@ -734,16 +734,16 @@ fn test_parse_tasks_def_missing_task_condition() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_list(Something::iter())]
#[pallet::task_index(0)]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_list(Something::iter())]
#[pezpallet::task_index(0)]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"missing `#\[pallet::task_condition\(\.\.\)\]`"
r"missing `#\[pezpallet::task_condition\(\.\.\)\]`"
);
});
}
@@ -753,16 +753,16 @@ fn test_parse_tasks_def_missing_task_index() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_list(Something::iter())]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_list(Something::iter())]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"missing `#\[pallet::task_index\(\.\.\)\]`"
r"missing `#\[pezpallet::task_index\(\.\.\)\]`"
);
});
}
@@ -772,17 +772,17 @@ fn test_parse_tasks_def_missing_task_weight() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_list(Something::iter())]
#[pallet::task_index(0)]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_list(Something::iter())]
#[pezpallet::task_index(0)]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"missing `#\[pallet::task_weight\(\.\.\)\]`"
r"missing `#\[pezpallet::task_weight\(\.\.\)\]`"
);
});
}
@@ -792,19 +792,19 @@ fn test_parse_tasks_def_unexpected_extra_task_list_attr() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_index(0)]
#[pallet::task_weight(0)]
#[pallet::task_list(Something::iter())]
#[pallet::task_list(SomethingElse::iter())]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_index(0)]
#[pezpallet::task_weight(0)]
#[pezpallet::task_list(Something::iter())]
#[pezpallet::task_list(SomethingElse::iter())]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"unexpected extra `#\[pallet::task_list\(\.\.\)\]`"
r"unexpected extra `#\[pezpallet::task_list\(\.\.\)\]`"
);
});
}
@@ -814,19 +814,19 @@ fn test_parse_tasks_def_unexpected_extra_task_condition_attr() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_condition(|i| i % 4 == 0)]
#[pallet::task_index(0)]
#[pallet::task_list(Something::iter())]
#[pallet::task_weight(0)]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_condition(|i| i % 4 == 0)]
#[pezpallet::task_index(0)]
#[pezpallet::task_list(Something::iter())]
#[pezpallet::task_weight(0)]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"unexpected extra `#\[pallet::task_condition\(\.\.\)\]`"
r"unexpected extra `#\[pezpallet::task_condition\(\.\.\)\]`"
);
});
}
@@ -836,19 +836,19 @@ fn test_parse_tasks_def_unexpected_extra_task_index_attr() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pallet::task_condition(|i| i % 2 == 0)]
#[pallet::task_index(0)]
#[pallet::task_index(0)]
#[pallet::task_list(Something::iter())]
#[pallet::task_weight(0)]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[pezpallet::task_condition(|i| i % 2 == 0)]
#[pezpallet::task_index(0)]
#[pezpallet::task_index(0)]
#[pezpallet::task_list(Something::iter())]
#[pezpallet::task_weight(0)]
pub fn foo(i: u32) -> DispatchResult {
Ok(())
}
}
}),
r"unexpected extra `#\[pallet::task_index\(\.\.\)\]`"
r"unexpected extra `#\[pezpallet::task_index\(\.\.\)\]`"
);
});
}
@@ -858,11 +858,11 @@ fn test_parse_tasks_def_extra_tasks_attribute() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TasksDef>(quote! {
#[pallet::tasks_experimental]
#[pallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pallet<T, I> {}
#[pezpallet::tasks_experimental]
#[pezpallet::tasks_experimental]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {}
}),
r"unexpected extra `#\[pallet::tasks_experimental\]` attribute"
r"unexpected extra `#\[pezpallet::tasks_experimental\]` attribute"
);
});
}
@@ -871,7 +871,7 @@ fn test_parse_tasks_def_extra_tasks_attribute() {
fn test_parse_task_enum_def_basic() {
simulate_manifest_dir("../../examples/basic", || {
parse2::<TaskEnumDef>(quote! {
#[pallet::task_enum]
#[pezpallet::task_enum]
pub enum Task<T: Config> {
Increment,
Decrement,
@@ -885,7 +885,7 @@ fn test_parse_task_enum_def_basic() {
fn test_parse_task_enum_def_non_task_name() {
simulate_manifest_dir("../../examples/basic", || {
parse2::<TaskEnumDef>(quote! {
#[pallet::task_enum]
#[pezpallet::task_enum]
pub enum Something<T> {
Foo
}
@@ -924,7 +924,7 @@ fn test_parse_task_enum_def_wrong_attr() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TaskEnumDef>(quote! {
#[pallet::something]
#[pezpallet::something]
pub enum Task<T: Config> {
Increment,
Decrement,
@@ -940,7 +940,7 @@ fn test_parse_task_enum_def_wrong_item() {
simulate_manifest_dir("../../examples/basic", || {
assert_parse_error_matches!(
parse2::<TaskEnumDef>(quote! {
#[pallet::task_enum]
#[pezpallet::task_enum]
pub struct Something<T>;
}),
"expected `enum`"
@@ -33,7 +33,7 @@ pub mod __private {
///
/// assert_parse_error_matches!(
/// parse2::<TaskEnumDef>(quote! {
/// #[pallet::task_enum]
/// #[pezpallet::task_enum]
/// pub struct Something;
/// }),
/// "expected `enum`"
@@ -46,16 +46,16 @@ pub mod __private {
/// ```ignore
/// assert_parse_error_matches!(
/// parse2::<TasksDef>(quote! {
/// #[pallet::tasks_experimental]
/// impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// #[pallet::task_condition(|i| i % 2 == 0)]
/// #[pallet::task_index(0)]
/// #[pezpallet::tasks_experimental]
/// impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// #[pezpallet::task_condition(|i| i % 2 == 0)]
/// #[pezpallet::task_index(0)]
/// pub fn foo(i: u32) -> DispatchResult {
/// Ok(())
/// }
/// }
/// }),
/// r"missing `#\[pallet::task_list\(\.\.\)\]`"
/// r"missing `#\[pezpallet::task_list\(\.\.\)\]`"
/// );
/// ```
///
@@ -68,7 +68,7 @@ macro_rules! assert_parse_error_matches {
Ok(_) => panic!("Expected an `Error(..)`, but got Ok(..)"),
Err(e) => {
let error_message = e.to_string();
let re = $crate::pallet::parse::tests::__private::regex::Regex::new($reg)
let re = $crate::pezpallet::parse::tests::__private::regex::Regex::new($reg)
.expect("Invalid regex pattern");
assert!(
re.is_match(&error_message),
@@ -81,7 +81,7 @@ macro_rules! assert_parse_error_matches {
};
}
/// Allows you to assert that an entire pallet parses successfully. A custom syntax is used for
/// Allows you to assert that an entire pezpallet parses successfully. A custom syntax is used for
/// specifying arguments so please pay attention to the docs below.
///
/// The general syntax is:
@@ -89,28 +89,28 @@ macro_rules! assert_parse_error_matches {
/// ```ignore
/// assert_pallet_parses! {
/// #[manifest_dir("../../examples/basic")]
/// #[pezframe_support::pallet]
/// pub mod pallet {
/// #[pallet::config]
/// #[pezframe_support::pezpallet]
/// pub mod pezpallet {
/// #[pezpallet::config]
/// pub trait Config: pezframe_system::Config {}
///
/// #[pallet::pallet]
/// pub struct Pallet<T>(_);
/// #[pezpallet::pezpallet]
/// pub struct Pezpallet<T>(_);
/// }
/// };
/// ```
///
/// The `#[manifest_dir(..)]` attribute _must_ be specified as the _first_ attribute on the
/// pallet module, and should reference the relative (to your current directory) path of a
/// directory containing containing the `Cargo.toml` of a valid pallet. Typically you will only
/// ever need to use the `examples/basic` pallet, but sometimes it might be advantageous to
/// pezpallet module, and should reference the relative (to your current directory) path of a
/// directory containing containing the `Cargo.toml` of a valid pezpallet. Typically you will only
/// ever need to use the `examples/basic` pezpallet, but sometimes it might be advantageous to
/// specify a different one that has additional dependencies.
///
/// The reason this must be specified is that our underlying parsing of pallets depends on
/// reaching out into the file system to look for particular `Cargo.toml` dependencies via the
/// [`generate_access_from_frame_or_crate`] method, so to simulate this properly in a proc
/// macro crate, we need to temporarily convince this function that we are running from the
/// directory of a valid pallet.
/// directory of a valid pezpallet.
#[macro_export]
macro_rules! assert_pallet_parses {
(
@@ -118,35 +118,35 @@ macro_rules! assert_pallet_parses {
$($tokens:tt)*
) => {
{
let mut pallet: Option<$crate::pallet::parse::Def> = None;
$crate::pallet::parse::tests::simulate_manifest_dir($manifest_dir, core::panic::AssertUnwindSafe(|| {
pallet = Some($crate::pallet::parse::Def::try_from(syn::parse_quote! {
let mut pezpallet: Option<$crate::pezpallet::parse::Def> = None;
$crate::pezpallet::parse::tests::simulate_manifest_dir($manifest_dir, core::panic::AssertUnwindSafe(|| {
pezpallet = Some($crate::pezpallet::parse::Def::try_from(syn::parse_quote! {
$($tokens)*
}, false).unwrap());
}));
pallet.unwrap()
pezpallet.unwrap()
}
}
}
/// Similar to [`assert_pallet_parses`], except this instead expects the pallet not to parse,
/// Similar to [`assert_pallet_parses`], except this instead expects the pezpallet not to parse,
/// and allows you to specify a regex matching the expected parse error.
///
/// This is identical syntactically to [`assert_pallet_parses`] in every way except there is a
/// second attribute that must be specified immediately after `#[manifest_dir(..)]` which is
/// `#[error_regex(..)]` which should contain a string/regex literal designed to match what you
/// consider to be the correct parsing error we should see when we try to parse this particular
/// pallet.
/// pezpallet.
///
/// ## Example:
///
/// ```
/// assert_pallet_parse_error! {
/// #[manifest_dir("../../examples/basic")]
/// #[error_regex("Missing `\\#\\[pallet::pallet\\]`")]
/// #[pezframe_support::pallet]
/// pub mod pallet {
/// #[pallet::config]
/// #[error_regex("Missing `\\#\\[pezpallet::pezpallet\\]`")]
/// #[pezframe_support::pezpallet]
/// pub mod pezpallet {
/// #[pezpallet::config]
/// pub trait Config: pezframe_system::Config {}
/// }
/// }
@@ -158,9 +158,9 @@ macro_rules! assert_pallet_parse_error {
#[error_regex($reg:literal)]
$($tokens:tt)*
) => {
$crate::pallet::parse::tests::simulate_manifest_dir($manifest_dir, || {
$crate::pezpallet::parse::tests::simulate_manifest_dir($manifest_dir, || {
$crate::assert_parse_error_matches!(
$crate::pallet::parse::Def::try_from(
$crate::pezpallet::parse::Def::try_from(
parse_quote! {
$($tokens)*
},
@@ -226,13 +226,13 @@ mod tasks;
fn test_parse_minimal_pallet() {
assert_pallet_parses! {
#[manifest_dir("../../examples/basic")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::config]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
};
}
@@ -241,10 +241,10 @@ fn test_parse_minimal_pallet() {
fn test_parse_pallet_missing_pallet() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("Missing `\\#\\[pallet::pallet\\]`")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::config]
#[error_regex("Missing `\\#\\[pezpallet::pezpallet\\]`")]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
}
}
@@ -254,11 +254,11 @@ fn test_parse_pallet_missing_pallet() {
fn test_parse_pallet_missing_config() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("Missing `\\#\\[pallet::config\\]`")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::pallet]
pub struct Pallet<T>(_);
#[error_regex("Missing `\\#\\[pezpallet::config\\]`")]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
}
}
@@ -268,9 +268,9 @@ fn test_parse_pallet_deprecated_attribute_on_error_enum() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("The `\\#\\[deprecated\\]` attribute should be applied to individual variants, not the enum as a whole\\.")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::error]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::error]
#[deprecated(note = "This enum is deprecated and should not be used.")]
pub enum Error<T> {
Foo
@@ -284,9 +284,9 @@ fn test_parse_pallet_deprecated_attribute_on_event_enum() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("The `\\#\\[deprecated\\]` attribute should be applied to individual variants, not the enum as a whole\\.")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::event]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::event]
#[deprecated(note = "This enum is deprecated and should not be used.")]
pub enum Event<T> {
Foo
@@ -21,19 +21,19 @@ use syn::parse_quote;
fn test_parse_pallet_with_task_enum_missing_impl() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("Missing `\\#\\[pallet::tasks_experimental\\]` impl")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::task_enum]
#[error_regex("Missing `\\#\\[pezpallet::tasks_experimental\\]` impl")]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::task_enum]
pub enum Task<T: Config> {
Something,
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
}
}
@@ -43,24 +43,24 @@ fn test_parse_pallet_with_task_enum_wrong_attribute() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("expected one of")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::wrong_attribute]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::wrong_attribute]
pub enum Task<T: Config> {
Something,
}
#[pallet::task_list]
#[pezpallet::task_list]
impl<T: Config> pezframe_support::traits::Task for Task<T>
where
T: TypeInfo,
{}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
}
}
@@ -69,20 +69,20 @@ fn test_parse_pallet_with_task_enum_wrong_attribute() {
fn test_parse_pallet_missing_task_enum() {
assert_pallet_parses! {
#[manifest_dir("../../examples/basic")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::tasks_experimental]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::tasks_experimental]
#[cfg(test)] // aha, this means it's being eaten
impl<T: Config> pezframe_support::traits::Task for Task<T>
where
T: TypeInfo,
{}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
};
}
@@ -92,22 +92,22 @@ fn test_parse_pallet_task_list_in_wrong_place() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex("can only be used on items within an `impl` statement.")]
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
pub enum MyCustomTaskEnum<T: Config> {
Something,
}
#[pallet::task_list]
#[pezpallet::task_list]
pub fn something() {
println!("hey");
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
}
}
@@ -117,8 +117,8 @@ fn test_parse_pallet_manual_tasks_impl_without_manual_tasks_enum() {
assert_pallet_parse_error! {
#[manifest_dir("../../examples/basic")]
#[error_regex(".*attribute must be attached to your.*")]
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
impl<T: Config> pezframe_support::traits::Task for Task<T>
where
@@ -131,11 +131,11 @@ fn test_parse_pallet_manual_tasks_impl_without_manual_tasks_enum() {
}
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
}
}
@@ -144,23 +144,23 @@ fn test_parse_pallet_manual_tasks_impl_without_manual_tasks_enum() {
fn test_parse_pallet_manual_task_enum_non_manual_impl() {
assert_pallet_parses! {
#[manifest_dir("../../examples/basic")]
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
pub enum MyCustomTaskEnum<T: Config> {
Something,
}
#[pallet::tasks_experimental]
#[pezpallet::tasks_experimental]
impl<T: Config> pezframe_support::traits::Task for MyCustomTaskEnum<T>
where
T: TypeInfo,
{}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
};
}
@@ -169,9 +169,9 @@ fn test_parse_pallet_manual_task_enum_non_manual_impl() {
fn test_parse_pallet_non_manual_task_enum_manual_impl() {
assert_pallet_parses! {
#[manifest_dir("../../examples/basic")]
#[pezframe_support::pallet]
pub mod pallet {
#[pallet::task_enum]
#[pezframe_support::pezpallet]
pub mod pezpallet {
#[pezpallet::task_enum]
pub enum MyCustomTaskEnum<T: Config> {
Something,
}
@@ -181,11 +181,11 @@ fn test_parse_pallet_non_manual_task_enum_manual_impl() {
T: TypeInfo,
{}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
};
}
@@ -194,8 +194,8 @@ fn test_parse_pallet_non_manual_task_enum_manual_impl() {
fn test_parse_pallet_manual_task_enum_manual_impl() {
assert_pallet_parses! {
#[manifest_dir("../../examples/basic")]
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
pub enum MyCustomTaskEnum<T: Config> {
Something,
}
@@ -205,11 +205,11 @@ fn test_parse_pallet_manual_task_enum_manual_impl() {
T: TypeInfo,
{}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
};
}
@@ -218,23 +218,23 @@ fn test_parse_pallet_manual_task_enum_manual_impl() {
fn test_parse_pallet_manual_task_enum_mismatch_ident() {
assert_pallet_parses! {
#[manifest_dir("../../examples/basic")]
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
pub enum WrongIdent<T: Config> {
Something,
}
#[pallet::tasks_experimental]
#[pezpallet::tasks_experimental]
impl<T: Config> pezframe_support::traits::Task for MyCustomTaskEnum<T>
where
T: TypeInfo,
{}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
};
}
@@ -20,7 +20,7 @@ use syn::spanned::Spanned;
/// Definition of type value. Just a function which is expanded to a struct implementing `Get`.
pub struct TypeValueDef {
/// The index of error item in pallet module.
/// The index of error item in pezpallet module.
pub index: usize,
/// Visibility of the struct to generate.
pub vis: syn::Visibility,
@@ -28,11 +28,11 @@ pub struct TypeValueDef {
pub ident: syn::Ident,
/// The type return by Get.
pub type_: Box<syn::Type>,
/// If type value is generic over `T` (or `T` and `I` for instantiable pallet)
/// If type value is generic over `T` (or `T` and `I` for instantiable pezpallet)
pub is_generic: bool,
/// The where clause of the function.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::type_value attribute.
/// The span of the pezpallet::type_value attribute.
pub attr_span: proc_macro2::Span,
/// Docs on the item.
pub docs: Vec<syn::Expr>,
@@ -47,7 +47,7 @@ impl TypeValueDef {
let item = if let syn::Item::Fn(item) = item {
item
} else {
let msg = "Invalid pallet::type_value, expected item fn";
let msg = "Invalid pezpallet::type_value, expected item fn";
return Err(syn::Error::new(item.span(), msg));
};
@@ -60,7 +60,7 @@ impl TypeValueDef {
}
}
let msg = "Invalid pallet::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));
}
@@ -75,12 +75,12 @@ impl TypeValueDef {
.or_else(|| item.sig.abi.as_ref().map(|t| t.span()))
.or_else(|| item.sig.variadic.as_ref().map(|t| t.span()))
{
let msg = "Invalid pallet::type_value, unexpected token";
let msg = "Invalid pezpallet::type_value, unexpected token";
return Err(syn::Error::new(span, msg));
}
if !item.sig.inputs.is_empty() {
let msg = "Invalid pallet::type_value, unexpected argument";
let msg = "Invalid pezpallet::type_value, unexpected argument";
return Err(syn::Error::new(item.sig.inputs[0].span(), msg));
}
@@ -89,7 +89,7 @@ impl TypeValueDef {
let type_ = match item.sig.output.clone() {
syn::ReturnType::Type(_, type_) => type_,
syn::ReturnType::Default => {
let msg = "Invalid pallet::type_value, expected return type";
let msg = "Invalid pezpallet::type_value, expected return type";
return Err(syn::Error::new(item.sig.span(), msg));
},
};
@@ -18,7 +18,7 @@
use super::helper;
use syn::spanned::Spanned;
/// The definition of the pallet validate unsigned implementation.
/// The definition of the pezpallet validate unsigned implementation.
pub struct ValidateUnsignedDef {}
impl ValidateUnsignedDef {
@@ -26,24 +26,24 @@ impl ValidateUnsignedDef {
let item = if let syn::Item::Impl(item) = item {
item
} else {
let msg = "Invalid pallet::validate_unsigned, expected item impl";
let msg = "Invalid pezpallet::validate_unsigned, expected item impl";
return Err(syn::Error::new(item.span(), msg));
};
if item.trait_.is_none() {
let msg = "Invalid pallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pallet<..>";
let msg = "Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
if let Some(last) = item.trait_.as_ref().unwrap().1.segments.last() {
if last.ident != "ValidateUnsigned" {
let msg = "Invalid pallet::validate_unsigned, expected trait ValidateUnsigned";
let msg = "Invalid pezpallet::validate_unsigned, expected trait ValidateUnsigned";
return Err(syn::Error::new(last.span(), msg));
}
} else {
let msg = "Invalid pallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pallet<..>";
let msg = "Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -19,11 +19,11 @@ use pezframe_support_procedural_tools::get_doc_literals;
use inflector::Inflector;
use syn::spanned::Spanned;
/// Parsed representation of an impl block annotated with `pallet::view_functions`.
/// Parsed representation of an impl block annotated with `pezpallet::view_functions`.
pub struct ViewFunctionsImplDef {
/// The where_clause used.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::view_functions attribute.
/// The span of the pezpallet::view_functions attribute.
pub attr_span: proc_macro2::Span,
/// The view function definitions.
pub view_functions: Vec<ViewFunctionDef>,
@@ -34,14 +34,14 @@ impl ViewFunctionsImplDef {
let syn::Item::Impl(item_impl) = item else {
return Err(syn::Error::new(
item.span(),
"Invalid pallet::view_functions, expected item impl",
"Invalid pezpallet::view_functions, expected item impl",
));
};
let mut view_functions = Vec::new();
for item in &mut item_impl.items {
if let syn::ImplItem::Fn(method) = item {
if !matches!(method.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pallet::view_functions, view function must be public: \
let msg = "Invalid pezpallet::view_functions, view function must be public: \
`pub fn`";
let span = match method.vis {
@@ -57,7 +57,7 @@ impl ViewFunctionsImplDef {
} else {
return Err(syn::Error::new(
item.span(),
"Invalid pallet::view_functions, expected a function",
"Invalid pezpallet::view_functions, expected a function",
));
}
}
@@ -37,7 +37,7 @@ use quote::quote;
use std::collections::HashSet;
use syn::{Ident, Result};
/// The fixed name of the system pallet.
/// The fixed name of the system pezpallet.
const SYSTEM_PALLET_NAME: &str = "System";
pub fn expand(def: Def, legacy_ordering: bool) -> TokenStream2 {
@@ -96,11 +96,11 @@ fn construct_runtime_implicit_to_explicit(
#[#pezframe_support::runtime #attr]
#input
);
for pallet in definition.pezpallet_decls.iter() {
let pezpallet_path = &pallet.path;
let pezpallet_name = &pallet.name;
let runtime_param = &pallet.runtime_param;
let pezpallet_segment_and_instance = match (&pallet.pezpallet_segment, &pallet.instance) {
for pezpallet in definition.pezpallet_decls.iter() {
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>),
@@ -130,7 +130,7 @@ fn construct_runtime_final_expansion(
let ExplicitAllPalletsDeclaration { mut pallets, name: pallets_name } = definition;
if !legacy_ordering {
// Ensure that order of hooks is based on the pallet index
// Ensure that order of hooks is based on the pezpallet index
pallets.sort_by_key(|p| p.index);
}
@@ -138,14 +138,14 @@ fn construct_runtime_final_expansion(
pallets.iter().find(|decl| decl.name == SYSTEM_PALLET_NAME).ok_or_else(|| {
syn::Error::new(
pallets_name.span(),
"`System` pallet declaration is missing. \
"`System` pezpallet declaration is missing. \
Please add this line: `pub type System = pezframe_system;`",
)
})?;
if !system_pallet.cfg_pattern.is_empty() {
return Err(syn::Error::new(
system_pallet.name.span(),
"`System` pallet declaration is feature gated, please remove any `#[cfg]` attributes",
"`System` pezpallet declaration is feature gated, please remove any `#[cfg]` attributes",
));
}
@@ -18,18 +18,18 @@
//! Implementation of `runtime`.
//!
//! `runtime` implementation is recursive and can generate code which will call itself
//! in order to get all the pallet parts for each pallet.
//! in order to get all the pezpallet parts for each pezpallet.
//!
//! Pallets can define their parts:
//! - Implicitly: `pub type System = pezframe_system;`
//! - Explicitly: `pub type System = pezframe_system + Pallet + Call;`
//! - Explicitly: `pub type System = pezframe_system + Pezpallet + Call;`
//!
//! The `runtime` transitions from the implicit definition to the explicit one.
//! From the explicit state, Bizinikiwi expands the pallets with additional information
//! that is to be included in the runtime metadata.
//!
//! Pallets must provide the `tt_default_parts_v2` macro for these transitions.
//! These are automatically implemented by the `#[pallet::pallet]` macro.
//! These are automatically implemented by the `#[pezpallet::pezpallet]` macro.
//!
//! This macro also generates the following enums for ease of decoding if the respective type
//! is defined inside `#[runtime::derive]`:
@@ -52,21 +52,21 @@
//! +----------+
//! ```
//!
//! The `runtime` macro transforms the implicit declaration of each pallet
//! `System: pezframe_system` to an explicit one `System: pezframe_system + Pallet + Call` using the
//! 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.
//!
//! The `tt_default_parts_v2` macro exposes a plus separated list of pallet parts. For example, the
//! `Event` part is exposed only if the pallet implements an event via `#[pallet::event]` macro.
//! The tokens generated by this macro are `+ Pallet + 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.
//! - pattern: The pattern to match against in the target stream.
//! - tokens: The tokens to added after the pattern match.
//!
//! The `runtime` macro uses the `tt_call` to get the default pallet parts via
//! the `tt_default_parts_v2` macro defined by each pallet. The pallet parts are then returned as
//! 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 `match_and_replace` then will modify the `runtime` to expand the implicit
//! definition to the explicit one.
@@ -85,7 +85,7 @@
//! pub type Balances = pezpallet_balances; // Implicit definition of parts
//! }
//! ```
//! This call has some implicit pallet parts, thus it will expand to:
//! This call has some implicit pezpallet parts, thus it will expand to:
//! ```ignore
//! pezframe_support::__private::tt_call! {
//! macro = [{ pezpallet_balances::tt_default_parts_v2 }]
@@ -114,8 +114,8 @@
//! }
//! }
//! ```
//! `tt_default_parts_v2` must be defined. It returns the pallet parts inside some tokens, and
//! then `tt_call` will pipe the returned pallet parts into the input of `match_and_insert`.
//! `tt_default_parts_v2` must be defined. It returns the pezpallet parts inside some tokens, and
//! then `tt_call` will pipe the returned pezpallet parts into the input of `match_and_insert`.
//! Thus `match_and_insert` will initially receive the following inputs:
//! ```ignore
//! pezframe_support::match_and_insert! {
@@ -134,11 +134,11 @@
//! }
//! }]
//! pattern = [{ System = pezframe_system }]
//! tokens = [{ ::{+ Pallet + Call} }]
//! tokens = [{ ::{+ Pezpallet + Call} }]
//! }
//! }]
//! pattern = [{ Balances = pezpallet_balances }]
//! tokens = [{ ::{+ Pallet + Call} }]
//! tokens = [{ ::{+ Pezpallet + Call} }]
//! }
//! ```
//! After dealing with `pezpallet_balances`, the inner `match_and_insert` will expand to:
@@ -153,11 +153,11 @@
//! pub type System = pezframe_system; // Implicit definition of parts
//!
//! #[runtime::pezpallet_index(1)]
//! pub type Balances = pezpallet_balances + Pallet + Call; // Explicit definition of parts
//! pub type Balances = pezpallet_balances + Pezpallet + Call; // Explicit definition of parts
//! }
//! }]
//! pattern = [{ System = pezframe_system }]
//! tokens = [{ ::{+ Pallet + Call} }]
//! tokens = [{ ::{+ Pezpallet + Call} }]
//! }
//! ```
//!
@@ -168,14 +168,14 @@
//! //...
//!
//! #[runtime::pezpallet_index(0)]
//! pub type System = pezframe_system + Pallet + Call;
//! pub type System = pezframe_system + Pezpallet + Call;
//!
//! #[runtime::pezpallet_index(1)]
//! pub type Balances = pezpallet_balances + Pallet + Call;
//! pub type Balances = pezpallet_balances + Pezpallet + Call;
//! }
//! ```
//!
//! This call has no implicit pallet parts, thus it will expand to the runtime construction:
//! This call has no implicit pezpallet parts, thus it will expand to the runtime construction:
//! ```ignore
//! pub struct Runtime { ... }
//! pub struct Call { ... }
@@ -188,15 +188,15 @@
//!
//! ```ignore
//! +----------------------+ +------------------------+ +-------------------+
//! | | | (defined in pallet) | | |
//! | | | (defined in pezpallet) | | |
//! | runtime | --> | tt_default_parts_v2! | --> | match_and_insert! |
//! | w/ no pallet parts | | | | |
//! | w/ no pezpallet parts | | | | |
//! +----------------------+ +------------------------+ +-------------------+
//!
//! +----------------------+
//! | |
//! --> | runtime |
//! | w/ pallet parts |
//! | w/ pezpallet parts |
//! +----------------------+
//! ```
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::pallet::parse::helper::MutItemAttrs;
use crate::pezpallet::parse::helper::MutItemAttrs;
use quote::ToTokens;
pub(crate) fn take_first_item_runtime_attr<Attr>(
@@ -16,12 +16,12 @@
// limitations under the License.
pub mod helper;
pub mod pallet;
pub mod pezpallet;
pub mod pezpallet_decl;
pub mod runtime_struct;
pub mod runtime_types;
use crate::construct_runtime::parse::Pallet;
use crate::construct_runtime::parse::Pezpallet;
use pezpallet_decl::PalletDeclaration;
use proc_macro2::TokenStream as TokenStream2;
use quote::ToTokens;
@@ -106,18 +106,18 @@ pub enum AllPalletsDeclaration {
Explicit(ExplicitAllPalletsDeclaration),
}
/// Declaration of a runtime with some pallet with implicit declaration of parts.
/// Declaration of a runtime with some pezpallet with implicit declaration of parts.
#[derive(Debug, Clone)]
pub struct ImplicitAllPalletsDeclaration {
pub pezpallet_decls: Vec<PalletDeclaration>,
pub pezpallet_count: usize,
}
/// Declaration of a runtime with all pallet having explicit declaration of parts.
/// Declaration of a runtime with all pezpallet having explicit declaration of parts.
#[derive(Debug, Clone)]
pub struct ExplicitAllPalletsDeclaration {
pub name: Ident,
pub pallets: Vec<Pallet>,
pub pallets: Vec<Pezpallet>,
}
pub struct Def {
@@ -202,7 +202,7 @@ impl Def {
pezpallet_decls.push(pezpallet_decl);
},
syn::Type::TraitObject(syn::TypeTraitObject { bounds, .. }) => {
let pallet = Pallet::try_from(
let pezpallet = Pezpallet::try_from(
item.span(),
&pezpallet_item,
pezpallet_index,
@@ -211,24 +211,24 @@ impl Def {
&bounds,
)?;
if let Some(used_pallet) = indices.insert(pallet.index, pallet.name.clone())
if let Some(used_pallet) = indices.insert(pezpallet.index, pezpallet.name.clone())
{
let msg = format!(
"Pallet indices are conflicting: Both pallets {} and {} are at index {}",
used_pallet, pallet.name, pallet.index,
"Pezpallet indices are conflicting: Both pallets {} and {} are at index {}",
used_pallet, pezpallet.name, pezpallet.index,
);
let mut err = syn::Error::new(used_pallet.span(), &msg);
err.combine(syn::Error::new(pallet.name.span(), msg));
err.combine(syn::Error::new(pezpallet.name.span(), msg));
return Err(err);
}
pallets.push(pallet);
pallets.push(pezpallet);
},
_ => continue,
}
} else {
if let syn::Item::Type(item) = item {
let msg = "Missing pallet index for pallet declaration. Please add `#[runtime::pezpallet_index(...)]`";
let msg = "Missing pezpallet index for pezpallet declaration. Please add `#[runtime::pezpallet_index(...)]`";
return Err(syn::Error::new(item.span(), &msg));
}
}
@@ -274,7 +274,7 @@ fn runtime_parsing_works() {
pub struct Runtime;
#[runtime::pezpallet_index(0)]
pub type System = pezframe_system::Pallet<Runtime>;
pub type System = pezframe_system::Pezpallet<Runtime>;
#[runtime::pezpallet_index(1)]
pub type Pallet1 = pallet1<Instance1>;
@@ -16,14 +16,14 @@
// limitations under the License.
use crate::{
construct_runtime::parse::{Pallet, PalletPart, PalletPartKeyword, PalletPath},
construct_runtime::parse::{Pezpallet, PalletPart, PalletPartKeyword, PalletPath},
runtime::parse::PalletDeclaration,
};
use pezframe_support_procedural_tools::get_doc_literals;
use quote::ToTokens;
use syn::{punctuated::Punctuated, spanned::Spanned, token, Error};
impl Pallet {
impl Pezpallet {
pub fn try_from(
attr_span: proc_macro2::Span,
item: &syn::ItemType,
@@ -48,14 +48,14 @@ impl Pallet {
} else {
return Err(Error::new(
attr_span,
"Invalid pallet declaration, expected a path or a trait object",
"Invalid pezpallet declaration, expected a path or a trait object",
));
};
}
let mut path = pezpallet_path.ok_or(Error::new(
attr_span,
"Invalid pallet declaration, expected a path or a trait object",
"Invalid pezpallet declaration, expected a path or a trait object",
))?;
let PalletDeclaration { path: inner, instance, .. } =
@@ -93,7 +93,7 @@ impl Pallet {
let docs = get_doc_literals(&item.attrs);
Ok(Pallet {
Ok(Pezpallet {
is_expanded: true,
name,
index: pezpallet_index,
@@ -119,14 +119,14 @@ fn pezpallet_parsing_works() {
};
let index = 0;
let pallet =
Pallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
let pezpallet =
Pezpallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
.unwrap();
assert_eq!(pallet.name.to_string(), "System");
assert_eq!(pallet.index, index);
assert_eq!(pallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pallet.instance, None);
assert_eq!(pezpallet.name.to_string(), "System");
assert_eq!(pezpallet.index, index);
assert_eq!(pezpallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pezpallet.instance, None);
}
#[test]
@@ -142,14 +142,14 @@ fn pezpallet_parsing_works_with_instance() {
};
let index = 0;
let pallet =
Pallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
let pezpallet =
Pezpallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
.unwrap();
assert_eq!(pallet.name.to_string(), "System");
assert_eq!(pallet.index, index);
assert_eq!(pallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pallet.instance, Some(parse_quote! { Instance1 }));
assert_eq!(pezpallet.name.to_string(), "System");
assert_eq!(pezpallet.index, index);
assert_eq!(pezpallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pezpallet.instance, Some(parse_quote! { Instance1 }));
}
#[test]
@@ -157,7 +157,7 @@ fn pezpallet_parsing_works_with_pallet() {
use syn::{parse_quote, ItemType};
let item: ItemType = parse_quote! {
pub type System = pezframe_system::Pallet<Runtime> + Call;
pub type System = pezframe_system::Pezpallet<Runtime> + Call;
};
let ItemType { ty, .. } = item.clone();
let syn::Type::TraitObject(syn::TypeTraitObject { bounds, .. }) = *ty else {
@@ -165,14 +165,14 @@ fn pezpallet_parsing_works_with_pallet() {
};
let index = 0;
let pallet =
Pallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
let pezpallet =
Pezpallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
.unwrap();
assert_eq!(pallet.name.to_string(), "System");
assert_eq!(pallet.index, index);
assert_eq!(pallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pallet.instance, None);
assert_eq!(pezpallet.name.to_string(), "System");
assert_eq!(pezpallet.index, index);
assert_eq!(pezpallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pezpallet.instance, None);
}
#[test]
@@ -180,7 +180,7 @@ fn pezpallet_parsing_works_with_instance_and_pallet() {
use syn::{parse_quote, ItemType};
let item: ItemType = parse_quote! {
pub type System = pezframe_system::Pallet<Runtime, Instance1> + Call;
pub type System = pezframe_system::Pezpallet<Runtime, Instance1> + Call;
};
let ItemType { ty, .. } = item.clone();
let syn::Type::TraitObject(syn::TypeTraitObject { bounds, .. }) = *ty else {
@@ -188,12 +188,12 @@ fn pezpallet_parsing_works_with_instance_and_pallet() {
};
let index = 0;
let pallet =
Pallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
let pezpallet =
Pezpallet::try_from(proc_macro2::Span::call_site(), &item, index, false, false, &bounds)
.unwrap();
assert_eq!(pallet.name.to_string(), "System");
assert_eq!(pallet.index, index);
assert_eq!(pallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pallet.instance, Some(parse_quote! { Instance1 }));
assert_eq!(pezpallet.name.to_string(), "System");
assert_eq!(pezpallet.index, index);
assert_eq!(pezpallet.path.to_token_stream().to_string(), "pezframe_system");
assert_eq!(pezpallet.instance, Some(parse_quote! { Instance1 }));
}
@@ -17,19 +17,19 @@
use syn::{Ident, PathArguments};
/// The declaration of a pallet.
/// The declaration of a pezpallet.
#[derive(Debug, Clone)]
pub struct PalletDeclaration {
/// The name of the pallet, e.g.`System` in `pub type System = pezframe_system`.
/// The name of the pezpallet, e.g.`System` in `pub type System = pezframe_system`.
pub name: Ident,
/// The path of the pallet, e.g. `pezframe_system` in `pub type System = pezframe_system`.
/// The path of the pezpallet, e.g. `pezframe_system` in `pub type System = pezframe_system`.
pub path: syn::Path,
/// The segment of the pallet, e.g. `Pallet` in `pub type System = pezframe_system::Pallet`.
/// 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 pallet, e.g. `Runtime` in
/// `pub type System = pezframe_system::Pallet<Runtime>`.
/// The runtime parameter of the pezpallet, e.g. `Runtime` in
/// `pub type System = pezframe_system::Pezpallet<Runtime>`.
pub runtime_param: Option<Ident>,
/// The instance of the pallet, e.g. `Instance1` in `pub type Council =
/// The instance of the pezpallet, e.g. `Instance1` in `pub type Council =
/// pezpallet_collective<Instance1>`.
pub instance: Option<Ident>,
}
@@ -52,7 +52,7 @@ impl PalletDeclaration {
args, ..
}) = segment.arguments.clone()
{
if segment.ident == "Pallet" {
if segment.ident == "Pezpallet" {
let mut segment = segment.clone();
segment.arguments = PathArguments::None;
pezpallet_segment = Some(segment.clone());
@@ -62,7 +62,7 @@ impl PalletDeclaration {
args_iter.next()
{
let ident = arg_path.path.require_ident()?.clone();
if segment.ident == "Pallet" {
if segment.ident == "Pezpallet" {
runtime_param = Some(ident);
if let Some(syn::GenericArgument::Type(syn::Type::Path(arg_path))) =
args_iter.next()
@@ -102,7 +102,7 @@ fn declaration_works() {
&parse_quote! { pub type System = pezframe_system; },
&parse_quote! { pezframe_system },
)
.expect("Failed to parse pallet declaration");
.expect("Failed to parse pezpallet declaration");
assert_eq!(decl.name, "System");
assert_eq!(decl.path, parse_quote! { pezframe_system });
@@ -120,7 +120,7 @@ fn declaration_works_with_instance() {
&parse_quote! { pub type System = pezframe_system<Instance1>; },
&parse_quote! { pezframe_system<Instance1> },
)
.expect("Failed to parse pallet declaration");
.expect("Failed to parse pezpallet declaration");
assert_eq!(decl.name, "System");
assert_eq!(decl.path, parse_quote! { pezframe_system });
@@ -135,16 +135,16 @@ fn declaration_works_with_pallet() {
let decl: PalletDeclaration = PalletDeclaration::try_from(
proc_macro2::Span::call_site(),
&parse_quote! { pub type System = pezframe_system::Pallet<Runtime>; },
&parse_quote! { pezframe_system::Pallet<Runtime> },
&parse_quote! { pub type System = pezframe_system::Pezpallet<Runtime>; },
&parse_quote! { pezframe_system::Pezpallet<Runtime> },
)
.expect("Failed to parse pallet declaration");
.expect("Failed to parse pezpallet declaration");
assert_eq!(decl.name, "System");
assert_eq!(decl.path, parse_quote! { pezframe_system });
let segment: syn::PathSegment =
syn::PathSegment { ident: parse_quote! { Pallet }, arguments: PathArguments::None };
syn::PathSegment { ident: parse_quote! { Pezpallet }, arguments: PathArguments::None };
assert_eq!(decl.pezpallet_segment, Some(segment));
assert_eq!(decl.runtime_param, Some(parse_quote! { Runtime }));
assert_eq!(decl.instance, None);
@@ -156,16 +156,16 @@ fn declaration_works_with_pallet_and_instance() {
let decl: PalletDeclaration = PalletDeclaration::try_from(
proc_macro2::Span::call_site(),
&parse_quote! { pub type System = pezframe_system::Pallet<Runtime, Instance1>; },
&parse_quote! { pezframe_system::Pallet<Runtime, Instance1> },
&parse_quote! { pub type System = pezframe_system::Pezpallet<Runtime, Instance1>; },
&parse_quote! { pezframe_system::Pezpallet<Runtime, Instance1> },
)
.expect("Failed to parse pallet declaration");
.expect("Failed to parse pezpallet declaration");
assert_eq!(decl.name, "System");
assert_eq!(decl.path, parse_quote! { pezframe_system });
let segment: syn::PathSegment =
syn::PathSegment { ident: parse_quote! { Pallet }, arguments: PathArguments::None };
syn::PathSegment { ident: parse_quote! { Pezpallet }, arguments: PathArguments::None };
assert_eq!(decl.pezpallet_segment, Some(segment));
assert_eq!(decl.runtime_param, Some(parse_quote! { Runtime }));
assert_eq!(decl.instance, Some(parse_quote! { Instance1 }));
@@ -17,7 +17,7 @@
//! Implementation of the `storage_alias` attribute macro.
use crate::{counter_prefix, pallet::parse::helper};
use crate::{counter_prefix, pezpallet::parse::helper};
use pezframe_support_procedural_tools::generate_access_from_frame_or_crate;
use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
@@ -116,7 +116,7 @@ mod storage_types {
mod prefix_types {
// Use the verbatim/unmodified input name as the prefix.
syn::custom_keyword!(verbatim);
// The input type is a pallet and its pallet name should be used as the prefix.
// The input type is a pezpallet and its pezpallet name should be used as the prefix.
syn::custom_keyword!(pezpallet_name);
// The input type implements `Get<'static str>` and this `str` should be used as the prefix.
syn::custom_keyword!(dynamic);
@@ -459,7 +459,7 @@ impl Parse for Input {
enum PrefixType {
/// An appropriate prefix will be determined automatically.
///
/// If generics are passed, this is assumed to be a pallet and the pallet name should be used.
/// 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.