deps: use polkadot-sdk umbrella crate (#1786)

* deps: unify usage of polkadot-sdk crates

* cargo fmt

* fix macro crate

* make tests compile

* fix more nits

* fix doc tests

* fix more nits

* more nits

* core: remove polkadot-sdk/std

* cargo fmt

* remove polkadot-sdk/std by default

* Update metadata/Cargo.toml

* remove more std

* Update Cargo.toml
This commit is contained in:
Niklas Adolfsson
2024-10-11 14:19:11 +02:00
committed by GitHub
parent 5bf1756394
commit 0e86993cd7
31 changed files with 6131 additions and 662 deletions
Generated
+5653 -182
View File
File diff suppressed because it is too large Load Diff
+1 -9
View File
@@ -117,8 +117,6 @@ which = "6.0.3"
strip-ansi-escapes = "0.2.0"
proptest = "1.5.0"
hex-literal = "0.4.1"
sc-executor = "0.40.1"
sc-executor-common = "0.35.0"
# Light client support:
smoldot = { version = "0.18.0", default-features = false }
@@ -139,13 +137,7 @@ instant = { version = "0.1.13", default-features = false }
tokio-util = "0.7.12"
# Substrate crates:
sp-core = { version = "34.0.0", default-features = false }
sp-crypto-hashing = { version = "0.1.0", default-features = false }
sp-runtime = "39.0.1"
sp-keyring = "39.0.0"
sp-maybe-compressed-blob = "11.0.0"
sp-state-machine = "0.43.0"
sp-io = "38.0.0"
polkadot-sdk = { version = "0.7", default-features = false }
# Subxt workspace crates:
subxt = { version = "0.37.0", path = "subxt", default-features = false }
+3 -9
View File
@@ -32,7 +32,7 @@ std = [
"impl-serde/std",
"primitive-types/std",
]
substrate-compat = ["sp-core", "sp-runtime"]
substrate-compat = ["polkadot-sdk/sp-core", "polkadot-sdk/sp-runtime", "polkadot-sdk/std"]
[dependencies]
codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] }
@@ -50,7 +50,6 @@ serde = { workspace = true, default-features = false, features = ["derive"] }
serde_json = { workspace = true, default-features = false, features = ["raw_value", "alloc"] }
hashbrown = { workspace = true }
# For ss58 encoding AccountId32 to serialize them properly:
base58 = { workspace = true }
blake2 = { workspace = true }
@@ -58,11 +57,9 @@ blake2 = { workspace = true }
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true, default-features = false }
primitive-types = { workspace = true, default-features = false, features = ["codec", "serde_no_std", "scale-info"] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] }
# Included if the "substrate-compat" feature is enabled.
sp-core = { workspace = true, optional = true }
sp-runtime = { workspace = true, optional = true }
tracing = { workspace = true, default-features = false }
# AccountId20
@@ -74,12 +71,9 @@ bitvec = { workspace = true }
codec = { workspace = true, features = ["derive", "bit-vec"] }
subxt-macro = { workspace = true }
subxt-signer = { workspace = true, features = ["sr25519", "subxt"] }
sp-core = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing", "sp-core", "sp-keyring"] }
hex = { workspace = true }
[package.metadata.docs.rs]
defalt-features = true
rustdoc-args = ["--cfg", "docsrs"]
+1
View File
@@ -132,6 +132,7 @@ cfg_substrate_compat! {
/// implement subxt's Hasher and Header traits for some substrate structs
mod substrate_impls {
use super::*;
use polkadot_sdk::sp_runtime;
impl<T: sp_runtime::traits::Header> Header for T
where
+1
View File
@@ -8,6 +8,7 @@ use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, Hashe
use alloc::format;
use alloc::vec::Vec;
use codec::{Decode, Encode};
use polkadot_sdk::sp_crypto_hashing;
use serde::{Deserialize, Serialize};
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
+2 -2
View File
@@ -52,7 +52,7 @@ pub mod ext {
pub use scale_value;
cfg_substrate_compat! {
pub use sp_runtime;
pub use sp_core;
pub use polkadot_sdk::sp_runtime;
pub use polkadot_sdk::sp_core;
}
}
+1
View File
@@ -11,6 +11,7 @@ use crate::error::{Error, MetadataError};
use crate::metadata::Metadata;
use alloc::borrow::ToOwned;
use alloc::vec::Vec;
use polkadot_sdk::sp_crypto_hashing;
use subxt_metadata::{PalletMetadata, StorageEntryMetadata, StorageHasher};
/// Return the root of a given [`Address`]: hash the pallet name and entry name
+1 -1
View File
@@ -65,8 +65,8 @@ use alloc::borrow::{Cow, ToOwned};
use alloc::vec::Vec;
use codec::{Compact, Encode};
use payload::Payload;
use polkadot_sdk::sp_crypto_hashing::blake2_256;
use signer::Signer as SignerT;
use sp_crypto_hashing::blake2_256;
// Expose these here since we expect them in some calls below.
pub use crate::client::{ClientState, RuntimeVersion};
+2 -2
View File
@@ -35,8 +35,8 @@ cfg_substrate_compat! {
mod pair_signer {
use super::Signer;
use crate::Config;
use sp_core::Pair as PairT;
use sp_runtime::{
use polkadot_sdk::sp_core::Pair as PairT;
use polkadot_sdk::sp_runtime::{
traits::{IdentifyAccount, Verify},
AccountId32 as SpAccountId32, MultiSignature as SpMultiSignature,
};
+3 -2
View File
@@ -175,6 +175,7 @@ impl core::str::FromStr for AccountId32 {
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::*;
use polkadot_sdk::{sp_core, sp_runtime};
impl From<sp_runtime::AccountId32> for AccountId32 {
fn from(value: sp_runtime::AccountId32) -> Self {
@@ -199,8 +200,8 @@ mod substrate_impls {
mod test {
use super::*;
use sp_core::crypto::Ss58Codec;
use sp_keyring::AccountKeyring;
use polkadot_sdk::sp_core::{self, crypto::Ss58Codec};
use polkadot_sdk::sp_keyring::AccountKeyring;
#[test]
fn ss58_is_compatible_with_substrate_impl() {
+1
View File
@@ -48,6 +48,7 @@ impl<AccountId, AccountIndex> From<AccountId> for MultiAddress<AccountId, Accoun
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::{super::AccountId32, *};
use polkadot_sdk::sp_runtime;
impl<N> From<sp_runtime::AccountId32> for MultiAddress<AccountId32, N> {
fn from(value: sp_runtime::AccountId32) -> Self {
+1
View File
@@ -24,6 +24,7 @@ pub enum MultiSignature {
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::*;
use polkadot_sdk::{sp_core, sp_runtime};
impl From<sp_runtime::MultiSignature> for MultiSignature {
fn from(value: sp_runtime::MultiSignature) -> Self {
+2 -6
View File
@@ -15,7 +15,7 @@ description = "Generate types and helpers for interacting with Substrate runtime
[features]
web = ["subxt-codegen/web"]
runtime-path = ["sp-io", "sc-executor-common", "sp-state-machine", "sp-maybe-compressed-blob", "sc-executor"]
runtime-path = ["polkadot-sdk"]
[lib]
proc-macro = true
@@ -28,11 +28,7 @@ syn = { workspace = true }
quote = { workspace = true }
subxt-codegen = { workspace = true, features = ["fetch-metadata"] }
scale-typegen = { workspace = true }
sc-executor = { workspace = true, optional = true }
sp-maybe-compressed-blob = { workspace = true, optional = true }
sp-state-machine = { workspace = true, optional = true }
sp-io = { workspace = true, optional = true }
sc-executor-common = { workspace = true, optional = true }
polkadot-sdk = { workspace = true, optional = true, features = ["sp-io", "sc-executor-common", "sp-state-machine", "sp-maybe-compressed-blob", "sc-executor"] }
[lints]
workspace = true
+7 -3
View File
@@ -5,9 +5,13 @@
use std::{borrow::Cow, path::Path};
use codec::Decode;
use sc_executor::{WasmExecutionMethod, WasmExecutor};
use sc_executor_common::runtime_blob::RuntimeBlob;
use sp_maybe_compressed_blob::CODE_BLOB_BOMB_LIMIT;
use polkadot_sdk::{
sc_executor::{self, WasmExecutionMethod, WasmExecutor},
sc_executor_common::runtime_blob::RuntimeBlob,
sp_io,
sp_maybe_compressed_blob::{self, CODE_BLOB_BOMB_LIMIT},
sp_state_machine,
};
use subxt_codegen::{fetch_metadata::fetch_metadata_from_file_blocking, CodegenError, Metadata};
/// Result type shorthand
+1 -1
View File
@@ -22,7 +22,7 @@ scale-info = { workspace = true, default-features = false }
frame-decode = { workspace = true }
frame-metadata = { workspace = true, default-features = false, features = ["current", "decode"] }
codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] }
hashbrown = { workspace = true }
[dev-dependencies]
+1
View File
@@ -11,6 +11,7 @@ use crate::{
use alloc::vec::Vec;
use hashbrown::HashMap;
use outer_enum_hashes::OuterEnumHashes;
use polkadot_sdk::sp_crypto_hashing;
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
pub mod outer_enum_hashes;
+2 -4
View File
@@ -18,7 +18,6 @@ keywords = ["parity", "subxt", "extrinsic", "signer"]
default = ["sr25519", "ecdsa", "subxt", "std"]
std = [
"regex/std",
"sp-crypto-hashing/std",
"pbkdf2/std",
"sha2/std",
"hmac/std",
@@ -60,7 +59,7 @@ cfg-if = { workspace = true }
codec = { package = "parity-scale-codec", workspace = true, features = [
"derive",
] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] }
pbkdf2 = { workspace = true }
sha2 = { workspace = true }
hmac = { workspace = true }
@@ -85,10 +84,9 @@ crypto_secretbox = { workspace = true, optional = true, features = ["alloc", "sa
getrandom = { workspace = true, optional = true }
[dev-dependencies]
sp-keyring = { workspace = true }
proptest = { workspace = true }
hex-literal = { workspace = true }
sp-core = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-core", "sp-keyring"] }
[package.metadata.cargo-machete]
ignored = ["getrandom"]
+1
View File
@@ -3,6 +3,7 @@
// see LICENSE for license details.
use codec::{Decode, Encode};
use polkadot_sdk::sp_crypto_hashing;
// This code is taken from sp_core::crypto::DeriveJunction. The logic should be identical,
// though the API is tweaked a touch.
+2 -2
View File
@@ -4,6 +4,7 @@
//! An ecdsa keypair implementation.
use codec::Encode;
use polkadot_sdk::sp_crypto_hashing;
use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri};
use core::{fmt::Display, str::FromStr};
@@ -359,8 +360,7 @@ mod test {
use super::*;
use sp_core::crypto::Pair as _;
use sp_core::ecdsa::Pair as SpPair;
use polkadot_sdk::sp_core::{self, crypto::Pair as _, ecdsa::Pair as SpPair};
#[test]
fn check_from_phrase_matches() {
+2 -2
View File
@@ -344,8 +344,8 @@ mod test {
use super::*;
use sp_core::crypto::Pair as _;
use sp_core::sr25519::Pair as SpPair;
use polkadot_sdk::sp_core::{self, crypto::Pair as _, sr25519::Pair as SpPair};
use polkadot_sdk::sp_keyring;
#[test]
fn check_from_phrase_matches() {
+2 -4
View File
@@ -104,7 +104,7 @@ instant = { workspace = true }
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true }
primitive-types = { workspace = true, features = ["codec", "scale-info", "serde"] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] }
# Included if the "jsonrpsee" feature is enabled.
jsonrpsee = { workspace = true, optional = true, features = ["jsonrpsee-types"] }
@@ -136,9 +136,7 @@ bitvec = { workspace = true }
codec = { workspace = true, features = ["derive", "bit-vec"] }
scale-info = { workspace = true, features = ["bit-vec"] }
tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread", "sync"] }
sp-core = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-core", "sp-keyring", "sp-runtime", "sp-crypto-hashing"] }
assert_matches = { workspace = true }
subxt-signer = { path = "../signer", features = ["unstable-eth"] }
# Tracing subscriber is useful for light-client examples to ensure that
@@ -507,7 +507,7 @@ mod test_utils {
#[cfg(test)]
mod test {
use futures::TryStreamExt;
use sp_core::H256;
use polkadot_sdk::sp_core::H256;
use super::super::follow_stream::test_utils::{
ev_best_block, ev_finalized, ev_initialized, ev_new_block,
+1 -1
View File
@@ -339,10 +339,10 @@ mod test {
pub use crate::backend::rpc::{RawRpcFuture, RawRpcSubscription};
pub use crate::{backend::StorageResponse, error::RpcError};
pub use futures::StreamExt;
pub use polkadot_sdk::sp_core::{self, H256};
pub use rpc::RpcClientT;
pub use serde::Serialize;
pub use serde_json::value::RawValue;
pub use sp_core::H256;
pub use std::collections::{HashMap, VecDeque};
pub use subxt_core::{config::DefaultExtrinsicParams, Config};
pub use tokio::sync::{mpsc, Mutex};
+2 -1
View File
@@ -81,9 +81,10 @@
//! # {
//! use subxt::config::PolkadotConfig;
//! use std::str::FromStr;
//! use polkadot_sdk::{sp_core, sp_keyring};
//!
//! //// 1. Use a `subxt_signer` impl:
//! use subxt_signer::{ SecretUri, sr25519 };
//! use subxt_signer::{SecretUri, sr25519};
//!
//! // Get hold of a `Signer` for a test account:
//! let alice = sr25519::dev::alice();
+1
View File
@@ -5,6 +5,7 @@
use crate::backend::{Backend, BackendExt, BlockRef};
use crate::{client::OnlineClientT, error::Error, events::Events, Config};
use derive_where::derive_where;
use polkadot_sdk::sp_crypto_hashing;
use std::future::Future;
/// A client for working with events.
+1 -1
View File
@@ -217,7 +217,7 @@ pub mod ext {
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// substitute_type(
/// path = "sp_runtime::multiaddress::MultiAddress<A, B>",
/// with = "::subxt::utils::Static<::sp_runtime::MultiAddress<A, B>>"
/// with = "::subxt::utils::Static<polkadot_sdk::sp_runtime::MultiAddress<A, B>>"
/// )
/// )]
/// mod polkadot {}
+1
View File
@@ -12,6 +12,7 @@ use crate::{
use codec::Decode;
use derive_where::derive_where;
use futures::StreamExt;
use polkadot_sdk::sp_crypto_hashing;
use std::{future::Future, marker::PhantomData};
use subxt_core::storage::address::{Address, StorageHashers, StorageKey};
use subxt_core::utils::Yes;
+2 -2
View File
@@ -635,8 +635,8 @@ mod test {
#[test]
fn transaction_validity_decoding_is_ok() {
use sp_runtime::transaction_validity as sp;
use sp_runtime::transaction_validity::TransactionValidity as T;
use polkadot_sdk::sp_runtime::transaction_validity as sp;
use polkadot_sdk::sp_runtime::transaction_validity::TransactionValidity as T;
let pairs = vec![
(
+1 -1
View File
@@ -34,7 +34,7 @@ hex = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
scale-info = { workspace = true, features = ["bit-vec"] }
sp-core = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-core"] }
syn = { workspace = true }
subxt = { workspace = true, features = ["unstable-metadata", "native", "jsonrpsee", "substrate-compat", "reconnecting-rpc-client"] }
subxt-signer = { workspace = true, features = ["default"] }
@@ -3,6 +3,7 @@
// see LICENSE for license details.
use crate::{node_runtime, subxt_test, test_context, utils::wait_for_blocks};
use polkadot_sdk::sp_core;
#[cfg(fullclient)]
use subxt::utils::AccountId32;
+430 -426
View File
File diff suppressed because it is too large Load Diff