mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 16:55:43 +00:00
Support extra constant renaming (#9814)
* Rebased with master. Resolved merge conflict in frame/support/test/tests/pallet.rs * Switching Account ID to SomeType1, as SomeType3 was giving me conversion error. * Wrong indent config. Fixed. * These tabs look fine locally, but look different on Github. Trying to get the style config right. * Parsing pallet::constant_name. Passing unit tests, which is confusing because I didn't change `ident` in the ExtraConstantDef initialization. * Finalized parsing of extra constant name by adding optional metadata field. Added expansion logic that replaces respective `idents` where they exist. * Erasing this to try to keep the format the same across the source code. * Another formatting change for consistency. * Update frame/support/procedural/src/pallet/expand/constants.rs strictly more idiomatic. Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/support/procedural/src/pallet/parse/extra_constants.rs strictly idiomatic change. Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fixing formatting and CI warnings. * switched to nightly compiler to use rustfmt.toml Co-authored-by: Eric Miller <emiller@lirio.co> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -26,6 +26,8 @@ struct ConstDef {
|
||||
pub doc: Vec<syn::Lit>,
|
||||
/// default_byte implementation
|
||||
pub default_byte_impl: proc_macro2::TokenStream,
|
||||
/// Constant name for Metadata (optional)
|
||||
pub metadata_name: Option<syn::Ident>,
|
||||
}
|
||||
|
||||
///
|
||||
@@ -54,6 +56,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
#frame_support::traits::Get<#const_type>>::get();
|
||||
#frame_support::codec::Encode::encode(&value)
|
||||
),
|
||||
metadata_name: None,
|
||||
}
|
||||
});
|
||||
|
||||
@@ -68,13 +71,14 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
let value = <Pallet<#type_use_gen>>::#ident();
|
||||
#frame_support::codec::Encode::encode(&value)
|
||||
),
|
||||
metadata_name: const_.metadata_name.clone(),
|
||||
}
|
||||
});
|
||||
|
||||
let consts = config_consts.chain(extra_consts).map(|const_| {
|
||||
let const_type = &const_.type_;
|
||||
let ident = &const_.ident;
|
||||
let ident_str = format!("{}", ident);
|
||||
let ident_str = format!("{}", const_.metadata_name.unwrap_or(const_.ident));
|
||||
|
||||
let doc = const_.doc.clone().into_iter();
|
||||
let default_byte_impl = &const_.default_byte_impl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user