diff --git a/Cargo.lock b/Cargo.lock index b861cd053a..dcc77df9ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4365,6 +4365,7 @@ dependencies = [ "tokio-stream", "tracing", "tracing-subscriber 0.3.18", + "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 81f09465ee..1aab4d59a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,6 +96,7 @@ tracing = "0.1.40" tracing-wasm = "0.2.1" tracing-subscriber = "0.3.18" trybuild = "1.0.86" +url = "2.5.0" wabt = "0.10.0" wasm-bindgen-test = "0.3.24" which = "5.0.0" diff --git a/cli/src/commands/codegen.rs b/cli/src/commands/codegen.rs index 2f1a2abef1..fa9b5d889d 100644 --- a/cli/src/commands/codegen.rs +++ b/cli/src/commands/codegen.rs @@ -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::FileOrUrl; +use crate::utils::{validate_url_security, FileOrUrl}; use clap::Parser as ClapParser; use codec::Decode; use color_eyre::eyre::eyre; @@ -62,6 +62,9 @@ pub struct Opts { /// Defaults to `false` (default substitutions are provided). #[clap(long)] no_default_substitutions: bool, + /// Allow insecure URLs e.g. URLs starting with ws:// or http:// without SSL encryption + #[clap(long, short)] + allow_insecure: bool, } fn derive_for_type_parser(src: &str) -> Result<(String, String), String> { @@ -89,6 +92,8 @@ fn substitute_type_parser(src: &str) -> Result<(String, String), String> { } pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Result<()> { + validate_url_security(opts.file_or_url.url.as_ref(), opts.allow_insecure)?; + let bytes = opts.file_or_url.fetch().await?; codegen( diff --git a/cli/src/commands/compatibility.rs b/cli/src/commands/compatibility.rs index d4264ddd55..890c47dd1f 100644 --- a/cli/src/commands/compatibility.rs +++ b/cli/src/commands/compatibility.rs @@ -11,6 +11,8 @@ use std::collections::HashMap; use subxt_codegen::fetch_metadata::MetadataVersion; use subxt_metadata::Metadata; +use crate::utils::validate_url_security; + /// Verify metadata compatibility between substrate nodes. #[derive(Debug, ClapParser)] pub struct Opts { @@ -36,9 +38,16 @@ pub struct Opts { /// Defaults to latest. #[clap(long = "version", default_value = "latest")] version: MetadataVersion, + /// Allow insecure URLs e.g. URLs starting with ws:// or http:// without SSL encryption + #[clap(long, short)] + allow_insecure: bool, } pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Result<()> { + for url in opts.nodes.iter() { + validate_url_security(Some(url), opts.allow_insecure)?; + } + match opts.pallet { Some(pallet) => { handle_pallet_metadata(opts.nodes.as_slice(), pallet.as_str(), opts.version, output) diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index 50439ebe93..02dd50d1be 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -5,7 +5,7 @@ use frame_metadata::RuntimeMetadataPrefixed; use std::collections::HashMap; use std::hash::Hash; -use crate::utils::FileOrUrl; +use crate::utils::{validate_url_security, FileOrUrl}; use color_eyre::owo_colors::OwoColorize; use scale_info::form::PortableForm; @@ -29,9 +29,15 @@ pub struct Opts { metadata_or_url_1: FileOrUrl, /// metadata file or node URL metadata_or_url_2: FileOrUrl, + /// Allow insecure URLs e.g. URLs starting with ws:// or http:// without SSL encryption + #[clap(long, short)] + allow_insecure: bool, } pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Result<()> { + validate_url_security(opts.metadata_or_url_1.url.as_ref(), opts.allow_insecure)?; + validate_url_security(opts.metadata_or_url_2.url.as_ref(), opts.allow_insecure)?; + let (entry_1_metadata, entry_2_metadata) = get_metadata(&opts).await?; let metadata_diff = MetadataDiff::construct(&entry_1_metadata, &entry_2_metadata); diff --git a/cli/src/commands/explore/mod.rs b/cli/src/commands/explore/mod.rs index 8798dc709e..31fd365ce0 100644 --- a/cli/src/commands/explore/mod.rs +++ b/cli/src/commands/explore/mod.rs @@ -1,4 +1,4 @@ -use crate::utils::{print_first_paragraph_with_indent, FileOrUrl}; +use crate::utils::{print_first_paragraph_with_indent, validate_url_security, FileOrUrl}; use clap::{Parser as ClapParser, Subcommand}; use std::fmt::Write; @@ -71,6 +71,9 @@ pub struct Opts { pallet: Option, #[command(subcommand)] pallet_subcommand: Option, + /// Allow insecure URLs e.g. URLs starting with ws:// or http:// without SSL encryption + #[clap(long, short)] + allow_insecure: bool, } #[derive(Debug, Clone, Subcommand)] @@ -81,6 +84,8 @@ pub enum PalletSubcommand { } pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Result<()> { + validate_url_security(opts.file_or_url.url.as_ref(), opts.allow_insecure)?; + // get the metadata let bytes = opts.file_or_url.fetch().await?; let metadata = Metadata::decode(&mut &bytes[..])?; @@ -160,48 +165,52 @@ fn print_available_pallets(metadata: &Metadata) -> String { #[cfg(test)] pub mod tests { - use super::{run, Opts}; + use super::Opts; - async fn simulate_run(cli_command: &str) -> color_eyre::Result { - let mut args = vec![ - "explore", - "--file=../artifacts/polkadot_metadata_small.scale", - ]; + async fn run(cli_command: &str) -> color_eyre::Result { + let mut args = vec!["explore"]; let mut split: Vec<&str> = cli_command.split(' ').filter(|e| !e.is_empty()).collect(); args.append(&mut split); let opts: Opts = clap::Parser::try_parse_from(args)?; let mut output: Vec = Vec::new(); - run(opts, &mut output) + super::run(opts, &mut output) .await .map(|_| String::from_utf8(output).unwrap()) } + async fn run_against_file(cli_command: &str) -> color_eyre::Result { + run(&format!( + "--file=../artifacts/polkadot_metadata_small.scale {cli_command}" + )) + .await + } + #[tokio::test] async fn test_commands() { // show pallets: - let output = simulate_run("").await; + let output = run_against_file("").await; assert_eq!(output.unwrap(), "Usage:\n subxt explore \n explore a specific pallet\n\nAvailable values are:\n Balances\n Multisig\n ParaInherent\n System\n Timestamp\n"); // if incorrect pallet, error: - let output = simulate_run("abc123").await; + let output = run_against_file("abc123").await; assert!(output.is_err()); // if correct pallet, show options (calls, constants, storage) - let output = simulate_run("Balances").await; + let output = run_against_file("Balances").await; assert_eq!(output.unwrap(), "Usage:\n subxt explore Balances calls\n explore the calls that can be made into this pallet\n subxt explore Balances constants\n explore the constants held in this pallet\n subxt explore Balances storage\n explore the storage values held in this pallet\n"); // check that exploring calls, storage entries and constants is possible: - let output = simulate_run("Balances calls").await; + let output = run_against_file("Balances calls").await; assert!(output.unwrap().starts_with("Usage:\n subxt explore Balances calls \n explore a specific call within this pallet\n\nAvailable 's in the \"Balances\" pallet:\n")); - let output = simulate_run("Balances storage").await; + let output = run_against_file("Balances storage").await; assert!(output.unwrap().starts_with("Usage:\n subxt explore Balances storage \n view details for a specific storage entry\n\nAvailable 's in the \"Balances\" pallet:\n")); - let output = simulate_run("Balances constants").await; + let output = run_against_file("Balances constants").await; assert!(output.unwrap().starts_with("Usage:\n subxt explore Balances constants \n explore a specific call within this pallet\n\nAvailable 's in the \"Balances\" pallet:\n")); // check that invalid subcommands don't work: - let output = simulate_run("Balances abc123").await; + let output = run_against_file("Balances abc123").await; assert!(output.is_err()); // check that we can explore a certain call: - let output = simulate_run("Balances calls transfer_allow_death").await; + let output = run_against_file("Balances calls transfer_allow_death").await; assert!(output.unwrap().starts_with("Usage:\n subxt explore Balances calls transfer_allow_death \n construct the call by providing a valid argument\n\nThe call expect expects a with this shape:\n {\n dest: enum MultiAddress")); // check that unsigned extrinsic can be constructed: - let output = simulate_run( + let output = run_against_file( "Balances calls transfer_allow_death {\"dest\":v\"Raw\"((255,255, 255)),\"value\":0}", ) .await; @@ -210,11 +219,32 @@ pub mod tests { "Encoded call data:\n 0x24040400020cffffff00\n" ); // check that we can explore a certain constant: - let output = simulate_run("Balances constants ExistentialDeposit").await; + let output = run_against_file("Balances constants ExistentialDeposit").await; assert_eq!(output.unwrap(), "Description:\n The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO!\n\nThe constant has the following shape:\n u128\n\nThe value of the constant is:\n 33333333\n"); // check that we can explore a certain storage entry: - let output = simulate_run("System storage Account").await; + let output = run_against_file("System storage Account").await; assert!(output.unwrap().starts_with("Usage:\n subxt explore System storage Account \n\nDescription:\n The full account information for a particular account ID.")); // in the future we could also integrate with substrate-testrunner to spawn up a node and send an actual storage query to it: e.g. `subxt explore System storage Digest` } + + #[tokio::test] + async fn insecure_urls_get_denied() { + // Connection should work fine: + 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")); + + // 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")); + } } diff --git a/cli/src/commands/metadata.rs b/cli/src/commands/metadata.rs index 8bace30f6f..292ca1c7a5 100644 --- a/cli/src/commands/metadata.rs +++ b/cli/src/commands/metadata.rs @@ -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::FileOrUrl; +use crate::utils::{validate_url_security, FileOrUrl}; use clap::Parser as ClapParser; use codec::{Decode, Encode}; use color_eyre::eyre::{self, bail}; @@ -35,9 +35,13 @@ pub struct Opts { /// Write the output of the metadata command to the provided file path. #[clap(long, short, value_parser)] pub output_file: Option, + /// Allow insecure URLs e.g. URLs starting with ws:// or http:// without SSL encryption + #[clap(long, short)] + allow_insecure: bool, } pub async fn run(opts: Opts, output: &mut impl Write) -> color_eyre::Result<()> { + validate_url_security(opts.file_or_url.url.as_ref(), opts.allow_insecure)?; let bytes = opts.file_or_url.fetch().await?; let mut metadata = RuntimeMetadataPrefixed::decode(&mut &bytes[..])?; diff --git a/cli/src/utils.rs b/cli/src/utils.rs index f96d24a7ef..24cf6756a2 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -3,7 +3,7 @@ // see LICENSE for license details. use clap::Args; -use color_eyre::eyre; +use color_eyre::eyre::bail; use std::str::FromStr; use std::{fs, io::Read, path::PathBuf}; @@ -87,7 +87,7 @@ impl FileOrUrl { match (&self.file, &self.url, self.version) { // Can't provide both --file and --url (Some(_), Some(_), _) => { - eyre::bail!("specify one of `--url` or `--file` but not both") + bail!("specify one of `--url` or `--file` but not both") } // Load from --file path (Some(PathOrStdIn::Path(path)), None, None) => { @@ -101,7 +101,7 @@ impl FileOrUrl { match res { Ok(bytes) => Ok(bytes), - Err(err) => eyre::bail!("reading bytes from stdin (`--file -`) failed: {err}"), + Err(err) => bail!("reading bytes from stdin (`--file -`) failed: {err}"), } } // Cannot load the metadata from the file and specify a version to fetch. @@ -110,7 +110,7 @@ impl FileOrUrl { // but that would be involved because we'd need to convert // from each metadata to the latest one and from the // latest one to each metadata version. For now, disable the conversion. - eyre::bail!("`--file` is incompatible with `--version`") + bail!("`--file` is incompatible with `--version`") } // Fetch from --url (None, Some(uri), version) => { @@ -144,6 +144,23 @@ pub fn with_indent(s: String, indent: usize) -> String { .join("\n") } +pub fn validate_url_security(url: Option<&Url>, allow_insecure: bool) -> color_eyre::Result<()> { + let Some(url) = url else { + return Ok(()); + }; + 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)"); + } + } + Err(err) => { + bail!("URL {url} is not valid: {err}") + } + } + Ok(()) +} + #[cfg(test)] mod tests { use crate::utils::{FileOrUrl, PathOrStdIn}; diff --git a/codegen/src/fetch_metadata.rs b/codegen/src/fetch_metadata.rs index c32377c085..c0c2c799ce 100644 --- a/codegen/src/fetch_metadata.rs +++ b/codegen/src/fetch_metadata.rs @@ -15,7 +15,6 @@ use jsonrpsee::{ }; use std::time::Duration; -// Part of the public interface: pub use jsonrpsee::client_transport::ws::Url; /// The metadata version that is fetched from the node. diff --git a/examples/wasm-example/Cargo.lock b/examples/wasm-example/Cargo.lock index 37d4cc7d57..f0fe931b41 100644 --- a/examples/wasm-example/Cargo.lock +++ b/examples/wasm-example/Cargo.lock @@ -19,49 +19,31 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] [[package]] -name = "aes" -version = "0.7.5" +name = "ahash" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", - "cipher", - "cpufeatures", - "opaque-debug", + "once_cell", + "version_check", + "zerocopy", ] [[package]] -name = "aes-gcm" -version = "0.9.2" +name = "allocator-api2" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "anyhow" @@ -96,31 +78,55 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.2", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + [[package]] name = "async-lock" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.2", + "event-listener-strategy", + "pin-project-lite", ] [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] -name = "atomic" -version = "0.5.3" +name = "atomic-take" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" [[package]] name = "autocfg" @@ -289,9 +295,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -313,36 +319,32 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "zeroize", ] [[package]] -name = "chacha20poly1305" -version = "0.9.1" +name = "cipher" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", - "zeroize", + "crypto-common", + "inout", ] [[package]] -name = "cipher" -version = "0.3.0" +name = "concurrent-queue" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ - "generic-array", + "crossbeam-utils", ] [[package]] @@ -430,6 +432,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core", "typenum", ] @@ -443,53 +446,32 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctr" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" -dependencies = [ - "cipher", -] - [[package]] name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" dependencies = [ "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", - "packed_simd_2", "platforms", + "rustc_version", "subtle", "zeroize", ] [[package]] -name = "curve25519-dalek-ng" -version = "4.1.1" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.6.4", - "subtle-ng", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.46", ] [[package]] @@ -537,7 +519,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] @@ -559,7 +541,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] @@ -612,17 +594,27 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + [[package]] name = "ed25519-zebra" -version = "3.1.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", + "curve25519-dalek", + "ed25519", + "hashbrown 0.14.0", "hex", - "rand_core 0.6.4", - "sha2 0.9.9", + "rand_core", + "sha2 0.10.7", "zeroize", ] @@ -644,11 +636,41 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "218a870470cce1469024e9fb66b901aa983929d81304a1cdb299f28118e550d5" +dependencies = [ + "concurrent-queue", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.2", + "pin-project-lite", +] + [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "fixed-hash" @@ -670,9 +692,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -708,9 +730,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -723,9 +745,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -733,15 +755,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -750,32 +772,42 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "futures-core", + "pin-project-lite", +] [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -789,9 +821,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -829,13 +861,12 @@ dependencies = [ ] [[package]] -name = "ghash" -version = "0.4.4" +name = "getrandom_or_panic" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" dependencies = [ - "opaque-debug", - "polyval", + "rand_core", ] [[package]] @@ -1071,9 +1102,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] [[package]] name = "hashbrown" @@ -1081,6 +1109,8 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ + "ahash", + "allocator-api2", "serde", ] @@ -1214,9 +1244,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1286,6 +1316,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -1298,17 +1337,11 @@ dependencies = [ "web-sys", ] -[[package]] -name = "intx" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f38a50a899dc47a6d0ed5508e7f601a2e34c3a85303514b5d137f3c10a0c75" - [[package]] name = "itertools" -version = "0.10.5" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" dependencies = [ "either", ] @@ -1321,9 +1354,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -1369,7 +1402,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35dc957af59ce98373bcdde0c1698060ca6c2d2e9ae357b459c7158b6df33330" dependencies = [ "anyhow", - "async-lock", + "async-lock 2.7.0", "async-trait", "beef", "futures-timer", @@ -1430,21 +1463,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - -[[package]] -name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsecp256k1" @@ -1502,9 +1529,12 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" -version = "0.10.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" +dependencies = [ + "hashbrown 0.14.0", +] [[package]] name = "memchr" @@ -1520,7 +1550,7 @@ checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ "byteorder", "keccak", - "rand_core 0.6.4", + "rand_core", "zeroize", ] @@ -1541,9 +1571,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", @@ -1651,16 +1681,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm 0.1.4", -] - [[package]] name = "parity-scale-codec" version = "3.6.4" @@ -1704,28 +1724,28 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] @@ -1759,22 +1779,10 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "poly1305" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" -dependencies = [ - "cpufeatures", - "opaque-debug", - "universal-hash", -] - -[[package]] -name = "polyval" -version = "0.5.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ - "cfg-if", "cpufeatures", "opaque-debug", "universal-hash", @@ -1798,9 +1806,9 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -1845,9 +1853,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] @@ -1871,9 +1879,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1892,7 +1900,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1902,15 +1910,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - [[package]] name = "rand_core" version = "0.6.4" @@ -2019,12 +2021,12 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ruzstd" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3ffab8f9715a0d455df4bbb9d21e91135aab3cd3ca187af0cd0c3c3f868fdc" +checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d" dependencies = [ "byteorder", - "thiserror-core", + "derive_more", "twox-hash", ] @@ -2047,9 +2049,9 @@ dependencies = [ [[package]] name = "scale-decode" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7789f5728e4e954aaa20cadcc370b99096fb8645fca3c9333ace44bb18f30095" +checksum = "7caaf753f8ed1ab4752c6afb20174f03598c664724e0e32628e161c21000ff76" dependencies = [ "derive_more", "parity-scale-codec", @@ -2062,9 +2064,9 @@ dependencies = [ [[package]] name = "scale-decode-derive" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27873eb6005868f8cc72dcfe109fae664cf51223d35387bc2f28be4c28d94c47" +checksum = "d3475108a1b62c7efd1b5c65974f30109a598b2f45f23c9ae030acb9686966db" dependencies = [ "darling 0.14.4", "proc-macro-crate", @@ -2103,9 +2105,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -2117,9 +2119,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2129,9 +2131,9 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6538d1cc1af9c0baf401c57da8a6d4730ef582db0d330d2efa56ec946b5b0283" +checksum = "58223c7691bf0bd46b43c9aea6f0472d1067f378d574180232358d7c6e0a8089" dependencies = [ "base58", "blake2", @@ -2158,17 +2160,20 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.10.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "844b7645371e6ecdf61ff246ba1958c29e802881a749ae3fb1993675d210d28d" +checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" dependencies = [ + "aead", "arrayref", "arrayvec 0.7.4", - "curve25519-dalek-ng", + "curve25519-dalek", + "getrandom_or_panic", "merlin", - "rand_core 0.6.4", - "sha2 0.9.9", - "subtle-ng", + "rand_core", + "serde_bytes", + "sha2 0.10.7", + "subtle", "zeroize", ] @@ -2225,9 +2230,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" dependencies = [ "serde_derive", ] @@ -2243,22 +2248,31 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "serde_bytes" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257" dependencies = [ "itoa", "ryu", @@ -2324,11 +2338,17 @@ dependencies = [ "keccak", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" + [[package]] name = "siphasher" -version = "0.3.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" [[package]] name = "slab" @@ -2347,29 +2367,31 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "smoldot" -version = "0.8.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cce5e2881b30bad7ef89f383a816ad0b22c45915911f28499026de4a76d20ee" +checksum = "eca99148e026936bbc444c3708748207033968e4ef1c33bfc885660ae4d44d21" dependencies = [ "arrayvec 0.7.4", - "async-lock", - "atomic", + "async-lock 3.2.0", + "atomic-take", "base64 0.21.2", "bip39", "blake2-rfc", "bs58", + "chacha20", "crossbeam-queue", "derive_more", "ed25519-zebra", "either", - "event-listener", + "event-listener 3.1.0", "fnv", - "futures-channel", + "futures-lite", "futures-util", "hashbrown 0.14.0", "hex", "hmac 0.12.1", "itertools", + "libm", "libsecp256k1", "merlin", "no-std-net", @@ -2378,6 +2400,8 @@ dependencies = [ "num-rational", "num-traits", "pbkdf2", + "pin-project", + "poly1305", "rand", "rand_chacha", "ruzstd", @@ -2385,56 +2409,49 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.7", + "sha3", "siphasher", "slab", "smallvec", - "snow", - "tiny-keccak", + "soketto", "twox-hash", "wasmi", + "x25519-dalek", + "zeroize", ] [[package]] name = "smoldot-light" -version = "0.6.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2f7b4687b83ff244ef6137735ed5716ad37dcdf3ee16c4eb1a32fb9808fa47" +checksum = "0e6f1898682b618b81570047b9d870b3faaff6ae1891b468eddd94d7f903c2fe" dependencies = [ - "async-lock", + "async-channel", + "async-lock 3.2.0", + "base64 0.21.2", "blake2-rfc", "derive_more", "either", - "event-listener", + "event-listener 3.1.0", "fnv", "futures-channel", + "futures-lite", "futures-util", "hashbrown 0.14.0", "hex", "itertools", "log", "lru", + "no-std-net", + "pin-project", "rand", + "rand_chacha", "serde", "serde_json", "siphasher", "slab", "smoldot", -] - -[[package]] -name = "snow" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" -dependencies = [ - "aes-gcm", - "blake2", - "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", - "rand_core 0.6.4", - "rustc_version", - "sha2 0.10.7", - "subtle", + "zeroize", ] [[package]] @@ -2449,9 +2466,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys", @@ -2474,25 +2491,18 @@ dependencies = [ [[package]] name = "sp-core-hashing" -version = "9.0.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee599a8399448e65197f9a6cee338ad192e9023e35e31f22382964c3c174c68" +checksum = "cb8524f01591ee58b46cd83c9dbc0fcffd2fd730dabec4f59326cd58a00f17e2" dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", "sha2 0.10.7", "sha3", - "sp-std", "twox-hash", ] -[[package]] -name = "sp-std" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53458e3c57df53698b3401ec0934bea8e8cfce034816873c0b0abbd83d7bac0d" - [[package]] name = "spin" version = "0.5.2" @@ -2523,12 +2533,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "subtle-ng" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" - [[package]] name = "subxt" version = "0.33.0" @@ -2540,6 +2544,7 @@ dependencies = [ "either", "frame-metadata 16.0.0", "futures", + "getrandom", "hex", "impl-serde", "jsonrpsee", @@ -2558,6 +2563,7 @@ dependencies = [ "subxt-metadata", "thiserror", "tracing", + "url", ] [[package]] @@ -2565,6 +2571,7 @@ name = "subxt-codegen" version = "0.33.0" dependencies = [ "frame-metadata 16.0.0", + "getrandom", "heck", "hex", "jsonrpsee", @@ -2573,7 +2580,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata", - "syn 2.0.28", + "syn 2.0.46", "thiserror", "tokio", ] @@ -2588,6 +2595,7 @@ dependencies = [ "getrandom", "instant", "js-sys", + "pin-project", "send_wrapper 0.6.0", "serde", "serde_json", @@ -2607,9 +2615,10 @@ name = "subxt-macro" version = "0.33.0" dependencies = [ "darling 0.20.3", + "parity-scale-codec", "proc-macro-error", "subxt-codegen", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] @@ -2636,9 +2645,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -2653,51 +2662,22 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] -[[package]] -name = "thiserror-core" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497" -dependencies = [ - "thiserror-core-impl", -] - -[[package]] -name = "thiserror-core-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", + "syn 2.0.46", ] [[package]] @@ -2717,9 +2697,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -2727,20 +2707,20 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "windows-sys", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] @@ -2825,11 +2805,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -2838,20 +2817,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -2914,11 +2893,11 @@ dependencies = [ [[package]] name = "universal-hash" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] @@ -2930,9 +2909,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -2962,9 +2941,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2972,24 +2951,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if", "js-sys", @@ -2999,9 +2978,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3009,22 +2988,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasm-example" @@ -3046,11 +3025,10 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.30.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51fb5c61993e71158abf5bb863df2674ca3ec39ed6471c64f07aeaf751d67b4" +checksum = "acfc1e384a36ca532d070a315925887247f3c7e23567e23e0ac9b1c5d6b8bf76" dependencies = [ - "intx", "smallvec", "spin 0.9.8", "wasmi_arena", @@ -3066,12 +3044,12 @@ checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" [[package]] name = "wasmi_core" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" +checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" dependencies = [ "downcast-rs", - "libm 0.2.7", + "libm", "num-traits", "paste", ] @@ -3087,9 +3065,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -3201,6 +3179,18 @@ dependencies = [ "tap", ] +[[package]] +name = "x25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" +dependencies = [ + "curve25519-dalek", + "rand_core", + "serde", + "zeroize", +] + [[package]] name = "yap" version = "0.11.0" @@ -3276,6 +3266,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.46", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -3293,5 +3303,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.46", ] diff --git a/examples/wasm-example/src/services.rs b/examples/wasm-example/src/services.rs index a6cd9b2c6d..5b8df203ef 100644 --- a/examples/wasm-example/src/services.rs +++ b/examples/wasm-example/src/services.rs @@ -1,5 +1,4 @@ use anyhow::anyhow; -use futures::StreamExt; use js_sys::Promise; use serde::{Deserialize, Serialize}; use serde_json::json; diff --git a/macro/src/lib.rs b/macro/src/lib.rs index 660d28f63a..3778d89a5f 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -32,7 +32,7 @@ struct RuntimeMetadataArgs { #[darling(default)] runtime_metadata_path: Option, #[darling(default)] - runtime_metadata_url: Option, + runtime_metadata_insecure_url: Option, #[darling(default)] derive_for_all_types: Option>, #[darling(default)] @@ -146,11 +146,14 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream { // Do we want to fetch unstable metadata? This only works if fetching from a URL. let unstable_metadata = args.unstable_metadata.is_present(); - match (args.runtime_metadata_path, args.runtime_metadata_url) { + match ( + args.runtime_metadata_path, + args.runtime_metadata_insecure_url, + ) { (Some(rest_of_path), None) => { if unstable_metadata { abort_call_site!( - "The 'unstable_metadata' attribute requires `runtime_metadata_url`" + "The 'unstable_metadata' attribute requires `runtime_metadata_insecure_url`" ) } @@ -185,12 +188,12 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream { } (None, None) => { abort_call_site!( - "One of 'runtime_metadata_path' or 'runtime_metadata_url' must be provided" + "One of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' must be provided" ) } (Some(_), Some(_)) => { abort_call_site!( - "Only one of 'runtime_metadata_path' or 'runtime_metadata_url' can be provided" + "Only one of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' can be provided" ) } } diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index cc8ff5820c..2fa41ad159 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -94,6 +94,9 @@ subxt-lightclient = { workspace = true, optional = true, default-features = fals # Light client support: tokio-stream = { workspace = true, optional = true } +# For parsing urls to disallow insecure schemes +url = { workspace = true } + # Included if "web" feature is enabled, to enable its js feature. getrandom = { workspace = true, optional = true } diff --git a/subxt/src/backend/rpc/rpc_client.rs b/subxt/src/backend/rpc/rpc_client.rs index 4302b9867e..8efedb0291 100644 --- a/subxt/src/backend/rpc/rpc_client.rs +++ b/subxt/src/backend/rpc/rpc_client.rs @@ -20,7 +20,18 @@ pub struct RpcClient { impl RpcClient { #[cfg(feature = "jsonrpsee")] /// Create a default RPC client pointed at some URL, currently based on [`jsonrpsee`]. + /// + /// Errors if an insecure URL is provided. In this case, use [`RpcClient::from_insecure_url`] instead. pub async fn from_url>(url: U) -> Result { + crate::utils::validate_url_is_secure(url.as_ref())?; + RpcClient::from_insecure_url(url).await + } + + #[cfg(feature = "jsonrpsee")] + /// Create a default RPC client pointed at some URL, currently based on [`jsonrpsee`]. + /// + /// Allows insecure URLs without SSL encryption, e.g. (http:// and ws:// URLs). + pub async fn from_insecure_url>(url: U) -> Result { let client = jsonrpsee_helpers::client(url.as_ref()) .await .map_err(|e| crate::error::RpcError::ClientError(Box::new(e)))?; diff --git a/subxt/src/client/light_client/builder.rs b/subxt/src/client/light_client/builder.rs index 3032a86b3e..cc576a2d96 100644 --- a/subxt/src/client/light_client/builder.rs +++ b/subxt/src/client/light_client/builder.rs @@ -5,6 +5,8 @@ use super::{rpc::LightClientRpc, LightClient, LightClientError}; use crate::backend::rpc::RpcClient; use crate::client::RawLightClient; +use crate::error::RpcError; +use crate::utils::validate_url_is_secure; use crate::{config::Config, error::Error, OnlineClient}; use std::num::NonZeroU32; use subxt_lightclient::{smoldot, AddedChain}; @@ -101,8 +103,19 @@ impl LightClientBuilder { /// https://docs.rs/wasm-bindgen-futures/latest/wasm_bindgen_futures/fn.future_to_promise.html. #[cfg(feature = "jsonrpsee")] pub async fn build_from_url>(self, url: Url) -> Result, Error> { - let chain_spec = fetch_url(url.as_ref()).await?; + validate_url_is_secure(url.as_ref())?; + self.build_from_insecure_url(url).await + } + /// Build the light client with specified URL to connect to. Allows insecure URLs (no SSL, ws:// or http://). + /// + /// For secure connections only, please use [`crate::LightClientBuilder::build_from_url`]. + #[cfg(feature = "jsonrpsee")] + pub async fn build_from_insecure_url>( + self, + url: Url, + ) -> Result, Error> { + let chain_spec = fetch_url(url.as_ref()).await?; self.build_client(chain_spec).await } @@ -235,7 +248,6 @@ async fn build_client_from_rpc( #[cfg(feature = "jsonrpsee")] async fn fetch_url(url: impl AsRef) -> Result { use jsonrpsee::core::client::ClientT; - let client = jsonrpsee_helpers::client(url.as_ref()).await?; client diff --git a/subxt/src/client/online_client.rs b/subxt/src/client/online_client.rs index cb45e56796..1382e4f086 100644 --- a/subxt/src/client/online_client.rs +++ b/subxt/src/client/online_client.rs @@ -66,7 +66,15 @@ impl OnlineClient { /// Construct a new [`OnlineClient`], providing a URL to connect to. pub async fn from_url(url: impl AsRef) -> Result, Error> { - let client = RpcClient::from_url(url).await?; + crate::utils::validate_url_is_secure(url.as_ref())?; + OnlineClient::from_insecure_url(url).await + } + + /// Construct a new [`OnlineClient`], providing a URL to connect to. + /// + /// Allows insecure URLs without SSL encryption, e.g. (http:// and ws:// URLs). + pub async fn from_insecure_url(url: impl AsRef) -> Result, Error> { + let client = RpcClient::from_insecure_url(url).await?; let backend = LegacyBackend::new(client); OnlineClient::from_backend(Arc::new(backend)).await } diff --git a/subxt/src/error/mod.rs b/subxt/src/error/mod.rs index a3666b1b68..02a2d5055d 100644 --- a/subxt/src/error/mod.rs +++ b/subxt/src/error/mod.rs @@ -115,6 +115,9 @@ pub enum RpcError { /// The RPC subscription dropped. #[error("RPC error: subscription dropped.")] SubscriptionDropped, + /// The requested URL is insecure. + #[error("RPC error: insecure URL: {0}")] + InsecureUrl(String), } impl RpcError { diff --git a/subxt/src/lib.rs b/subxt/src/lib.rs index 939400c5e7..16c23d6a8f 100644 --- a/subxt/src/lib.rs +++ b/subxt/src/lib.rs @@ -220,7 +220,7 @@ pub mod ext { /// mod polkadot {} /// ``` /// -/// ## `runtime_metadata_url = "..."` +/// ## `runtime_metadata_insecure_url = "..."` /// /// This attribute can be used instead of `runtime_metadata_path` and will tell the macro to download metadata from a node running /// at the provided URL, rather than a node running locally. This can be useful in CI, but is **not recommended** in production code, @@ -228,7 +228,7 @@ pub mod ext { /// /// ```rust,ignore /// #[subxt::subxt( -/// runtime_metadata_url = "wss://rpc.polkadot.io:443" +/// runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443" /// )] /// mod polkadot {} /// ``` @@ -281,14 +281,14 @@ pub mod ext { /// /// ## `unstable_metadata` /// -/// This attribute works only in combination with `runtime_metadata_url`. By default, the macro will fetch the latest stable +/// This attribute works only in combination with `runtime_metadata_insecure_url`. By default, the macro will fetch the latest stable /// version of the metadata from the target node. This attribute makes the codegen attempt to fetch the unstable version of /// the metadata first. This is **not recommended** in production code, since the unstable metadata a node is providing is likely /// to be incompatible with Subxt. /// /// ```rust,ignore /// #[subxt::subxt( -/// runtime_metadata_url = "wss://rpc.polkadot.io:443", +/// runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443", /// unstable_metadata /// )] /// mod polkadot {} diff --git a/subxt/src/utils/mod.rs b/subxt/src/utils/mod.rs index 7de0bf0367..dc9320a303 100644 --- a/subxt/src/utils/mod.rs +++ b/subxt/src/utils/mod.rs @@ -13,8 +13,11 @@ mod static_type; mod unchecked_extrinsic; mod wrapper_opaque; +use crate::error::RpcError; +use crate::Error; use codec::{Compact, Decode, Encode}; use derivative::Derivative; +use url::Url; pub use account_id::AccountId32; pub use era::Era; @@ -47,6 +50,31 @@ pub(crate) fn strip_compact_prefix(bytes: &[u8]) -> Result<(u64, &[u8]), codec:: Ok((val.0, *cursor)) } +/// A URL is considered secure if it uses a secure scheme ("https" or "wss") or is referring to localhost. +/// +/// Returns an error if the the string could not be parsed into a URL. +pub fn url_is_secure(url: &str) -> Result { + let url = Url::parse(url).map_err(|e| Error::Rpc(RpcError::ClientError(Box::new(e))))?; + + let secure_scheme = url.scheme() == "https" || url.scheme() == "wss"; + let is_localhost = url.host().is_some_and(|e| match e { + url::Host::Domain(e) => e == "localhost", + url::Host::Ipv4(e) => e.is_loopback(), + url::Host::Ipv6(e) => e.is_loopback(), + }); + + Ok(secure_scheme || is_localhost) +} + +/// Validates, that the given Url is secure ("https" or "wss" scheme) or is referring to localhost. +pub fn validate_url_is_secure(url: &str) -> Result<(), Error> { + if !url_is_secure(url)? { + Err(Error::Rpc(crate::error::RpcError::InsecureUrl(url.into()))) + } else { + Ok(()) + } +} + /// A version of [`std::marker::PhantomData`] that is also Send and Sync (which is fine /// because regardless of the generic param, it is always possible to Send + Sync this /// 0 size type). diff --git a/testing/ui-tests/src/incorrect/need_url_or_path.stderr b/testing/ui-tests/src/incorrect/need_url_or_path.stderr index afdcbcf213..366544dfb4 100644 --- a/testing/ui-tests/src/incorrect/need_url_or_path.stderr +++ b/testing/ui-tests/src/incorrect/need_url_or_path.stderr @@ -1,4 +1,4 @@ -error: One of 'runtime_metadata_path' or 'runtime_metadata_url' must be provided +error: One of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' must be provided --> src/incorrect/need_url_or_path.rs:1:1 | 1 | #[subxt::subxt()] diff --git a/testing/ui-tests/src/incorrect/url_and_path_provided.rs b/testing/ui-tests/src/incorrect/url_and_path_provided.rs index 90cc5cca57..a088841d69 100644 --- a/testing/ui-tests/src/incorrect/url_and_path_provided.rs +++ b/testing/ui-tests/src/incorrect/url_and_path_provided.rs @@ -1,6 +1,6 @@ #[subxt::subxt( runtime_metadata_path = "../../../../artifacts/polkadot_metadata_tiny.scale", - runtime_metadata_url = "wss://rpc.polkadot.io:443" + runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443" )] pub mod node_runtime {} diff --git a/testing/ui-tests/src/incorrect/url_and_path_provided.stderr b/testing/ui-tests/src/incorrect/url_and_path_provided.stderr index 2c9d48feb8..afbeadb42b 100644 --- a/testing/ui-tests/src/incorrect/url_and_path_provided.stderr +++ b/testing/ui-tests/src/incorrect/url_and_path_provided.stderr @@ -1,9 +1,9 @@ -error: Only one of 'runtime_metadata_path' or 'runtime_metadata_url' can be provided +error: Only one of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' can be provided --> src/incorrect/url_and_path_provided.rs:1:1 | 1 | / #[subxt::subxt( 2 | | runtime_metadata_path = "../../../../artifacts/polkadot_metadata_tiny.scale", -3 | | runtime_metadata_url = "wss://rpc.polkadot.io:443" +3 | | runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443" 4 | | )] | |__^ |