mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
remove prelude from core, use alloc directly
This commit is contained in:
Generated
+1
-2
@@ -4541,7 +4541,6 @@ dependencies = [
|
||||
"base58",
|
||||
"bitvec",
|
||||
"blake2",
|
||||
"cfg-if",
|
||||
"derivative",
|
||||
"derive_more",
|
||||
"either",
|
||||
@@ -4636,7 +4635,7 @@ dependencies = [
|
||||
"sp-core",
|
||||
"sp-core-hashing",
|
||||
"sp-keyring",
|
||||
"subxt",
|
||||
"subxt-core",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -47,7 +47,6 @@ sp-core-hashing = { workspace = true }
|
||||
# Included if the "substrate-compat" feature is enabled.
|
||||
sp-core = { workspace = true, optional = true }
|
||||
sp-runtime = { workspace = true, optional = true }
|
||||
cfg-if = { workspace = true }
|
||||
either = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
use crate::client::ClientBase;
|
||||
|
||||
use super::Config;
|
||||
use crate::prelude::*;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Debug;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
use derive_more::Display;
|
||||
|
||||
|
||||
@@ -10,17 +10,16 @@
|
||||
use super::extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError};
|
||||
use super::Config;
|
||||
use crate::client::ClientBase;
|
||||
use crate::prelude::*;
|
||||
use crate::utils::Era;
|
||||
use borrow::ToOwned;
|
||||
use boxed::Box;
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Compact, Encode};
|
||||
use collections::BTreeMap;
|
||||
use core::fmt::Debug;
|
||||
use derivative::Derivative;
|
||||
use scale_decode::DecodeAsType;
|
||||
use scale_info::PortableRegistry;
|
||||
use vec::Vec;
|
||||
|
||||
/// A single [`SignedExtension`] has a unique name, but is otherwise the
|
||||
/// same as [`ExtrinsicParams`] in describing how to encode the extra and
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
//! Substrate specific configuration
|
||||
|
||||
use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, Hasher, Header};
|
||||
use crate::prelude::*;
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
pub use primitive_types::{H256, U256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
/// Default set of commonly used types by Substrate runtimes.
|
||||
// Note: We only use this at the type level, so it should be impossible to
|
||||
@@ -209,7 +208,7 @@ impl<'a> serde::Deserialize<'a> for DigestItem {
|
||||
{
|
||||
let r = impl_serde::serialize::deserialize(de)?;
|
||||
Decode::decode(&mut &r[..])
|
||||
.map_err(|e| serde::de::Error::custom(format!("Decode error: {e}")))
|
||||
.map_err(|e| serde::de::Error::custom(alloc::format!("Decode error: {e}")))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +291,7 @@ impl From<U256> for NumberOrHex {
|
||||
|
||||
/// A quick helper to encode some bytes to hex.
|
||||
fn to_hex(bytes: impl AsRef<[u8]>) -> String {
|
||||
format!("0x{}", hex::encode(bytes.as_ref()))
|
||||
alloc::format!("0x{}", hex::encode(bytes.as_ref()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+1
-2
@@ -6,10 +6,9 @@
|
||||
//! transactions, storage and constant lookups.
|
||||
|
||||
use crate::metadata::{DecodeWithMetadata, Metadata};
|
||||
use crate::prelude::*;
|
||||
use alloc::vec::Vec;
|
||||
use scale_decode::DecodeAsType;
|
||||
pub use scale_value::{At, Value};
|
||||
use vec::Vec;
|
||||
|
||||
/// A [`scale_value::Value`] type endowed with contextual information
|
||||
/// regarding what type was used to decode each part of it. This implements
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use alloc::string::String;
|
||||
use derive_more::{Display, From};
|
||||
|
||||
#[derive(Debug, Display, From)]
|
||||
|
||||
+9
-1
@@ -8,12 +8,13 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub mod client;
|
||||
pub mod config;
|
||||
pub mod dynamic;
|
||||
mod error;
|
||||
pub mod metadata;
|
||||
pub mod prelude;
|
||||
pub mod signer;
|
||||
pub mod storage;
|
||||
pub mod tx;
|
||||
@@ -26,7 +27,14 @@ pub use config::{
|
||||
PolkadotExtrinsicParams, SubstrateConfig, SubstrateExtrinsicParams,
|
||||
};
|
||||
|
||||
pub use signer::Signer;
|
||||
|
||||
pub use metadata::Metadata;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
mod marker {
|
||||
/// A unit marker struct that is only used for specialized generics.
|
||||
pub struct Yes;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
pub struct Yes;
|
||||
@@ -3,8 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::Metadata;
|
||||
use crate::prelude::*;
|
||||
use vec::Vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
/// This trait is implemented for all types that also implement [`scale_decode::DecodeAsType`].
|
||||
pub trait DecodeWithMetadata: Sized {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{prelude::*, MetadataError};
|
||||
use borrow::ToOwned;
|
||||
use sync::Arc;
|
||||
use crate::error::MetadataError;
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::sync::Arc;
|
||||
|
||||
/// A cheaply clone-able representation of the runtime metadata received from a node.
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate alloc;
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
#[allow(unused)]
|
||||
pub use std::{
|
||||
any,
|
||||
borrow,
|
||||
boxed,
|
||||
cmp,
|
||||
collections,
|
||||
fmt,
|
||||
format,
|
||||
hash,
|
||||
marker,
|
||||
mem,
|
||||
num,
|
||||
ops,
|
||||
string,
|
||||
sync,
|
||||
time,
|
||||
vec,
|
||||
rc,
|
||||
iter,
|
||||
};
|
||||
} else {
|
||||
#[allow(unused)]
|
||||
pub use alloc::{
|
||||
borrow,
|
||||
boxed,
|
||||
collections,
|
||||
format,
|
||||
string,
|
||||
sync,
|
||||
vec,
|
||||
rc
|
||||
};
|
||||
#[allow(unused)]
|
||||
pub use core::{
|
||||
any,
|
||||
cmp,
|
||||
fmt,
|
||||
hash,
|
||||
marker,
|
||||
mem,
|
||||
num,
|
||||
ops,
|
||||
time,
|
||||
iter,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
//! Types associated with accessing and working with storage items.
|
||||
|
||||
mod storage_address;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
/// Types representing an address which describes where a storage
|
||||
/// entry lives and how to properly decode it.
|
||||
pub mod storage_address;
|
||||
|
||||
pub mod address {
|
||||
pub use super::storage_address::{
|
||||
dynamic, make_static_storage_map_key, Address, DynamicAddress, StaticStorageMapKey,
|
||||
|
||||
@@ -11,9 +11,11 @@ use crate::{
|
||||
|
||||
use crate::metadata::{DecodeWithMetadata, EncodeWithMetadata, Metadata};
|
||||
use crate::Error;
|
||||
use alloc::borrow::{Cow, ToOwned};
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use derivative::Derivative;
|
||||
use scale_info::TypeDef;
|
||||
use std::borrow::Cow;
|
||||
use subxt_metadata::{StorageEntryType, StorageHasher};
|
||||
|
||||
/// This represents a storage address. Anything implementing this trait
|
||||
@@ -58,14 +60,14 @@ pub struct Yes;
|
||||
#[derive(Derivative)]
|
||||
#[derivative(
|
||||
Clone(bound = "StorageKey: Clone"),
|
||||
Debug(bound = "StorageKey: std::fmt::Debug")
|
||||
Debug(bound = "StorageKey: core::fmt::Debug")
|
||||
)]
|
||||
pub struct Address<StorageKey, ReturnTy, Fetchable, Defaultable, Iterable> {
|
||||
pallet_name: Cow<'static, str>,
|
||||
entry_name: Cow<'static, str>,
|
||||
storage_entry_keys: Vec<StorageKey>,
|
||||
validation_hash: Option<[u8; 32]>,
|
||||
_marker: std::marker::PhantomData<(ReturnTy, Fetchable, Defaultable, Iterable)>,
|
||||
_marker: core::marker::PhantomData<(ReturnTy, Fetchable, Defaultable, Iterable)>,
|
||||
}
|
||||
|
||||
/// A typical storage address constructed at runtime rather than via the `subxt` macro; this
|
||||
@@ -89,7 +91,7 @@ where
|
||||
entry_name: Cow::Owned(entry_name.into()),
|
||||
storage_entry_keys: storage_entry_keys.into_iter().collect(),
|
||||
validation_hash: None,
|
||||
_marker: std::marker::PhantomData,
|
||||
_marker: core::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +109,7 @@ where
|
||||
entry_name: Cow::Borrowed(entry_name),
|
||||
storage_entry_keys: storage_entry_keys.into_iter().collect(),
|
||||
validation_hash: Some(hash),
|
||||
_marker: std::marker::PhantomData,
|
||||
_marker: core::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +189,7 @@ where
|
||||
TypeDef::Tuple(tuple) => {
|
||||
either::Either::Left(tuple.fields.iter().map(|f| f.id))
|
||||
}
|
||||
_other => either::Either::Right(std::iter::once(*key_ty)),
|
||||
_other => either::Either::Right(core::iter::once(*key_ty)),
|
||||
};
|
||||
|
||||
if type_ids.len() < self.storage_entry_keys.len() {
|
||||
|
||||
+5
-10
@@ -5,21 +5,16 @@
|
||||
//! This module contains the trait and types used to represent
|
||||
//! transactions that can be submitted.
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::Error;
|
||||
use crate::MetadataError;
|
||||
use crate::{
|
||||
dynamic::Value,
|
||||
metadata::{self, Metadata},
|
||||
};
|
||||
use borrow::Cow;
|
||||
use borrow::ToOwned;
|
||||
use crate::{dynamic::Value, metadata::Metadata};
|
||||
use alloc::borrow::{Cow, ToOwned};
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::vec::Vec;
|
||||
use codec::Encode;
|
||||
use scale_encode::EncodeAsFields;
|
||||
use scale_value::{Composite, ValueDef, Variant};
|
||||
use string::String;
|
||||
use sync::Arc;
|
||||
use vec::Vec;
|
||||
|
||||
/// This represents a transaction payload that can be submitted
|
||||
/// to a node.
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
//! This doesn't contain much functionality itself, but is easy to convert to/from an `sp_core::AccountId32`
|
||||
//! for instance, to gain functionality without forcing a dependency on Substrate crates here.
|
||||
|
||||
use crate::prelude::*;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
use derive_more::Display;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
/// A 32-byte cryptographic identifier. This is a simplified version of Substrate's
|
||||
/// `sp_core::crypto::AccountId32`. To obtain more functionality, convert this into
|
||||
@@ -145,7 +145,7 @@ impl<'de> Deserialize<'de> for AccountId32 {
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
AccountId32::from_ss58check(&String::deserialize(deserializer)?)
|
||||
.map_err(|e| serde::de::Error::custom(format!("{e:?}")))
|
||||
.map_err(|e| serde::de::Error::custom(alloc::format!("{e:?}")))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
//! Generic `scale_bits` over `bitvec`-like `BitOrder` and `BitFormat` types.
|
||||
|
||||
use crate::prelude::*;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Compact, Input};
|
||||
use core::marker::PhantomData;
|
||||
use scale_bits::{
|
||||
@@ -12,7 +13,6 @@ use scale_bits::{
|
||||
Bits,
|
||||
};
|
||||
use scale_decode::IntoVisitor;
|
||||
use vec::Vec;
|
||||
|
||||
/// Associates `bitvec::store::BitStore` trait with corresponding, type-erased `scale_bits::StoreFormat` enum.
|
||||
///
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
//! Miscellaneous utility helpers.
|
||||
|
||||
use crate::prelude::*;
|
||||
use borrow::ToOwned;
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use derivative::Derivative;
|
||||
use vec::Vec;
|
||||
|
||||
mod account_id;
|
||||
pub mod bits;
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
//! This doesn't contain much functionality itself, but is easy to convert to/from an `sp_runtime::MultiAddress`
|
||||
//! for instance, to gain functionality without forcing a dependency on Substrate crates here.
|
||||
|
||||
use crate::prelude::*;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
use vec::Vec;
|
||||
|
||||
/// A multi-format address wrapper for on-chain accounts. This is a simplified version of Substrate's
|
||||
/// `sp_runtime::MultiAddress`. To obtain more functionality, convert this into that type (this conversion
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::prelude::*;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
use scale_decode::{visitor::DecodeAsTypeResult, IntoVisitor, Visitor};
|
||||
use scale_encode::EncodeAsType;
|
||||
use vec::Vec;
|
||||
|
||||
/// If the type inside this implements [`Encode`], this will implement [`scale_encode::EncodeAsType`].
|
||||
/// If the type inside this implements [`Decode`], this will implement [`scale_decode::DecodeAsType`].
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
//! bytes to be re-encoded (length prefixed).
|
||||
|
||||
use super::{Encoded, Static};
|
||||
use crate::prelude::*;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
use core::marker::PhantomData;
|
||||
use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, IntoVisitor, Visitor};
|
||||
use vec::Vec;
|
||||
|
||||
/// The unchecked extrinsic from substrate.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Encode)]
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::PhantomDataSendSync;
|
||||
use crate::prelude::*;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Compact, Decode, DecodeAll, Encode};
|
||||
use derivative::Derivative;
|
||||
use scale_decode::{IntoVisitor, Visitor};
|
||||
use scale_encode::EncodeAsType;
|
||||
use vec::Vec;
|
||||
|
||||
/// A wrapper for any type `T` which implement encode/decode in a way compatible with `Vec<u8>`.
|
||||
/// [`WrapperKeepOpaque`] stores the type only in its opaque format, aka as a `Vec<u8>`. To
|
||||
|
||||
+4
-5
@@ -15,7 +15,7 @@ description = "Sign extrinsics to be submitted by Subxt"
|
||||
keywords = ["parity", "subxt", "extrinsic", "signer"]
|
||||
|
||||
[features]
|
||||
default = ["sr25519", "ecdsa", "subxt", "native"]
|
||||
default = ["sr25519", "ecdsa", "subxt"]
|
||||
|
||||
# Pick the signer implementation(s) you need by enabling the
|
||||
# corresponding features. Note: I had more difficulties getting
|
||||
@@ -26,15 +26,14 @@ ecdsa = ["secp256k1"]
|
||||
|
||||
# Make the keypair algorithms here compatible with Subxt's Signer trait,
|
||||
# so that they can be used to sign transactions for compatible chains.
|
||||
subxt = ["dep:subxt"]
|
||||
subxt = ["dep:subxt-core"]
|
||||
|
||||
# The getrandom package is used via schnorrkel. We need to enable the JS
|
||||
# feature on it if compiling for the web.
|
||||
web = ["getrandom/js", "subxt?/web"]
|
||||
native = ["subxt?/native"]
|
||||
web = ["getrandom/js"]
|
||||
|
||||
[dependencies]
|
||||
subxt = { workspace = true, optional = true, default-features = false }
|
||||
subxt-core = { workspace = true, optional = true, default-features = false }
|
||||
regex = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] }
|
||||
|
||||
Generated
+1
-1
@@ -675,9 +675,9 @@ version = "0.34.0"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"blake2",
|
||||
"cfg-if",
|
||||
"derivative",
|
||||
"derive_more",
|
||||
"either",
|
||||
"frame-metadata 16.0.0",
|
||||
"hex",
|
||||
"impl-serde",
|
||||
|
||||
@@ -36,6 +36,7 @@ extern crate alloc;
|
||||
// Note: Panics in this function will lead to `Aborted (core dumped)` and a non-zero exit status => suitable for CI tests.
|
||||
fn run_tests() {
|
||||
subxt_metadata_test();
|
||||
subxt_core_test();
|
||||
}
|
||||
|
||||
/// Makes sure, subxt-metadata works in a no-std-context:
|
||||
@@ -49,5 +50,5 @@ fn subxt_metadata_test() {
|
||||
}
|
||||
|
||||
fn subxt_core_test() {
|
||||
let era = subxt_core::utils::Era::Immortal;
|
||||
let _ = subxt_core::utils::Era::Immortal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user