Merge remote-tracking branch 'origin/master' into lexnv/codegen-config

This commit is contained in:
Alexandru Vasile
2024-09-13 18:59:58 +03:00
111 changed files with 24479 additions and 7527 deletions
+4 -1
View File
@@ -25,7 +25,7 @@ quote = { workspace = true }
syn = { workspace = true }
scale-info = { workspace = true }
subxt-metadata = { workspace = true }
jsonrpsee = { workspace = true, features = ["async-client", "client-ws-transport-native-tls", "http-client"], optional = true }
jsonrpsee = { workspace = true, features = ["async-client", "client-ws-transport-tls", "http-client"], optional = true }
hex = { workspace = true, features = ["std"] }
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
thiserror = { workspace = true }
@@ -43,3 +43,6 @@ rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.playground]
defalt-features = true
[lints]
workspace = true
+1 -1
View File
@@ -262,7 +262,7 @@ impl RuntimeGenerator {
/// The outer extrinsic enum.
pub type Call = #call_path;
/// The outer error enum representing the DispatchError's Module variant.
/// The outer error enum represents the DispatchError's Module variant.
pub type Error = #error_path;
pub fn constants() -> ConstantsApi {
+1 -1
View File
@@ -22,7 +22,7 @@ fn generate_runtime_api(
type_gen: &TypeGenerator,
crate_path: &syn::Path,
) -> Result<(TokenStream2, TokenStream2), CodegenError> {
// Trait name must remain as is (upper case) to identity the runtime call.
// Trait name must remain as is (upper case) to identify the runtime call.
let trait_name_str = api.name();
// The snake case for the trait name.
let trait_name_snake = format_ident!("{}", api.name().to_snake_case());
+3
View File
@@ -57,6 +57,9 @@ pub enum CodegenError {
/// Cannot generate types.
#[error("Type Generation failed: {0}")]
TypeGeneration(#[from] TypegenError),
/// Error when generating metadata from Wasm-runtime
#[error("Failed to generate metadata from wasm file. reason: {0}")]
Wasm(String),
}
impl CodegenError {
+7 -2
View File
@@ -342,10 +342,11 @@ fn default_derives(crate_path: &syn::Path) -> DerivesRegistry {
parse_quote!(Debug),
];
let attributes: [syn::Attribute; 3] = [
let attributes: [syn::Attribute; 4] = [
parse_quote!(#[encode_as_type(crate_path = #encode_crate_path)]),
parse_quote!(#[decode_as_type(crate_path = #decode_crate_path)]),
parse_quote!(#[codec(crate = #crate_path::ext::codec)]),
parse_quote!(#[codec(dumb_trait_bound)]),
];
let mut derives_registry = DerivesRegistry::new();
@@ -357,7 +358,7 @@ fn default_derives(crate_path: &syn::Path) -> DerivesRegistry {
fn default_substitutes(crate_path: &syn::Path) -> TypeSubstitutes {
let mut type_substitutes = TypeSubstitutes::new();
let defaults: [(syn::Path, syn::Path); 12] = [
let defaults: [(syn::Path, syn::Path); 13] = [
(
parse_quote!(bitvec::order::Lsb0),
parse_quote!(#crate_path::utils::bits::Lsb0),
@@ -370,6 +371,10 @@ fn default_substitutes(crate_path: &syn::Path) -> TypeSubstitutes {
parse_quote!(sp_core::crypto::AccountId32),
parse_quote!(#crate_path::utils::AccountId32),
),
(
parse_quote!(fp_account::AccountId20),
parse_quote!(#crate_path::utils::AccountId20),
),
(
parse_quote!(sp_runtime::multiaddress::MultiAddress),
parse_quote!(#crate_path::utils::MultiAddress),