From c139955410879cb012e44fe4327a094087e3bb11 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 8 Feb 2022 10:15:44 +0000 Subject: [PATCH 1/2] Fix conversion of `Call` struct names to UpperCamelCase --- codegen/src/api/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index d11071f156..635da5ed0f 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -462,7 +462,7 @@ where type_gen, ); CompositeDef::struct_def( - var.name(), + struct_name.as_ref(), Default::default(), fields, Some(parse_quote!(pub)), From 09109f89b4c4ef33b32747b4f6463c0622283c16 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 8 Feb 2022 10:21:09 +0000 Subject: [PATCH 2/2] Update to latest heck and use ToUpperCamelCase --- codegen/Cargo.toml | 2 +- codegen/src/api/calls.rs | 6 +++--- codegen/src/api/constants.rs | 2 +- codegen/src/api/mod.rs | 2 +- codegen/src/api/storage.rs | 2 +- macro/Cargo.toml | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index c2cf3c551d..75965e344f 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -15,7 +15,7 @@ async-trait = "0.1.49" codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] } darling = "0.13.0" frame-metadata = "14.0" -heck = "0.3.2" +heck = "0.4.0" proc-macro2 = "1.0.24" proc-macro-crate = "0.1.5" proc-macro-error = "1.0.4" diff --git a/codegen/src/api/calls.rs b/codegen/src/api/calls.rs index 96fc12fc9c..f6e1e00d87 100644 --- a/codegen/src/api/calls.rs +++ b/codegen/src/api/calls.rs @@ -23,8 +23,8 @@ use frame_metadata::{ PalletMetadata, }; use heck::{ - CamelCase as _, - SnakeCase as _, + ToSnakeCase as _, + ToUpperCamelCase as _, }; use proc_macro2::TokenStream as TokenStream2; use proc_macro_error::abort_call_site; @@ -43,7 +43,7 @@ pub fn generate_calls( let struct_defs = super::generate_structs_from_variants( type_gen, call.ty.id(), - |name| name.to_camel_case().into(), + |name| name.to_upper_camel_case().into(), "Call", ); let (call_structs, call_fns): (Vec<_>, Vec<_>) = struct_defs diff --git a/codegen/src/api/constants.rs b/codegen/src/api/constants.rs index 7cbb988450..d7786a6b39 100644 --- a/codegen/src/api/constants.rs +++ b/codegen/src/api/constants.rs @@ -16,7 +16,7 @@ use crate::types::TypeGenerator; use frame_metadata::PalletConstantMetadata; -use heck::SnakeCase as _; +use heck::ToSnakeCase as _; use proc_macro2::TokenStream as TokenStream2; use quote::{ format_ident, diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index 635da5ed0f..651328261d 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -54,7 +54,7 @@ use frame_metadata::{ RuntimeMetadataPrefixed, StorageEntryType, }; -use heck::SnakeCase as _; +use heck::ToSnakeCase as _; use proc_macro2::TokenStream as TokenStream2; use proc_macro_error::abort_call_site; use quote::{ diff --git a/codegen/src/api/storage.rs b/codegen/src/api/storage.rs index 6e2065c8a8..1a6a8bb5ce 100644 --- a/codegen/src/api/storage.rs +++ b/codegen/src/api/storage.rs @@ -23,7 +23,7 @@ use frame_metadata::{ StorageEntryType, StorageHasher, }; -use heck::SnakeCase as _; +use heck::ToSnakeCase as _; use proc_macro2::TokenStream as TokenStream2; use proc_macro_error::abort_call_site; use quote::{ diff --git a/macro/Cargo.toml b/macro/Cargo.toml index b1267735e4..c8165e2da6 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -19,7 +19,7 @@ async-trait = "0.1.49" codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] } darling = "0.13.0" frame-metadata = "14.0" -heck = "0.3.2" +heck = "0.4.0" proc-macro2 = "1.0.24" proc-macro-crate = "0.1.5" proc-macro-error = "1.0.4"