From 8e1b63743b24d7aa5d1643deda26df8720c14421 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Fri, 25 Aug 2023 14:01:21 +0200 Subject: [PATCH 01/25] minor api changes --- cli/src/commands/diff.rs | 46 ++++++++++++---------------- codegen/src/api/mod.rs | 2 +- codegen/src/api/storage.rs | 5 +-- codegen/src/lib.rs | 5 ++- codegen/src/types/type_def.rs | 5 +++ codegen/src/types/type_def_params.rs | 5 +++ metadata/src/lib.rs | 17 ++++++++++ 7 files changed, 53 insertions(+), 32 deletions(-) diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index 9200e85209..54c054e924 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -220,40 +220,34 @@ impl StorageEntryDiff { metadata_1: &Metadata, metadata_2: &Metadata, ) -> Self { - let value_1_ty_id = match storage_entry_1.entry_type() { - StorageEntryType::Plain(value_ty) | StorageEntryType::Map { value_ty, .. } => value_ty, - }; + let value_1_ty_id = storage_entry_1.entry_type().value_ty(); let value_1_hash = metadata_1 .type_hash(*value_1_ty_id) .expect("type should be present"); - let value_2_ty_id = match storage_entry_2.entry_type() { - StorageEntryType::Plain(value_ty) | StorageEntryType::Map { value_ty, .. } => value_ty, - }; + let value_2_ty_id = storage_entry_2.entry_type().value_ty(); let value_2_hash = metadata_1 .type_hash(*value_2_ty_id) .expect("type should be present"); let value_different = value_1_hash != value_2_hash; - let key_1_hash = match storage_entry_1.entry_type() { - StorageEntryType::Plain(_) => None, - StorageEntryType::Map { key_ty, .. } => Some(*key_ty), - } - .map(|key_ty| { - metadata_1 - .type_hash(key_ty) - .expect("type should be present") - }) - .unwrap_or_default(); - let key_2_hash = match storage_entry_2.entry_type() { - StorageEntryType::Plain(_) => None, - StorageEntryType::Map { key_ty, .. } => Some(*key_ty), - } - .map(|key_ty| { - metadata_2 - .type_hash(key_ty) - .expect("type should be present") - }) - .unwrap_or_default(); + let key_1_hash = storage_entry_1 + .entry_type() + .key_ty() + .map(|key_ty| { + metadata_1 + .type_hash(key_ty) + .expect("type should be present") + }) + .unwrap_or_default(); + let key_2_hash = storage_entry_2 + .entry_type() + .key_ty() + .map(|key_ty| { + metadata_2 + .type_hash(key_ty) + .expect("type should be present") + }) + .unwrap_or_default(); let key_different = key_1_hash != key_2_hash; StorageEntryDiff { diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index 7802ba7ea9..b1523488ea 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -233,7 +233,7 @@ impl RuntimeGenerator { /// unique path, so that types with matching paths don't end up overwriting each other /// in the codegen. We ignore any types with generics; Subxt actually endeavours to /// de-duplicate those into single types with a generic. - fn ensure_unique_type_paths(metadata: &mut Metadata) { + pub fn ensure_unique_type_paths(metadata: &mut Metadata) { let mut visited_path_counts = HashMap::, usize>::new(); for ty in metadata.types_mut().types.iter_mut() { // Ignore types without a path (ie prelude types). diff --git a/codegen/src/api/storage.rs b/codegen/src/api/storage.rs index 9712fe7f35..ca2dcafa14 100644 --- a/codegen/src/api/storage.rs +++ b/codegen/src/api/storage.rs @@ -93,10 +93,7 @@ fn generate_storage_entry_fns( }; let snake_case_name = storage_entry.name().to_snake_case(); - let storage_entry_ty = match storage_entry.entry_type() { - StorageEntryType::Plain(ty) => *ty, - StorageEntryType::Map { value_ty, .. } => *value_ty, - }; + let storage_entry_ty = storage_entry.entry_type().value_ty(); let storage_entry_value_ty = type_gen.resolve_type_path(storage_entry_ty); let docs = storage_entry.docs(); let docs = should_gen_docs diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index be2e27e0d2..30f607ef0d 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -55,5 +55,8 @@ pub mod utils; pub use self::{ api::{GenerateRuntimeApi, RuntimeGenerator}, error::{CodegenError, TypeSubstitutionError}, - types::{CratePath, Derives, DerivesRegistry, Module, TypeGenerator, TypeSubstitutes}, + types::{ + CratePath, Derives, DerivesRegistry, Module, TypeDefGen, TypeDefParameters, TypeGenerator, + TypeSubstitutes, + }, }; diff --git a/codegen/src/types/type_def.rs b/codegen/src/types/type_def.rs index 25fa02556a..57470abf7f 100644 --- a/codegen/src/types/type_def.rs +++ b/codegen/src/types/type_def.rs @@ -118,6 +118,11 @@ impl TypeDefGen { ty_docs, }) } + + /// are there unused type params? + pub fn has_unused_type_params(&self) -> bool { + self.type_params.has_unused_type_params() + } } impl quote::ToTokens for TypeDefGen { diff --git a/codegen/src/types/type_def_params.rs b/codegen/src/types/type_def_params.rs index 15dc5b6bc2..155029fdd4 100644 --- a/codegen/src/types/type_def_params.rs +++ b/codegen/src/types/type_def_params.rs @@ -60,6 +60,11 @@ impl TypeDefParameters { pub fn params(&self) -> &[TypeParameter] { &self.params } + + /// Returns true if there are any unused type params + pub fn has_unused_type_params(&self) -> bool { + !self.unused.is_empty() + } } impl quote::ToTokens for TypeDefParameters { diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index c76ce8fd6b..81a7f47bd4 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -395,6 +395,23 @@ pub enum StorageEntryType { }, } +impl StorageEntryType { + /// returns the type of the value. + pub fn value_ty(&self) -> u32 { + match self { + StorageEntryType::Map { value_ty, .. } | StorageEntryType::Plain(value_ty) => *value_ty, + } + } + + /// The type of the key, can be a tuple with elements for each of the hashers. None for a Plain storage entry + pub fn key_ty(&self) -> Option { + match self { + StorageEntryType::Map { key_ty, .. } => Some(*key_ty), + StorageEntryType::Plain(_) => None, + } + } +} + /// Hasher used by storage maps. #[derive(Debug, Clone, Copy)] pub enum StorageHasher { From dcc1f0836e7c21bb12ffdf894ad5915bbbc366bf Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 29 Aug 2023 18:24:25 +0200 Subject: [PATCH 02/25] parsing instead of format_ident! --- codegen/src/api/custom_values.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codegen/src/api/custom_values.rs b/codegen/src/api/custom_values.rs index e131a80cca..839d3a504f 100644 --- a/codegen/src/api/custom_values.rs +++ b/codegen/src/api/custom_values.rs @@ -47,7 +47,8 @@ fn generate_custom_value_fn( if fn_names_taken.contains(&fn_name) { return None; } - let fn_name_ident = format_ident!("{fn_name}"); + // if the fn_name would be an invalid ident, return None: + let fn_name_ident = syn::parse_str::(&fn_name).ok()?; fn_names_taken.insert(fn_name); let custom_value_hash = custom_value.hash(); From d11c76ef473b773e8e7bae0f8d274cc3a24b4b18 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 29 Aug 2023 18:29:36 +0200 Subject: [PATCH 03/25] fix self issue --- codegen/src/api/custom_values.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/src/api/custom_values.rs b/codegen/src/api/custom_values.rs index 839d3a504f..8b03d72325 100644 --- a/codegen/src/api/custom_values.rs +++ b/codegen/src/api/custom_values.rs @@ -55,7 +55,7 @@ fn generate_custom_value_fn( let return_ty = type_gen.resolve_type_path(custom_value.type_id()); Some(quote!( - pub fn #fn_name_ident() -> #crate_path::custom_values::StaticAddress<#return_ty> { + pub fn #fn_name_ident(&self) -> #crate_path::custom_values::StaticAddress<#return_ty> { #crate_path::custom_values::StaticAddress::new_static(#name, [#(#custom_value_hash,)*]) } )) From da83ec00962ef5be99968d85c6b786d3d81867aa Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Thu, 31 Aug 2023 23:48:52 +0200 Subject: [PATCH 04/25] expose types on typegen --- codegen/src/types/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codegen/src/types/mod.rs b/codegen/src/types/mod.rs index 2e8d1611be..ae7d093332 100644 --- a/codegen/src/types/mod.rs +++ b/codegen/src/types/mod.rs @@ -117,6 +117,11 @@ impl<'a> TypeGenerator<'a> { .clone() } + /// Returns a reference to its `PortableRegistry` + pub fn types(&self) -> &PortableRegistry { + &self.type_registry + } + /// Get the type path for a field of a struct or an enum variant, providing any generic /// type parameters from the containing type. This is for identifying where a generic type /// parameter is used in a field type e.g. From 6204c6d0959bef8e8660d90542b4cfca6cdf3187 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 11 Sep 2023 13:25:56 +0200 Subject: [PATCH 05/25] web wasm support via feature flag --- Cargo.lock | 1 + codegen/Cargo.toml | 21 +++++++++++++++++---- codegen/src/api/custom_values.rs | 2 +- codegen/src/api/mod.rs | 6 +++++- codegen/src/api/storage.rs | 1 + codegen/src/error.rs | 1 + codegen/src/lib.rs | 5 +++++ codegen/src/types/mod.rs | 2 +- metadata/Cargo.toml | 4 +++- 9 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f01c4fb8e..ff6b6924ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4211,6 +4211,7 @@ version = "0.31.0" dependencies = [ "bitvec", "frame-metadata 16.0.0", + "getrandom 0.2.10", "heck", "hex", "jsonrpsee", diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 18609661fb..efa5650c07 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -12,19 +12,32 @@ documentation = "https://docs.rs/subxt-codegen" homepage.workspace = true description = "Generate an API for interacting with a substrate node from FRAME metadata" +[features] +default = ["fetch_metadata"] +fetch_metadata = ["dep:jsonrpsee", "dep:tokio", "dep:frame-metadata"] +web = ["getrandom/js"] + [dependencies] -codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } -frame-metadata = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true, features = [ + "derive", +] } +frame-metadata = { workspace = true, optional = true } heck = { workspace = true } proc-macro2 = { workspace = true } 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"] } +jsonrpsee = { workspace = true, features = [ + "async-client", + "client-ws-transport-native-tls", + "http-client", +], optional = true } hex = { workspace = true } -tokio = { workspace = true, features = ["rt-multi-thread"] } +tokio = { workspace = true, features = ["rt-multi-thread"], optional = true } thiserror = { workspace = true } +getrandom = { workspace = true, optional = true } + [dev-dependencies] bitvec = { workspace = true } diff --git a/codegen/src/api/custom_values.rs b/codegen/src/api/custom_values.rs index 8b03d72325..b50d24c6c1 100644 --- a/codegen/src/api/custom_values.rs +++ b/codegen/src/api/custom_values.rs @@ -9,7 +9,7 @@ use heck::ToSnakeCase as _; use subxt_metadata::{CustomValueMetadata, Metadata}; use proc_macro2::TokenStream as TokenStream2; -use quote::{format_ident, quote}; +use quote::{quote}; /// Generate the custom values mod, if there are any custom values in the metadata. Else returns None. pub fn generate_custom_values<'a>( diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index b1523488ea..4769709667 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -20,9 +20,12 @@ use crate::error::CodegenError; use crate::{ ir, types::{CompositeDef, CompositeDefFields, TypeGenerator, TypeSubstitutes}, - utils::{fetch_metadata_bytes_blocking, MetadataVersion, Url}, CratePath, }; + +#[cfg(feature = "fetch_metadata")] +use crate::utils::{fetch_metadata_bytes_blocking, MetadataVersion, Url}; + use codec::Decode; use heck::ToSnakeCase as _; use proc_macro2::TokenStream as TokenStream2; @@ -146,6 +149,7 @@ impl GenerateRuntimeApi { /// # Warning /// /// Not recommended to be used in production environments. + #[cfg(feature = "fetch_metadata")] pub fn generate_from_url(self, url: Url) -> Result { fn fetch_metadata(url: Url, version: MetadataVersion) -> Result { let bytes = fetch_metadata_bytes_blocking(url, version)?; diff --git a/codegen/src/api/storage.rs b/codegen/src/api/storage.rs index 988679e7a9..9d8784ec82 100644 --- a/codegen/src/api/storage.rs +++ b/codegen/src/api/storage.rs @@ -170,6 +170,7 @@ fn primitive_type_alias(type_path: &TypePath) -> TokenStream { quote!(#type_path) } +#[cfg(feature = "fetch_metadata")] #[cfg(test)] mod tests { use crate::RuntimeGenerator; diff --git a/codegen/src/error.rs b/codegen/src/error.rs index f293df2ee6..95110ead0c 100644 --- a/codegen/src/error.rs +++ b/codegen/src/error.rs @@ -87,6 +87,7 @@ pub enum FetchMetadataError { DecodeError(#[from] hex::FromHexError), #[error("Cannot scale encode/decode value: {0}")] CodecError(#[from] codec::Error), + #[cfg(feature = "fetch_metadata")] #[error("Request error: {0}")] RequestError(#[from] jsonrpsee::core::Error), #[error("'{0}' not supported, supported URI schemes are http, https, ws or wss.")] diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 30f607ef0d..f5d1294af2 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -50,8 +50,13 @@ mod error; mod ir; mod types; +#[cfg(feature = "fetch_metadata")] pub mod utils; +#[cfg(feature = "web")] +#[allow(unused_imports)] +pub use getrandom as _; + pub use self::{ api::{GenerateRuntimeApi, RuntimeGenerator}, error::{CodegenError, TypeSubstitutionError}, diff --git a/codegen/src/types/mod.rs b/codegen/src/types/mod.rs index ae7d093332..a68d8c09ff 100644 --- a/codegen/src/types/mod.rs +++ b/codegen/src/types/mod.rs @@ -119,7 +119,7 @@ impl<'a> TypeGenerator<'a> { /// Returns a reference to its `PortableRegistry` pub fn types(&self) -> &PortableRegistry { - &self.type_registry + self.type_registry } /// Get the type path for a field of a struct or an enum variant, providing any generic diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml index 6e3669278d..5cdeabd106 100644 --- a/metadata/Cargo.toml +++ b/metadata/Cargo.toml @@ -14,7 +14,9 @@ homepage.workspace = true description = "Command line utilities for checking metadata compatibility between nodes." [dependencies] -codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } +codec = { package = "parity-scale-codec", workspace = true, features = [ + "derive", +] } frame-metadata = { workspace = true } scale-info = { workspace = true } sp-core-hashing = { workspace = true } From 7dbae5dc779780ab7989d70cc19069e636317668 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Mon, 11 Sep 2023 14:44:16 +0200 Subject: [PATCH 06/25] fmt and clippy --- cli/src/commands/diff.rs | 5 ++--- codegen/src/api/custom_values.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index 54c054e924..50439ebe93 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -13,7 +13,6 @@ use scale_info::Variant; use subxt_metadata::{ ConstantMetadata, Metadata, PalletMetadata, RuntimeApiMetadata, StorageEntryMetadata, - StorageEntryType, }; /// Explore the differences between two nodes @@ -222,11 +221,11 @@ impl StorageEntryDiff { ) -> Self { let value_1_ty_id = storage_entry_1.entry_type().value_ty(); let value_1_hash = metadata_1 - .type_hash(*value_1_ty_id) + .type_hash(value_1_ty_id) .expect("type should be present"); let value_2_ty_id = storage_entry_2.entry_type().value_ty(); let value_2_hash = metadata_1 - .type_hash(*value_2_ty_id) + .type_hash(value_2_ty_id) .expect("type should be present"); let value_different = value_1_hash != value_2_hash; diff --git a/codegen/src/api/custom_values.rs b/codegen/src/api/custom_values.rs index b50d24c6c1..e9d4653008 100644 --- a/codegen/src/api/custom_values.rs +++ b/codegen/src/api/custom_values.rs @@ -9,7 +9,7 @@ use heck::ToSnakeCase as _; use subxt_metadata::{CustomValueMetadata, Metadata}; use proc_macro2::TokenStream as TokenStream2; -use quote::{quote}; +use quote::quote; /// Generate the custom values mod, if there are any custom values in the metadata. Else returns None. pub fn generate_custom_values<'a>( From d1964107f789cda313e16372fe3659fc28e8d834 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 12 Sep 2023 12:20:19 +0200 Subject: [PATCH 07/25] small adjustments --- codegen/Cargo.toml | 4 +--- codegen/src/lib.rs | 8 ++++++++ metadata/src/lib.rs | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index efa5650c07..81ff71dcc6 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -18,9 +18,7 @@ fetch_metadata = ["dep:jsonrpsee", "dep:tokio", "dep:frame-metadata"] web = ["getrandom/js"] [dependencies] -codec = { package = "parity-scale-codec", workspace = true, features = [ - "derive", -] } +codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } frame-metadata = { workspace = true, optional = true } heck = { workspace = true } proc-macro2 = { workspace = true } diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index f5d1294af2..ea70554728 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -53,6 +53,14 @@ mod types; #[cfg(feature = "fetch_metadata")] pub mod utils; +#[cfg(any( + all(feature = "web", feature = "fetch_metadata"), + not(any(feature = "web", feature = "fetch_metadata")) +))] +compile_error!( + "subxt-codegen: exactly one of the 'web' and 'fetch_metadata' features should be used." +); + #[cfg(feature = "web")] #[allow(unused_imports)] pub use getrandom as _; diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index 93813bd88e..daf8fa255c 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -396,14 +396,14 @@ pub enum StorageEntryType { } impl StorageEntryType { - /// returns the type of the value. + /// The type of the value. pub fn value_ty(&self) -> u32 { match self { StorageEntryType::Map { value_ty, .. } | StorageEntryType::Plain(value_ty) => *value_ty, } } - /// The type of the key, can be a tuple with elements for each of the hashers. None for a Plain storage entry + /// The type of the key, can be a tuple with elements for each of the hashers. None for a Plain storage entry. pub fn key_ty(&self) -> Option { match self { StorageEntryType::Map { key_ty, .. } => Some(*key_ty), From 5d9e8178187c7304db6ff0e08176258d6bdb0a71 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 12 Sep 2023 12:22:12 +0200 Subject: [PATCH 08/25] remove exposing of types() in type generator --- codegen/src/types/mod.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/codegen/src/types/mod.rs b/codegen/src/types/mod.rs index a68d8c09ff..2e8d1611be 100644 --- a/codegen/src/types/mod.rs +++ b/codegen/src/types/mod.rs @@ -117,11 +117,6 @@ impl<'a> TypeGenerator<'a> { .clone() } - /// Returns a reference to its `PortableRegistry` - pub fn types(&self) -> &PortableRegistry { - self.type_registry - } - /// Get the type path for a field of a struct or an enum variant, providing any generic /// type parameters from the containing type. This is for identifying where a generic type /// parameter is used in a field type e.g. From 6281fd292e98e3813bba9bd764298a06a984b17d Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 12 Sep 2023 12:40:24 +0200 Subject: [PATCH 09/25] adjust compile error --- codegen/src/lib.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index ea70554728..e7300c00d4 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -53,13 +53,8 @@ mod types; #[cfg(feature = "fetch_metadata")] pub mod utils; -#[cfg(any( - all(feature = "web", feature = "fetch_metadata"), - not(any(feature = "web", feature = "fetch_metadata")) -))] -compile_error!( - "subxt-codegen: exactly one of the 'web' and 'fetch_metadata' features should be used." -); +#[cfg(any(all(feature = "web", feature = "fetch_metadata")))] +compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be used together."); #[cfg(feature = "web")] #[allow(unused_imports)] From 3722035fdc3c09130e6b2e0c164190a5d9656945 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 12 Sep 2023 12:59:04 +0200 Subject: [PATCH 10/25] remove little any flag --- codegen/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index e7300c00d4..f98abfe12e 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -53,7 +53,7 @@ mod types; #[cfg(feature = "fetch_metadata")] pub mod utils; -#[cfg(any(all(feature = "web", feature = "fetch_metadata")))] +#[cfg(all(feature = "web", feature = "fetch_metadata"))] compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be used together."); #[cfg(feature = "web")] From 9f7a2798a9461f397900701ed5ed059c67ea51e9 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 12 Sep 2023 17:51:26 +0200 Subject: [PATCH 11/25] Need access to the type registry from the typegen again --- codegen/src/types/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codegen/src/types/mod.rs b/codegen/src/types/mod.rs index 2e8d1611be..f565fb0460 100644 --- a/codegen/src/types/mod.rs +++ b/codegen/src/types/mod.rs @@ -262,6 +262,11 @@ impl<'a> TypeGenerator<'a> { self.derives.default_derives() } + /// Returns the type registry. + pub fn types(&self) -> &PortableRegistry { + self.type_registry + } + /// Returns the derives to be applied to a generated type. pub fn type_derives(&self, ty: &Type) -> Result { let joined_path = ty.path.segments.join("::"); From a99138116516c6401331c3bcfcae31acb2ac7164 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:35:39 +0300 Subject: [PATCH 12/25] Bump proc-macro2 from 1.0.66 to 1.0.67 (#1164) Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.66 to 1.0.67. - [Release notes](https://github.com/dtolnay/proc-macro2/releases) - [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.66...1.0.67) --- updated-dependencies: - dependency-name: proc-macro2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fa0415c39..cdfdb30196 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2824,9 +2824,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index 52a7149272..28ea35e3aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ jsonrpsee = { version = "0.20" } pretty_assertions = "1.4.0" primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "scale-info", "serde"] } proc-macro-error = "1.0.4" -proc-macro2 = "1.0.66" +proc-macro2 = "1.0.67" quote = "1.0.33" regex = "1.9.5" scale-info = "2.9.0" From 260e386a44bc77e294952820a42c15316df0c742 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:36:00 +0300 Subject: [PATCH 13/25] Bump serde_json from 1.0.106 to 1.0.107 (#1166) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.106 to 1.0.107. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.106...v1.0.107) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdfdb30196..763801ded0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3480,9 +3480,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 28ea35e3aa..f193987fd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ scale-bits = "0.4.0" scale-decode = "0.9.0" scale-encode = "0.5.0" serde = { version = "1.0.188" } -serde_json = { version = "1.0.106" } +serde_json = { version = "1.0.107" } syn = { version = "2.0.15", features = ["full", "extra-traits"] } thiserror = "1.0.48" tokio = { version = "1.32", default-features = false } From a1ea890e9d25536cb31d0099d026f15e87df29f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:36:16 +0300 Subject: [PATCH 14/25] Bump trybuild from 1.0.84 to 1.0.85 (#1167) Bumps [trybuild](https://github.com/dtolnay/trybuild) from 1.0.84 to 1.0.85. - [Release notes](https://github.com/dtolnay/trybuild/releases) - [Commits](https://github.com/dtolnay/trybuild/compare/1.0.84...1.0.85) --- updated-dependencies: - dependency-name: trybuild dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 763801ded0..64acb76000 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4749,9 +4749,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5c89fd17b7536f2cf66c97cff6e811e89e728ca0ed13caeed610c779360d8b4" +checksum = "196a58260a906cedb9bf6d8034b6379d0c11f552416960452f267402ceeddff1" dependencies = [ "basic-toml", "glob 0.3.1", diff --git a/Cargo.toml b/Cargo.toml index f193987fd8..86b39d709b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ tokio = { version = "1.32", default-features = false } tracing = "0.1.34" tracing-wasm = "0.2.1" tracing-subscriber = "0.3.17" -trybuild = "1.0.84" +trybuild = "1.0.85" wabt = "0.10.0" wasm-bindgen-test = "0.3.24" which = "4.4.2" From ed22f430f323c93cb8f0aa1e10e5c5cd6714eb58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 12:59:27 +0300 Subject: [PATCH 15/25] Bump Swatinem/rust-cache from 2.6.2 to 2.7.0 (#1168) Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.6.2 to 2.7.0. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/e207df5d269b42b69c8bc5101da26f7d31feddb4...a95ba195448af2da9b00fb742d14ffaaf3c21f43) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/nightly.yml | 2 +- .github/workflows/rust.yml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f8cd0d6a8d..ccf90cb64e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -35,7 +35,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Cargo test uses: actions-rs/cargo@v1.0.3 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 67943a11bb..d55efb2b65 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -47,7 +47,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Install cargo-hack uses: baptiste0928/cargo-install@v2 @@ -99,7 +99,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 # Check WASM examples, which aren't a part of the workspace and so are otherwise missed: - name: Cargo check WASM examples @@ -122,7 +122,7 @@ jobs: components: rustfmt - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Cargo fmt uses: actions-rs/cargo@v1.0.3 @@ -153,7 +153,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Check internal documentation links run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc -vv --workspace --no-deps --document-private-items @@ -187,7 +187,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Install cargo-nextest run: cargo install cargo-nextest @@ -222,7 +222,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Run tests uses: actions-rs/cargo@v1.0.3 @@ -254,7 +254,7 @@ jobs: override: true - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Run clippy uses: actions-rs/cargo@v1 @@ -279,7 +279,7 @@ jobs: uses: browser-actions/setup-chrome@latest - name: Rust Cache - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - name: Download Substrate run: | From 9d6c404eaeb9460469ef18b155d46bbb3ca36507 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 12:59:49 +0300 Subject: [PATCH 16/25] Bump jsonrpsee from 0.20.0 to 0.20.1 (#1165) Bumps [jsonrpsee](https://github.com/paritytech/jsonrpsee) from 0.20.0 to 0.20.1. - [Release notes](https://github.com/paritytech/jsonrpsee/releases) - [Changelog](https://github.com/paritytech/jsonrpsee/blob/v0.20.1/CHANGELOG.md) - [Commits](https://github.com/paritytech/jsonrpsee/compare/v0.20.0...v0.20.1) --- updated-dependencies: - dependency-name: jsonrpsee dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64acb76000..d427381607 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1608,9 +1608,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "gloo-net" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66b4e3c7d9ed8d315fd6b97c8b1f74a7c6ecbbc2320e65ae7ed38b7068cc620" +checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" dependencies = [ "futures-channel", "futures-core", @@ -1641,9 +1641,9 @@ dependencies = [ [[package]] name = "gloo-utils" -version = "0.1.7" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" dependencies = [ "js-sys", "serde", @@ -2060,9 +2060,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8002beb64691edce321fc16cdba91916b10d798f9d480a05467b0ee98463c03b" +checksum = "9ad9b31183a8bcbe843e32ca8554ad2936633548d95a7bb6a8e14c767dea6b05" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -2072,9 +2072,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310f9566a32ec8db214805127c4f17e7e8e91015e4a1407fc1d0e84df0086a73" +checksum = "97f2743cad51cc86b0dbfe316309eeb87a9d96a3d7f4dd7a99767c4b5f065335" dependencies = [ "futures-channel", "futures-util", @@ -2094,9 +2094,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4278372ecb78ebb522c36a242209a29162f4af0997a41158c8b60450b081baf1" +checksum = "35dc957af59ce98373bcdde0c1698060ca6c2d2e9ae357b459c7158b6df33330" dependencies = [ "anyhow", "async-lock", @@ -2117,9 +2117,9 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2393386c97ce214851a9677568c5a38223ae4eada833617cb16d8464d1128f1b" +checksum = "0dd865d0072764cb937b0110a92b5f53e995f7101cb346beca03d93a2dea79de" dependencies = [ "async-trait", "hyper", @@ -2137,9 +2137,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbea61f2d95b9592491228db0c4d2b1e43ea1154ed9713bb666169cf3919ea7d" +checksum = "fa9e25aec855b2a7d3ed90fded6c41e8c3fb72b63f071e1be3f0004eba19b625" dependencies = [ "anyhow", "beef", @@ -4770,7 +4770,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] From 721949bd0ad27b4a58e32aef1d084ecb1b14da87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:55:54 +0200 Subject: [PATCH 17/25] Bump clap from 4.4.2 to 4.4.3 (#1163) Bumps [clap](https://github.com/clap-rs/clap) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d427381607..2245dd3f47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,9 +715,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.2" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" dependencies = [ "clap_builder", "clap_derive", @@ -4232,7 +4232,7 @@ dependencies = [ name = "subxt-cli" version = "0.31.0" dependencies = [ - "clap 4.4.2", + "clap 4.4.3", "color-eyre", "frame-metadata 16.0.0", "hex", diff --git a/Cargo.toml b/Cargo.toml index 86b39d709b..16a51431dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ assert_matches = "1.5.0" base58 = { version = "0.2.0" } bitvec = { version = "1", default-features = false } blake2 = { version = "0.10.4", default-features = false } -clap = { version = "4.4.2", features = ["derive", "cargo"] } +clap = { version = "4.4.3", features = ["derive", "cargo"] } criterion = "0.4" codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } color-eyre = "0.6.1" From d073f5493b8b95e60c0077e70c86a68cc9e479f6 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 19 Sep 2023 16:34:24 +0200 Subject: [PATCH 18/25] fix double quote import introduced by merge --- codegen/src/api/custom_values.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/codegen/src/api/custom_values.rs b/codegen/src/api/custom_values.rs index 3bbf79dc5c..2a0f297d4b 100644 --- a/codegen/src/api/custom_values.rs +++ b/codegen/src/api/custom_values.rs @@ -9,7 +9,6 @@ use heck::ToSnakeCase as _; use subxt_metadata::{CustomValueMetadata, Metadata}; use proc_macro2::TokenStream as TokenStream2; -use quote::quote; use quote::{quote, ToTokens}; /// Generate the custom values mod, if there are any custom values in the metadata. Else returns None. From 1cdf564dee708848040cb49c3cf577d9f908a896 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Tue, 19 Sep 2023 16:46:41 +0200 Subject: [PATCH 19/25] clippy --- cli/src/commands/compatibility.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/compatibility.rs b/cli/src/commands/compatibility.rs index 99730334e3..614af7f08b 100644 --- a/cli/src/commands/compatibility.rs +++ b/cli/src/commands/compatibility.rs @@ -77,7 +77,7 @@ async fn handle_pallet_metadata( compatibility .pallet_present .entry(hex_hash) - .or_insert_with(Vec::new) + .or_default() .push(node.to_string()); } None => { @@ -110,7 +110,7 @@ async fn handle_full_metadata( compatibility_map .entry(hex_hash) - .or_insert_with(Vec::new) + .or_default() .push(node.to_string()); } From 8879c8f953489414787db517dc6c09519127e2cf Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 20 Sep 2023 09:41:56 +0200 Subject: [PATCH 20/25] put ensure_unique_types on metadata, revert toml changes --- codegen/Cargo.toml | 12 ++++------ codegen/src/api/mod.rs | 47 ++++---------------------------------- codegen/src/api/storage.rs | 1 - codegen/src/error.rs | 2 +- codegen/src/lib.rs | 9 +++++--- metadata/src/lib.rs | 39 +++++++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 56 deletions(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 81ff71dcc6..07bffea866 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -13,24 +13,20 @@ homepage.workspace = true description = "Generate an API for interacting with a substrate node from FRAME metadata" [features] -default = ["fetch_metadata"] -fetch_metadata = ["dep:jsonrpsee", "dep:tokio", "dep:frame-metadata"] +default = ["fetch-metadata"] +fetch-metadata = ["dep:jsonrpsee", "dep:tokio"] web = ["getrandom/js"] [dependencies] codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } -frame-metadata = { workspace = true, optional = true } +frame-metadata = { workspace = true } heck = { workspace = true } proc-macro2 = { workspace = true } 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-native-tls", "http-client"], optional = true } hex = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread"], optional = true } thiserror = { workspace = true } diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index 4769709667..488a2ca48c 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -23,14 +23,14 @@ use crate::{ CratePath, }; -#[cfg(feature = "fetch_metadata")] +#[cfg(feature = "fetch-metadata")] use crate::utils::{fetch_metadata_bytes_blocking, MetadataVersion, Url}; use codec::Decode; use heck::ToSnakeCase as _; use proc_macro2::TokenStream as TokenStream2; use quote::{format_ident, quote}; -use std::{collections::HashMap, fs, io::Read, path, string::ToString}; +use std::{fs, io::Read, path, string::ToString}; use syn::parse_quote; /// Generate the runtime API for interacting with a substrate runtime. @@ -149,7 +149,7 @@ impl GenerateRuntimeApi { /// # Warning /// /// Not recommended to be used in production environments. - #[cfg(feature = "fetch_metadata")] + #[cfg(feature = "fetch-metadata")] pub fn generate_from_url(self, url: Url) -> Result { fn fetch_metadata(url: Url, version: MetadataVersion) -> Result { let bytes = fetch_metadata_bytes_blocking(url, version)?; @@ -229,49 +229,10 @@ impl RuntimeGenerator { /// /// Supported versions: v14 and v15. pub fn new(mut metadata: Metadata) -> Self { - Self::ensure_unique_type_paths(&mut metadata); + metadata.ensure_unique_type_paths(); RuntimeGenerator { metadata } } - /// Ensure that every unique type we'll be generating or referring to also has a - /// unique path, so that types with matching paths don't end up overwriting each other - /// in the codegen. We ignore any types with generics; Subxt actually endeavours to - /// de-duplicate those into single types with a generic. - pub fn ensure_unique_type_paths(metadata: &mut Metadata) { - let mut visited_path_counts = HashMap::, usize>::new(); - for ty in metadata.types_mut().types.iter_mut() { - // Ignore types without a path (ie prelude types). - if ty.ty.path.namespace().is_empty() { - continue; - } - - let has_valid_type_params = ty.ty.type_params.iter().any(|tp| tp.ty.is_some()); - - // Ignore types which have generic params that the type generation will use. - // Ordinarily we'd expect that any two types with identical paths must be parameterized - // in order to share the path. However scale-info doesn't understand all forms of generics - // properly I think (eg generics that have associated types that can differ), and so in - // those cases we need to fix the paths for Subxt to generate correct code. - if has_valid_type_params { - continue; - } - - // Count how many times we've seen the same path already. - let visited_count = visited_path_counts - .entry(ty.ty.path.segments.clone()) - .or_default(); - *visited_count += 1; - - // alter the type so that if it's been seen more than once, we append a number to - // its name to ensure that every unique type has a unique path, too. - if *visited_count > 1 { - if let Some(name) = ty.ty.path.segments.last_mut() { - *name = format!("{name}{visited_count}"); - } - } - } - } - /// Generate the API for interacting with a Substrate runtime. /// /// # Arguments diff --git a/codegen/src/api/storage.rs b/codegen/src/api/storage.rs index 9d8784ec82..988679e7a9 100644 --- a/codegen/src/api/storage.rs +++ b/codegen/src/api/storage.rs @@ -170,7 +170,6 @@ fn primitive_type_alias(type_path: &TypePath) -> TokenStream { quote!(#type_path) } -#[cfg(feature = "fetch_metadata")] #[cfg(test)] mod tests { use crate::RuntimeGenerator; diff --git a/codegen/src/error.rs b/codegen/src/error.rs index 95110ead0c..4e0aa43e9f 100644 --- a/codegen/src/error.rs +++ b/codegen/src/error.rs @@ -87,7 +87,7 @@ pub enum FetchMetadataError { DecodeError(#[from] hex::FromHexError), #[error("Cannot scale encode/decode value: {0}")] CodecError(#[from] codec::Error), - #[cfg(feature = "fetch_metadata")] + #[cfg(feature = "fetch-metadata")] #[error("Request error: {0}")] RequestError(#[from] jsonrpsee::core::Error), #[error("'{0}' not supported, supported URI schemes are http, https, ws or wss.")] diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index f98abfe12e..5576e089a7 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -50,15 +50,18 @@ mod error; mod ir; mod types; -#[cfg(feature = "fetch_metadata")] +#[cfg(feature = "fetch-metadata")] pub mod utils; -#[cfg(all(feature = "web", feature = "fetch_metadata"))] +#[cfg(all(feature = "web", feature = "fetch-metadata"))] compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be used together."); #[cfg(feature = "web")] #[allow(unused_imports)] -pub use getrandom as _; +const _: () = { + pub use getrandom as _; + use frame_metadata as _; +}; pub use self::{ api::{GenerateRuntimeApi, RuntimeGenerator}, diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index a9c656be0a..b0186cab66 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -166,6 +166,45 @@ impl Metadata { &mut HashMap::new(), )) } + + /// Ensure that every unique type we'll be generating or referring to also has a + /// unique path, so that types with matching paths don't end up overwriting each other + /// in the codegen. We ignore any types with generics; Subxt actually endeavours to + /// de-duplicate those into single types with a generic. + pub fn ensure_unique_type_paths(&mut self) { + let mut visited_path_counts = HashMap::, usize>::new(); + for ty in self.types.types.iter_mut() { + // Ignore types without a path (ie prelude types). + if ty.ty.path.namespace().is_empty() { + continue; + } + + let has_valid_type_params = ty.ty.type_params.iter().any(|tp| tp.ty.is_some()); + + // Ignore types which have generic params that the type generation will use. + // Ordinarily we'd expect that any two types with identical paths must be parameterized + // in order to share the path. However scale-info doesn't understand all forms of generics + // properly I think (eg generics that have associated types that can differ), and so in + // those cases we need to fix the paths for Subxt to generate correct code. + if has_valid_type_params { + continue; + } + + // Count how many times we've seen the same path already. + let visited_count = visited_path_counts + .entry(ty.ty.path.segments.clone()) + .or_default(); + *visited_count += 1; + + // alter the type so that if it's been seen more than once, we append a number to + // its name to ensure that every unique type has a unique path, too. + if *visited_count > 1 { + if let Some(name) = ty.ty.path.segments.last_mut() { + *name = format!("{name}{visited_count}"); + } + } + } + } } /// Metadata for a specific pallet. From 05e1d0982209bfdc64115fb0338a498c0afa8359 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 20 Sep 2023 09:42:29 +0200 Subject: [PATCH 21/25] fmt --- codegen/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 5576e089a7..02bc3ebc32 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -59,8 +59,8 @@ compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be #[cfg(feature = "web")] #[allow(unused_imports)] const _: () = { - pub use getrandom as _; use frame_metadata as _; + pub use getrandom as _; }; pub use self::{ From 47bed783cb3686788810d38b6f0eff780994b3d4 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 20 Sep 2023 10:18:42 +0200 Subject: [PATCH 22/25] solve frame_metadata import --- codegen/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 02bc3ebc32..679066ad16 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -58,10 +58,10 @@ compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be #[cfg(feature = "web")] #[allow(unused_imports)] -const _: () = { - use frame_metadata as _; - pub use getrandom as _; -}; +pub use getrandom as _; + +#[allow(unused_imports)] +use frame_metadata as _; pub use self::{ api::{GenerateRuntimeApi, RuntimeGenerator}, From 7f4fab9d07e5ede5c59d08d75ebd683d47a1dd57 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Wed, 20 Sep 2023 10:08:55 +0100 Subject: [PATCH 23/25] tidy fetch-metadata and non_exhaustive on errors --- codegen/Cargo.toml | 6 +++--- codegen/src/api/mod.rs | 7 +++---- codegen/src/error.rs | 3 +++ codegen/src/lib.rs | 3 --- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 07bffea866..997c775a76 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -14,12 +14,12 @@ description = "Generate an API for interacting with a substrate node from FRAME [features] default = ["fetch-metadata"] -fetch-metadata = ["dep:jsonrpsee", "dep:tokio"] +fetch-metadata = ["dep:jsonrpsee", "dep:tokio", "dep:frame-metadata"] web = ["getrandom/js"] [dependencies] codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } -frame-metadata = { workspace = true } +frame-metadata = { workspace = true, optional = true } heck = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } @@ -36,4 +36,4 @@ getrandom = { workspace = true, optional = true } [dev-dependencies] bitvec = { workspace = true } scale-info = { workspace = true, features = ["bit-vec"] } -pretty_assertions = { workspace = true } +pretty_assertions = { workspace = true } \ No newline at end of file diff --git a/codegen/src/api/mod.rs b/codegen/src/api/mod.rs index 488a2ca48c..1d1897e3d2 100644 --- a/codegen/src/api/mod.rs +++ b/codegen/src/api/mod.rs @@ -23,9 +23,6 @@ use crate::{ CratePath, }; -#[cfg(feature = "fetch-metadata")] -use crate::utils::{fetch_metadata_bytes_blocking, MetadataVersion, Url}; - use codec::Decode; use heck::ToSnakeCase as _; use proc_macro2::TokenStream as TokenStream2; @@ -150,7 +147,9 @@ impl GenerateRuntimeApi { /// /// Not recommended to be used in production environments. #[cfg(feature = "fetch-metadata")] - pub fn generate_from_url(self, url: Url) -> Result { + pub fn generate_from_url(self, url: crate::utils::Url) -> Result { + use crate::utils::{fetch_metadata_bytes_blocking, MetadataVersion, Url}; + fn fetch_metadata(url: Url, version: MetadataVersion) -> Result { let bytes = fetch_metadata_bytes_blocking(url, version)?; Ok(Metadata::decode(&mut &bytes[..])?) diff --git a/codegen/src/error.rs b/codegen/src/error.rs index 4e0aa43e9f..60437f5de7 100644 --- a/codegen/src/error.rs +++ b/codegen/src/error.rs @@ -8,6 +8,7 @@ use proc_macro2::{Span, TokenStream as TokenStream2}; /// Error returned when the Codegen cannot generate the runtime API. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum CodegenError { /// The given metadata type could not be found. #[error("Could not find type with ID {0} in the type registry; please raise a support issue.")] @@ -82,6 +83,7 @@ impl CodegenError { /// Error attempting to load metadata. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum FetchMetadataError { #[error("Cannot decode hex value: {0}")] DecodeError(#[from] hex::FromHexError), @@ -98,6 +100,7 @@ pub enum FetchMetadataError { /// Error attempting to do type substitution. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum TypeSubstitutionError { /// Substitute "to" type must be an absolute path. #[error("`substitute_type(with = )` must be a path prefixed with 'crate::' or '::'")] diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 679066ad16..c4b67f543f 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -60,9 +60,6 @@ compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be #[allow(unused_imports)] pub use getrandom as _; -#[allow(unused_imports)] -use frame_metadata as _; - pub use self::{ api::{GenerateRuntimeApi, RuntimeGenerator}, error::{CodegenError, TypeSubstitutionError}, From 16ad86dbb80915560d99e5ca6dd2fb8fc41b21d2 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 20 Sep 2023 12:08:01 +0200 Subject: [PATCH 24/25] remove the getrandom thing --- Cargo.lock | 1 - codegen/Cargo.toml | 3 - codegen/src/lib.rs | 4 - examples/wasm-example/Cargo.lock | 229 ++++++++++++++++++++----------- 4 files changed, 148 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2245dd3f47..bd23900c88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4255,7 +4255,6 @@ version = "0.31.0" dependencies = [ "bitvec", "frame-metadata 16.0.0", - "getrandom 0.2.10", "heck", "hex", "jsonrpsee", diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 997c775a76..a336f7fa7c 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -15,7 +15,6 @@ description = "Generate an API for interacting with a substrate node from FRAME [features] default = ["fetch-metadata"] fetch-metadata = ["dep:jsonrpsee", "dep:tokio", "dep:frame-metadata"] -web = ["getrandom/js"] [dependencies] codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } @@ -30,8 +29,6 @@ jsonrpsee = { workspace = true, features = ["async-client", "client-ws-transport hex = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread"], optional = true } thiserror = { workspace = true } -getrandom = { workspace = true, optional = true } - [dev-dependencies] bitvec = { workspace = true } diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index c4b67f543f..5af5a244b9 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -56,10 +56,6 @@ pub mod utils; #[cfg(all(feature = "web", feature = "fetch-metadata"))] compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be used together."); -#[cfg(feature = "web")] -#[allow(unused_imports)] -pub use getrandom as _; - pub use self::{ api::{GenerateRuntimeApi, RuntimeGenerator}, error::{CodegenError, TypeSubstitutionError}, diff --git a/examples/wasm-example/Cargo.lock b/examples/wasm-example/Cargo.lock index 174decfb19..8a8a3af72d 100644 --- a/examples/wasm-example/Cargo.lock +++ b/examples/wasm-example/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", @@ -859,7 +859,7 @@ dependencies = [ "gloo-render", "gloo-storage", "gloo-timers", - "gloo-utils", + "gloo-utils 0.1.7", "gloo-worker", ] @@ -869,7 +869,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82b7ce3c05debe147233596904981848862b068862e9ec3e34be446077190d3f" dependencies = [ - "gloo-utils", + "gloo-utils 0.1.7", "js-sys", "serde", "wasm-bindgen", @@ -916,7 +916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfd137a4b629e72b8c949ec56c71ea9bd5491cc66358a0a7787e94875feec71" dependencies = [ "gloo-events", - "gloo-utils", + "gloo-utils 0.1.7", "serde", "serde-wasm-bindgen", "serde_urlencoded", @@ -927,14 +927,15 @@ dependencies = [ [[package]] name = "gloo-net" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9902a044653b26b99f7e3693a42f171312d9be8b26b5697bd1e43ad1f8a35e10" +checksum = "3000ef231a67d5bfee6b35f2c0f6f5c8d45b3381ef5bbbea603690ec4e539762" dependencies = [ "futures-channel", "futures-core", "futures-sink", - "gloo-utils", + "gloo-utils 0.1.7", + "http", "js-sys", "pin-project", "serde", @@ -947,14 +948,14 @@ dependencies = [ [[package]] name = "gloo-net" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3000ef231a67d5bfee6b35f2c0f6f5c8d45b3381ef5bbbea603690ec4e539762" +checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" dependencies = [ "futures-channel", "futures-core", "futures-sink", - "gloo-utils", + "gloo-utils 0.2.0", "http", "js-sys", "pin-project", @@ -982,7 +983,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d6ab60bf5dbfd6f0ed1f7843da31b41010515c745735c970e821945ca91e480" dependencies = [ - "gloo-utils", + "gloo-utils 0.1.7", "js-sys", "serde", "serde_json", @@ -1016,6 +1017,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "gloo-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "gloo-worker" version = "0.2.1" @@ -1025,7 +1039,7 @@ dependencies = [ "anymap2", "bincode", "gloo-console", - "gloo-utils", + "gloo-utils 0.1.7", "js-sys", "serde", "wasm-bindgen", @@ -1169,7 +1183,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -1178,10 +1192,11 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ + "futures-util", "http", "hyper", "log", @@ -1189,7 +1204,6 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls", - "webpki-roots", ] [[package]] @@ -1198,6 +1212,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -1306,9 +1330,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.16.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" +checksum = "9ad9b31183a8bcbe843e32ca8554ad2936633548d95a7bb6a8e14c767dea6b05" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -1318,18 +1342,15 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.16.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" +checksum = "97f2743cad51cc86b0dbfe316309eeb87a9d96a3d7f4dd7a99767c4b5f065335" dependencies = [ - "anyhow", "futures-channel", - "futures-timer", "futures-util", - "gloo-net 0.2.6", + "gloo-net 0.4.0", "http", "jsonrpsee-core", - "jsonrpsee-types", "pin-project", "rustls-native-certs", "soketto", @@ -1338,20 +1359,19 @@ dependencies = [ "tokio-rustls", "tokio-util", "tracing", - "webpki-roots", + "url", ] [[package]] name = "jsonrpsee-core" -version = "0.16.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" +checksum = "35dc957af59ce98373bcdde0c1698060ca6c2d2e9ae357b459c7158b6df33330" dependencies = [ "anyhow", "async-lock", "async-trait", "beef", - "futures-channel", "futures-timer", "futures-util", "hyper", @@ -1367,28 +1387,29 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.16.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad" +checksum = "0dd865d0072764cb937b0110a92b5f53e995f7101cb346beca03d93a2dea79de" dependencies = [ "async-trait", "hyper", "hyper-rustls", "jsonrpsee-core", "jsonrpsee-types", - "rustc-hash", "serde", "serde_json", "thiserror", "tokio", + "tower", "tracing", + "url", ] [[package]] name = "jsonrpsee-types" -version = "0.16.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" +checksum = "fa9e25aec855b2a7d3ed90fded6c41e8c3fb72b63f071e1be3f0004eba19b625" dependencies = [ "anyhow", "beef", @@ -1709,9 +1730,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1824,9 +1845,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -1850,9 +1871,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1949,14 +1970,14 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", + "rustls-webpki", "sct", - "webpki", ] [[package]] @@ -1980,6 +2001,16 @@ dependencies = [ "base64 0.21.2", ] +[[package]] +name = "rustls-webpki" +version = "0.101.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2194,9 +2225,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.181" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3e73c93c3240c0bda063c239298e633114c69a888c3e37ca8bb33f343e9890" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -2214,9 +2245,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.181" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be02f6cb0cd3a5ec20bbcfbcbd749f57daddb1a0882dc2e46a6c236c90b977ed" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -2225,9 +2256,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -2416,6 +2447,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "soketto" version = "0.7.1" @@ -2492,13 +2533,13 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" name = "subxt" version = "0.31.0" dependencies = [ + "async-trait", "base58", "blake2", "derivative", "either", "frame-metadata 16.0.0", "futures", - "getrandom", "hex", "impl-serde", "jsonrpsee", @@ -2612,9 +2653,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] @@ -2641,9 +2682,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", @@ -2676,18 +2717,17 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", "pin-project-lite", - "socket2", + "socket2 0.5.4", "tokio-macros", "windows-sys", ] @@ -2705,13 +2745,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ "rustls", "tokio", - "webpki", ] [[package]] @@ -2757,6 +2796,27 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + [[package]] name = "tower-service" version = "0.3.2" @@ -2770,6 +2830,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2809,7 +2870,6 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand", "static_assertions", ] @@ -2831,12 +2891,27 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "universal-hash" version = "0.4.0" @@ -2853,6 +2928,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "version_check" version = "0.9.4" @@ -3009,25 +3095,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] - [[package]] name = "winapi" version = "0.3.9" From 1fbe008d8306fdd0d90919487b1a7b227bbbfdb0 Mon Sep 17 00:00:00 2001 From: Tadeo hepperle Date: Wed, 20 Sep 2023 12:58:12 +0200 Subject: [PATCH 25/25] fix toml autoformatting --- metadata/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml index 5cdeabd106..6e3669278d 100644 --- a/metadata/Cargo.toml +++ b/metadata/Cargo.toml @@ -14,9 +14,7 @@ homepage.workspace = true description = "Command line utilities for checking metadata compatibility between nodes." [dependencies] -codec = { package = "parity-scale-codec", workspace = true, features = [ - "derive", -] } +codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } frame-metadata = { workspace = true } scale-info = { workspace = true } sp-core-hashing = { workspace = true }