mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 05:01:08 +00:00
Emit error when construct_runtime imports a non-existent pallet part (#8949)
* Emit error when construct_runtime imports a non-existent Call part * Reword and display pallet name when emitting part not found error * Migrate decl_outer_dispatch to a proc macro * Rename calls.rs to call.rs * Create new construct_runtime_v2 macro * Add UI test for importing non-existent call part in construct_runtime * Emit error when construct_runtime imports a non-existent Config part * Emit error when construct_runtime imports a non-existent Event part * Migrate decl_outer_inherent to a proc macro * Emit error when construct_runtime imports a non-existent Inherent part * Migrate decl_outer_validate_unsigned to a proc macro * Emit error when construct_runtime imports a non-existent ValidateUnsigned part * impl for old macro * fix line width * add doc * hide macroes and use unique counter everywhere * Remove construct_runtime_v2 * Encapsulate pallet part check macros in a module * Fix macro definitions in dummy part checker * Tag ProvideInherent impl with #[pallet::inherent] properly for authorship pallet * Remove Call part from pallets that do not define it * Add Call part unit tests * Remove undefined Call part import from offences pallet * Add tests for expand_outer_inherent * Remove Call part from pallets that do not define them * Remove Call part imports from pallets that do not have it defined * Remove Call part import of the offences pallet from grandpa pallet mocks * Update frame/support/test/tests/pallet.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Remove Call part imports for pallets that do not define them * Move inherent tests to inherent_expand * Add unit tests for expand_outer_validate_unsigned * Add newline at the end of file * fix ui test * Small prayer to RNGsus for fixing CI * Remove Call part from construct_runtime for randomness collective flip pallet * Remove Call part import for randomness collective flip pallet * Summon Laplace's demon instead of praying to RNGsus * Update test expectations * fix ui test and make sure it's flaky * Revert "fix ui test and make sure it's flaky" This reverts commit 362b6881389c911ef8d9ef85d71c9463f5694b20. * Comment out test instead of putting it in conditional compilation * Update UI test expectations * Update UI test expectations * Emit error when construct_runtime imports a non-existent Origin part Co-authored-by: thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Denis P <denis.pisarev@parity.io>
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
use proc_macro::TokenStream;
|
||||
use crate::COUNTER;
|
||||
|
||||
pub fn generate_dummy_part_checker(input: TokenStream) -> TokenStream {
|
||||
if !input.is_empty() {
|
||||
return syn::Error::new(proc_macro2::Span::call_site(), "No arguments expected")
|
||||
.to_compile_error().into()
|
||||
}
|
||||
|
||||
let count = COUNTER.with(|counter| counter.borrow_mut().inc());
|
||||
|
||||
let genesis_config_macro_ident = syn::Ident::new(
|
||||
&format!("__is_genesis_config_defined_{}", count),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let event_macro_ident = syn::Ident::new(
|
||||
&format!("__is_event_part_defined_{}", count),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let inherent_macro_ident = syn::Ident::new(
|
||||
&format!("__is_inherent_part_defined_{}", count),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let validate_unsigned_macro_ident = syn::Ident::new(
|
||||
&format!("__is_validate_unsigned_part_defined_{}", count),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let call_macro_ident = syn::Ident::new(
|
||||
&format!("__is_call_part_defined_{}", count),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let origin_macro_ident = syn::Ident::new(
|
||||
&format!("__is_origin_part_defined_{}", count),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
|
||||
quote::quote!(
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_genesis_config_check {
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! #genesis_config_macro_ident {
|
||||
($pallet_name:ident) => {};
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub use #genesis_config_macro_ident as is_genesis_config_defined;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_event_check {
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! #event_macro_ident {
|
||||
($pallet_name:ident) => {};
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub use #event_macro_ident as is_event_part_defined;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_inherent_check {
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! #inherent_macro_ident {
|
||||
($pallet_name:ident) => {};
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub use #inherent_macro_ident as is_inherent_part_defined;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_validate_unsigned_check {
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! #validate_unsigned_macro_ident {
|
||||
($pallet_name:ident) => {};
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub use #validate_unsigned_macro_ident as is_validate_unsigned_part_defined;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_call_check {
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! #call_macro_ident {
|
||||
($pallet_name:ident) => {};
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub use #call_macro_ident as is_call_part_defined;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_origin_check {
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! #origin_macro_ident {
|
||||
($pallet_name:ident) => {};
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub use #origin_macro_ident as is_origin_part_defined;
|
||||
}
|
||||
).into()
|
||||
}
|
||||
Reference in New Issue
Block a user