mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 07:17:56 +00:00
Use pallet names to name enum variants (#8990)
* Remove unused event_metadata variable * Eliminate mod_name and use pallet names to name enum variants * Rename field name `pallet` to `path` * Use only the pallet name to generate variant names * Use new naming scheme for Event enum in sudo pallet tests * Use new naming scheme for Event enum in offences pallet tests * Use new naming scheme for Event enum in contracts pallet tests * Use new naming scheme for Event enum in collective pallet tests * Use new naming scheme for Event enum in bounties pallet tests * Use new naming scheme for Event enum in balances pallet tests * Use new naming scheme for Event enum in assets pallet tests * Use new naming scheme for Event enum in frame support tests * Use new naming scheme for Event enum in tips pallet tests * Use new naming scheme for Event enum in transaction payment pallet tests * Use new naming scheme for GenesisConfig fields in example pallet tests * Use new naming scheme for GenesisConfig fields in elections pallet tests * Use new naming scheme for Event enum in election provider multi-phase pallet tests * Use new naming scheme for Event enum in elections phragmen pallet tests * Use new naming scheme for GenesisConfig fields in chain spec * Use new naming scheme for Event enum in staking pallet mock * Use new naming scheme for GenesisConfig fields in node-template chain spec * Use new naming scheme for GenesisConfig fields in node-testing chain spec * Use new naming scheme for Event enum in node executor tests * Use new naming scheme for GenesisConfig fields in transaction storage pallet mock * Refactor match conditions
This commit is contained in:
@@ -156,7 +156,7 @@ pub struct PalletDeclaration {
|
||||
pub name: Ident,
|
||||
/// Optional fixed index (e.g. `MyPallet ... = 3,`)
|
||||
pub index: Option<u8>,
|
||||
pub pallet: PalletPath,
|
||||
pub path: PalletPath,
|
||||
pub instance: Option<Ident>,
|
||||
pub pallet_parts: Vec<PalletPart>,
|
||||
}
|
||||
@@ -165,7 +165,7 @@ impl Parse for PalletDeclaration {
|
||||
fn parse(input: ParseStream) -> Result<Self> {
|
||||
let name = input.parse()?;
|
||||
let _: Token![:] = input.parse()?;
|
||||
let pallet = input.parse()?;
|
||||
let path = input.parse()?;
|
||||
let instance = if input.peek(Token![<]) {
|
||||
let _: Token![<] = input.parse()?;
|
||||
let res = Some(input.parse()?);
|
||||
@@ -189,7 +189,7 @@ impl Parse for PalletDeclaration {
|
||||
|
||||
let parsed = Self {
|
||||
name,
|
||||
pallet,
|
||||
path,
|
||||
instance,
|
||||
pallet_parts,
|
||||
index,
|
||||
@@ -247,30 +247,6 @@ impl Parse for PalletPath {
|
||||
}
|
||||
}
|
||||
|
||||
impl PalletPath {
|
||||
/// Return the snake-cased module name for this path.
|
||||
pub fn mod_name(&self) -> Ident {
|
||||
let mut iter = self.inner.segments.iter();
|
||||
let mut mod_name = match &iter.next().expect("Path should always have 1 segment; qed").ident {
|
||||
ident if ident == "self" || ident == "super" || ident == "crate" => {
|
||||
// Skip `crate`, `self` and `super` quasi-keywords when creating the module name
|
||||
iter.next()
|
||||
.expect("There must be a path segment pointing to a pallet following \
|
||||
`crate`, `self` or `super`; qed")
|
||||
.ident
|
||||
.clone()
|
||||
}
|
||||
ident => ident.clone(),
|
||||
};
|
||||
|
||||
for segment in iter {
|
||||
mod_name = quote::format_ident!("{}_{}", mod_name, segment.ident);
|
||||
}
|
||||
|
||||
mod_name
|
||||
}
|
||||
}
|
||||
|
||||
impl quote::ToTokens for PalletPath {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
self.inner.to_tokens(tokens);
|
||||
|
||||
Reference in New Issue
Block a user