Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ resolver = "2"

[workspace.package]
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition = "2024"
version = "0.41.0"
rust-version = "1.81.0"
rust-version = "1.86.0"
license = "Apache-2.0 OR GPL-3.0"
repository = "https://github.com/paritytech/subxt"
documentation = "https://docs.rs/subxt"
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.

use crate::utils::{validate_url_security, FileOrUrl};
use crate::utils::{FileOrUrl, validate_url_security};
use clap::Parser as ClapParser;
use codec::Decode;
use color_eyre::eyre::eyre;
Expand Down
6 changes: 3 additions & 3 deletions cli/src/commands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use frame_metadata::RuntimeMetadataPrefixed;
use std::collections::HashMap;
use std::hash::Hash;

use crate::utils::{validate_url_security, FileOrUrl};
use crate::utils::{FileOrUrl, validate_url_security};
use color_eyre::owo_colors::OwoColorize;

use scale_info::form::PortableForm;
use scale_info::Variant;
use scale_info::form::PortableForm;

use subxt_metadata::{
ConstantMetadata, Metadata, PalletMetadata, RuntimeApiMetadata, StorageEntryMetadata,
Expand Down Expand Up @@ -441,7 +441,7 @@ fn diff<T, C: PartialEq, I: Hash + PartialEq + Eq + Ord>(

#[cfg(test)]
mod test {
use crate::commands::diff::{diff, Diff};
use crate::commands::diff::{Diff, diff};

#[test]
fn test_diff_fn() {
Expand Down
28 changes: 16 additions & 12 deletions cli/src/commands/explore/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::validate_url_security;
use crate::utils::FileOrUrl;
use clap::{command, Parser, Subcommand};
use crate::utils::validate_url_security;
use clap::{Parser, Subcommand, command};
use codec::Decode;
use color_eyre::eyre::eyre;
use color_eyre::owo_colors::OwoColorize;
Expand Down Expand Up @@ -447,18 +447,22 @@ pub mod tests {
run("--url wss://rpc.polkadot.io:443").await.unwrap();

// Errors, because the --allow-insecure is not set:
assert!(run("--url ws://rpc.polkadot.io:443")
.await
.unwrap_err()
.to_string()
.contains("is not secure"));
assert!(
run("--url ws://rpc.polkadot.io:443")
.await
.unwrap_err()
.to_string()
.contains("is not secure")
);

// This checks, that we never prevent (insecure) requests to localhost, even if the `--allow-insecure` flag is not set.
// It errors, because there is no node running locally, which results in the "Request error".
assert!(run("--url ws://localhost")
.await
.unwrap_err()
.to_string()
.contains("Request error"));
assert!(
run("--url ws://localhost")
.await
.unwrap_err()
.to_string()
.contains("Request error")
);
}
}
8 changes: 4 additions & 4 deletions cli/src/commands/explore/pallets/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ use std::str::FromStr;
use subxt::tx;
use subxt::utils::H256;
use subxt::{
config::SubstrateConfig,
metadata::{types::PalletMetadata, Metadata},
OfflineClient,
config::SubstrateConfig,
metadata::{Metadata, types::PalletMetadata},
};

use crate::utils::{
fields_composite_example, fields_description, parse_string_into_scale_value, Indent,
SyntaxHighlight,
Indent, SyntaxHighlight, fields_composite_example, fields_description,
parse_string_into_scale_value,
};

#[derive(Debug, Clone, Args)]
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/explore/pallets/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use clap::Args;
use color_eyre::eyre::eyre;
use indoc::{formatdoc, writedoc};
use scale_typegen_description::type_description;
use subxt::metadata::{types::PalletMetadata, Metadata};
use subxt::metadata::{Metadata, types::PalletMetadata};

use crate::utils::{first_paragraph_of_docs, format_scale_value, Indent, SyntaxHighlight};
use crate::utils::{Indent, SyntaxHighlight, first_paragraph_of_docs, format_scale_value};

#[derive(Debug, Clone, Args)]
pub struct ConstantsSubcommand {
Expand Down
6 changes: 3 additions & 3 deletions cli/src/commands/explore/pallets/events.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use clap::Args;
use color_eyre::eyre::eyre;
use indoc::{formatdoc, writedoc};
use scale_info::{form::PortableForm, Variant};
use subxt::metadata::{types::PalletMetadata, Metadata};
use scale_info::{Variant, form::PortableForm};
use subxt::metadata::{Metadata, types::PalletMetadata};

use crate::utils::{fields_description, first_paragraph_of_docs, Indent};
use crate::utils::{Indent, fields_description, first_paragraph_of_docs};

#[derive(Debug, Clone, Args)]
pub struct EventsSubcommand {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/explore/pallets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use indoc::writedoc;
use subxt::Metadata;
use subxt_metadata::PalletMetadata;

use crate::utils::{first_paragraph_of_docs, FileOrUrl, Indent};
use crate::utils::{FileOrUrl, Indent, first_paragraph_of_docs};

use self::{
calls::CallsSubcommand,
constants::ConstantsSubcommand,
events::{explore_events, EventsSubcommand},
events::{EventsSubcommand, explore_events},
storage::StorageSubcommand,
};

Expand Down
10 changes: 6 additions & 4 deletions cli/src/commands/explore/pallets/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use std::write;
use subxt::{
ext::scale_encode::EncodeAsType,
metadata::{
types::{PalletMetadata, StorageEntryType, StorageMetadata},
Metadata,
types::{PalletMetadata, StorageEntryType, StorageMetadata},
},
};

use crate::utils::{
create_client, first_paragraph_of_docs, parse_string_into_scale_value, type_example, FileOrUrl,
Indent, SyntaxHighlight,
FileOrUrl, Indent, SyntaxHighlight, create_client, first_paragraph_of_docs,
parse_string_into_scale_value, type_example,
};

#[derive(Debug, Clone, Args)]
Expand Down Expand Up @@ -151,7 +151,9 @@ pub async fn explore_storage(

let storage_entry_keys: Vec<Value> = match (trailing_args.is_empty(), key_ty_id) {
(false, None) => {
let warning = format!("Warning: You submitted a key, but no key is needed: \"{trailing_args}\". To access the storage value, please do not provide any key.");
let warning = format!(
"Warning: You submitted a key, but no key is needed: \"{trailing_args}\". To access the storage value, please do not provide any key."
);
writeln!(output, "{}", warning.yellow())?;
return Ok(());
}
Expand Down
11 changes: 7 additions & 4 deletions cli/src/commands/explore/runtime_apis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::{
create_client, fields_composite_example, fields_description, first_paragraph_of_docs,
parse_string_into_scale_value, FileOrUrl, Indent, SyntaxHighlight,
FileOrUrl, Indent, SyntaxHighlight, create_client, fields_composite_example,
fields_description, first_paragraph_of_docs, parse_string_into_scale_value,
};

use color_eyre::{
Expand All @@ -12,8 +12,8 @@ use indoc::{formatdoc, writedoc};
use scale_typegen_description::type_description;
use scale_value::Value;
use subxt::{
ext::{scale_decode::DecodeAsType, scale_encode::EncodeAsType},
Metadata,
ext::{scale_decode::DecodeAsType, scale_encode::EncodeAsType},
};
use subxt_metadata::RuntimeApiMetadata;

Expand Down Expand Up @@ -144,7 +144,10 @@ pub async fn run<'a>(
}

if trailing_args.len() != method.inputs().len() {
bail!("The number of trailing arguments you provided after the `execute` flag does not match the expected number of inputs!\n{}", execute_usage());
bail!(
"The number of trailing arguments you provided after the `execute` flag does not match the expected number of inputs!\n{}",
execute_usage()
);
}

// encode each provided input as bytes of the correct type:
Expand Down
6 changes: 4 additions & 2 deletions cli/src/commands/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.

use crate::utils::{validate_url_security, FileOrUrl};
use crate::utils::{FileOrUrl, validate_url_security};
use clap::Parser as ClapParser;
use codec::{Decode, Encode};
use color_eyre::eyre::{self, bail};
Expand Down Expand Up @@ -62,7 +62,9 @@ pub async fn run(opts: Opts, output: &mut impl Write) -> color_eyre::Result<()>
RuntimeMetadata::V15(md) => md.strip_metadata(keep_pallets_fn, keep_runtime_apis_fn),
RuntimeMetadata::V16(md) => md.strip_metadata(keep_pallets_fn, keep_runtime_apis_fn),
_ => {
bail!("Unsupported metadata version for stripping pallets/runtime APIs: V14, V15 or V16 metadata is expected.")
bail!(
"Unsupported metadata version for stripping pallets/runtime APIs: V14, V15 or V16 metadata is expected."
)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ pub fn validate_url_security(url: Option<&Url>, allow_insecure: bool) -> color_e
match subxt::utils::url_is_secure(url.as_str()) {
Ok(is_secure) => {
if !allow_insecure && !is_secure {
bail!("URL {url} is not secure!\nIf you are really want to use this URL, try using --allow-insecure (-a)");
bail!(
"URL {url} is not secure!\nIf you are really want to use this URL, try using --allow-insecure (-a)"
);
}
}
Err(err) => {
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/api/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::{typegen::ir::type_ir::CompositeIRKind, TypeGenerator};
use scale_typegen::{TypeGenerator, typegen::ir::type_ir::CompositeIRKind};
use subxt_metadata::PalletMetadata;

/// Generate calls from the provided pallet's metadata. Each call returns a `StaticPayload`
Expand Down Expand Up @@ -53,7 +53,7 @@ pub fn generate_calls(
.unzip(),
CompositeIRKind::NoFields => Default::default(),
CompositeIRKind::Unnamed(_) => {
return Err(CodegenError::InvalidCallVariant(call_ty))
return Err(CodegenError::InvalidCallVariant(call_ty));
}
};

Expand Down
2 changes: 1 addition & 1 deletion codegen/src/api/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use heck::ToSnakeCase as _;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::TypeGenerator;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use subxt_metadata::PalletMetadata;

use super::CodegenError;
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/api/custom_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// see LICENSE for license details.

use heck::ToSnakeCase as _;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::TypeGenerator;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use std::collections::HashSet;
use subxt_metadata::{CustomValueMetadata, Metadata};

Expand Down
2 changes: 1 addition & 1 deletion codegen/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use super::CodegenError;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::TypeGenerator;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use subxt_metadata::PalletMetadata;

/// Generate events from the provided pallet metadata.
Expand Down
6 changes: 3 additions & 3 deletions codegen/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ mod pallet_view_functions;
mod runtime_apis;
mod storage;

use scale_typegen::typegen::ir::type_ir::{CompositeFieldIR, CompositeIR, CompositeIRKind};
use scale_typegen::TypeGenerator;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::typegen::ir::type_ir::{CompositeFieldIR, CompositeIR, CompositeIRKind};
use scale_typegen::typegen::type_params::TypeParameters;
use scale_typegen::typegen::type_path::TypePath;
use scale_typegen::TypeGenerator;
use subxt_metadata::Metadata;
use syn::{parse_quote, Ident};
use syn::{Ident, parse_quote};

use crate::error::CodegenError;
use crate::subxt_type_gen_settings;
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/api/pallet_view_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use heck::ToUpperCamelCase as _;
use crate::CodegenError;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::TypeGenerator;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use std::collections::HashSet;
use subxt_metadata::{PalletMetadata, ViewFunctionMetadata};

Expand Down
2 changes: 1 addition & 1 deletion codegen/src/api/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::collections::HashSet;
use heck::ToSnakeCase as _;
use heck::ToUpperCamelCase as _;

use scale_typegen::typegen::ir::ToTokensWithSettings;
use scale_typegen::TypeGenerator;
use scale_typegen::typegen::ir::ToTokensWithSettings;
use subxt_metadata::{Metadata, RuntimeApiMetadata};

use proc_macro2::TokenStream as TokenStream2;
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/api/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use heck::{ToSnakeCase as _, ToUpperCamelCase};
use proc_macro2::{Ident, TokenStream as TokenStream2, TokenStream};
use quote::{format_ident, quote};
use scale_info::TypeDef;
use scale_typegen::{typegen::type_path::TypePath, TypeGenerator};
use scale_typegen::{TypeGenerator, typegen::type_path::TypePath};
use subxt_metadata::{
PalletMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, StorageHasher,
};
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {
use frame_metadata::v15;
use heck::ToUpperCamelCase;
use quote::{format_ident, quote};
use scale_info::{meta_type, MetaType};
use scale_info::{MetaType, meta_type};

use std::borrow::Cow;

Expand Down
Loading
Loading