diff --git a/Cargo.lock b/Cargo.lock index 85bcecf80f..d7fa206e6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4560,7 +4560,6 @@ dependencies = [ "sp-keyring", "sp-runtime", "subxt-metadata", - "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9608f9176f..cf2eda7e78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,7 @@ impl-serde = { version = "0.4.0" } indoc = "2" jsonrpsee = { version = "0.21" } pretty_assertions = "1.4.0" -primitive-types = { version = "0.12.2", default-features = false, features = ["codec", "scale-info", "serde"] } +primitive-types = { version = "0.12.2", default-features = false } proc-macro-error = "1.0.4" proc-macro2 = "1.0.78" quote = "1.0.35" @@ -131,7 +131,8 @@ sp-keyring = "31.0.0" # Subxt workspace crates: subxt = { version = "0.34.0", path = "subxt", default-features = false } subxt-macro = { version = "0.34.0", path = "macro" } -subxt-metadata = { version = "0.34.0", path = "metadata" } +subxt-core = { version = "0.34.0", path = "core", default-features = false } +subxt-metadata = { version = "0.34.0", path = "metadata", default-features = false } subxt-codegen = { version = "0.34.0", path = "codegen" } subxt-signer = { version = "0.34.0", path = "signer" } subxt-lightclient = { version = "0.34.0", path = "lightclient", default-features = false } diff --git a/core/Cargo.toml b/core/Cargo.toml index 98947ffc65..edc0307f29 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -44,9 +44,6 @@ impl-serde = { workspace = true } primitive-types = { workspace = true, default-features = false, features = ["codec", "serde_no_std", "scale-info"] } sp-core-hashing = { workspace = true } -# For parsing urls to disallow insecure schemes -url = { workspace = true } - # Included if the "substrate-compat" feature is enabled. sp-core = { workspace = true, optional = true } sp-runtime = { workspace = true, optional = true } diff --git a/core/src/client/mod.rs b/core/src/client/mod.rs index 919154b836..d768cbbd9d 100644 --- a/core/src/client/mod.rs +++ b/core/src/client/mod.rs @@ -9,14 +9,14 @@ use crate::{config::Config, metadata::Metadata}; #[derive(Derivative)] #[derivative(Debug(bound = ""))] -pub struct MinimalClient { +pub struct ClientBase { pub genesis_hash: C::Hash, pub runtime_version: RuntimeVersion, pub metadata: Metadata, marker: core::marker::PhantomData, } -impl MinimalClient { +impl ClientBase { pub fn metadata(&self) -> Metadata { self.metadata.clone() } diff --git a/core/src/config/extrinsic_params.rs b/core/src/config/extrinsic_params.rs index 79d7837e5b..9e6396d1b1 100644 --- a/core/src/config/extrinsic_params.rs +++ b/core/src/config/extrinsic_params.rs @@ -7,7 +7,7 @@ //! [`crate::config::DefaultExtrinsicParams`] provides a general-purpose //! implementation of this that will work in many cases. -use crate::client::MinimalClient; +use crate::client::ClientBase; use super::Config; use crate::prelude::*; @@ -71,7 +71,7 @@ pub trait ExtrinsicParams: ExtrinsicParamsEncoder + Sized + 'static { /// Construct a new instance of our [`ExtrinsicParams`]. fn new( nonce: u64, - client: &MinimalClient, + client: &ClientBase, other_params: Self::OtherParams, ) -> Result; } diff --git a/core/src/config/signed_extensions.rs b/core/src/config/signed_extensions.rs index 9d05c4cb53..2bf6a1bc51 100644 --- a/core/src/config/signed_extensions.rs +++ b/core/src/config/signed_extensions.rs @@ -9,7 +9,7 @@ use super::extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError}; use super::Config; -use crate::client::MinimalClient; +use crate::client::ClientBase; use crate::prelude::*; use crate::utils::Era; use borrow::ToOwned; @@ -45,7 +45,7 @@ impl ExtrinsicParams for CheckSpecVersion { fn new( _nonce: u64, - client: &MinimalClient, + client: &ClientBase, _other_params: Self::OtherParams, ) -> Result { Ok(CheckSpecVersion(client.runtime_version().spec_version)) @@ -73,7 +73,7 @@ impl ExtrinsicParams for CheckNonce { fn new( nonce: u64, - _client: &MinimalClient, + _client: &ClientBase, _other_params: Self::OtherParams, ) -> Result { Ok(CheckNonce(Compact(nonce))) @@ -101,7 +101,7 @@ impl ExtrinsicParams for CheckTxVersion { fn new( _nonce: u64, - client: &MinimalClient, + client: &ClientBase, _other_params: Self::OtherParams, ) -> Result { Ok(CheckTxVersion(client.runtime_version().transaction_version)) @@ -129,7 +129,7 @@ impl ExtrinsicParams for CheckGenesis { fn new( _nonce: u64, - client: &MinimalClient, + client: &ClientBase, _other_params: Self::OtherParams, ) -> Result { Ok(CheckGenesis(client.genesis_hash())) @@ -195,7 +195,7 @@ impl ExtrinsicParams for CheckMortality { fn new( _nonce: u64, - client: &MinimalClient, + client: &ClientBase, other_params: Self::OtherParams, ) -> Result { Ok(CheckMortality { @@ -286,7 +286,7 @@ impl ExtrinsicParams for ChargeAssetTxPayment { fn new( _nonce: u64, - _client: &MinimalClient, + _client: &ClientBase, other_params: Self::OtherParams, ) -> Result { Ok(ChargeAssetTxPayment { @@ -344,7 +344,7 @@ impl ExtrinsicParams for ChargeTransactionPayment { fn new( _nonce: u64, - _client: &MinimalClient, + _client: &ClientBase, other_params: Self::OtherParams, ) -> Result { Ok(ChargeTransactionPayment { @@ -388,7 +388,7 @@ macro_rules! impl_tuples { fn new( nonce: u64, - client: &MinimalClient, + client: &ClientBase, other_params: Self::OtherParams, ) -> Result { let metadata = client.metadata(); diff --git a/core/src/utils/mod.rs b/core/src/utils/mod.rs index f8e74fafbb..c04aafcdb0 100644 --- a/core/src/utils/mod.rs +++ b/core/src/utils/mod.rs @@ -15,7 +15,6 @@ mod wrapper_opaque; use codec::{Compact, Decode, Encode}; use derivative::Derivative; -use url::Url; pub use account_id::AccountId32; use borrow::ToOwned; @@ -50,22 +49,6 @@ 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)?; - - 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) -} - use crate::prelude::*; /// A version of [`core::marker::PhantomData`] that is also Send and Sync (which is fine diff --git a/testing/no-std-tests/Cargo.lock b/testing/no-std-tests/Cargo.lock index ceff2e1339..9adef2beda 100644 --- a/testing/no-std-tests/Cargo.lock +++ b/testing/no-std-tests/Cargo.lock @@ -222,9 +222,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ - "byteorder", - "rand", - "rustc-hex", "static_assertions", ] @@ -234,15 +231,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - [[package]] name = "frame-metadata" version = "15.1.0" @@ -263,7 +251,6 @@ dependencies = [ "cfg-if", "parity-scale-codec", "scale-info", - "serde", ] [[package]] @@ -282,17 +269,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "hashbrown" version = "0.14.3" @@ -315,16 +291,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "impl-codec" version = "0.6.0" @@ -410,11 +376,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec", - "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", - "serde", ] [[package]] @@ -429,18 +393,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primitive-types" version = "0.12.2" @@ -498,42 +450,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - [[package]] name = "rustc_version" version = "0.4.0" @@ -627,7 +543,6 @@ dependencies = [ "derive_more", "parity-scale-codec", "scale-info-derive", - "serde", ] [[package]] @@ -777,7 +692,6 @@ dependencies = [ "serde_json", "sp-core-hashing", "subxt-metadata", - "url", ] [[package]] @@ -832,21 +746,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "toml_datetime" version = "0.6.3" @@ -904,50 +803,18 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "url" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "winnow" version = "0.5.34" diff --git a/testing/no-std-tests/src/main.rs b/testing/no-std-tests/src/main.rs index 1638514801..2ca5d22f5e 100644 --- a/testing/no-std-tests/src/main.rs +++ b/testing/no-std-tests/src/main.rs @@ -49,6 +49,6 @@ fn subxt_metadata_test() { } fn subxt_core_test() { - let url = "wss://mysite.com"; - assert!(subxt_core::utils::url_is_secure(url).unwrap()); + // let er + // assert!(subxt_core::utils::url_is_secure(url).unwrap()); }