mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
Move subxt-new to be the new subxt, and get first example working
This commit is contained in:
+15
-4
@@ -15,7 +15,7 @@ description = "Sign extrinsics to be submitted by Subxt"
|
||||
keywords = ["parity", "subxt", "extrinsic", "signer"]
|
||||
|
||||
[features]
|
||||
default = ["sr25519", "ecdsa", "subxt", "std"]
|
||||
default = ["sr25519", "ecdsa", "std"]
|
||||
std = [
|
||||
"regex/std",
|
||||
"pbkdf2/std",
|
||||
@@ -40,18 +40,25 @@ ecdsa = ["secp256k1"]
|
||||
unstable-eth = ["keccak-hash", "ecdsa", "secp256k1", "bip32"]
|
||||
|
||||
# Enable support for loading key pairs from polkadot-js json.
|
||||
polkadot-js-compat = ["std", "subxt", "sr25519", "base64", "scrypt", "crypto_secretbox", "serde", "serde_json"]
|
||||
polkadot-js-compat = [
|
||||
"std",
|
||||
"sr25519",
|
||||
"base64",
|
||||
"scrypt",
|
||||
"crypto_secretbox",
|
||||
"serde",
|
||||
"serde_json"
|
||||
]
|
||||
|
||||
# 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-core"]
|
||||
subxt = ["dep:subxt"]
|
||||
|
||||
# The getrandom package is used via schnorrkel. We need to enable the JS
|
||||
# feature on it if compiling for the web.
|
||||
web = ["getrandom/js"]
|
||||
|
||||
[dependencies]
|
||||
subxt-core = { workspace = true, optional = true, default-features = false }
|
||||
secrecy = { workspace = true }
|
||||
regex = { workspace = true, features = ["unicode"] }
|
||||
hex = { workspace = true }
|
||||
@@ -74,12 +81,16 @@ secp256k1 = { workspace = true, optional = true, features = [
|
||||
keccak-hash = { workspace = true, optional = true }
|
||||
thiserror = { workspace = true, default-features = false }
|
||||
|
||||
# Pulled in if the subxt features is enabled.
|
||||
subxt = { workspace = true, optional = true }
|
||||
|
||||
# These are used if the polkadot-js-compat feature is enabled
|
||||
serde = { workspace = true, optional = true }
|
||||
serde_json = { workspace = true, optional = true }
|
||||
base64 = { workspace = true, optional = true, features = ["alloc"] }
|
||||
scrypt = { workspace = true, default-features = false, optional = true }
|
||||
crypto_secretbox = { workspace = true, optional = true, features = ["alloc", "salsa20"] }
|
||||
subxt-utils-accountid32 = { workspace = true, optional = true }
|
||||
|
||||
# We only pull this in to enable the JS flag for schnorrkel to use.
|
||||
getrandom = { workspace = true, optional = true }
|
||||
|
||||
+3
-4
@@ -297,10 +297,9 @@ pub mod dev {
|
||||
#[cfg(feature = "subxt")]
|
||||
mod subxt_compat {
|
||||
use super::*;
|
||||
|
||||
use subxt_core::config::Config;
|
||||
use subxt_core::tx::signer::Signer as SignerT;
|
||||
use subxt_core::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
use subxt::config::Config;
|
||||
use subxt::transactions::Signer as SignerT;
|
||||
use subxt::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
|
||||
impl From<Signature> for MultiSignature {
|
||||
fn from(value: Signature) -> Self {
|
||||
|
||||
+11
-10
@@ -309,10 +309,10 @@ pub mod dev {
|
||||
#[cfg(feature = "subxt")]
|
||||
mod subxt_compat {
|
||||
use super::*;
|
||||
use subxt_core::config::Config;
|
||||
use subxt_core::tx::signer::Signer as SignerT;
|
||||
use subxt_core::utils::AccountId20;
|
||||
use subxt_core::utils::MultiAddress;
|
||||
use subxt::config::Config;
|
||||
use subxt::transactions::Signer as SignerT;
|
||||
use subxt::utils::AccountId20;
|
||||
use subxt::utils::MultiAddress;
|
||||
|
||||
impl<T: Config> SignerT<T> for Keypair
|
||||
where
|
||||
@@ -365,21 +365,22 @@ mod test {
|
||||
use bip39::Mnemonic;
|
||||
use proptest::prelude::*;
|
||||
use secp256k1::Secp256k1;
|
||||
use subxt_core::utils::AccountId20;
|
||||
|
||||
use subxt_core::{config::*, tx::signer::Signer as SignerT};
|
||||
use subxt::utils::AccountId20;
|
||||
use subxt::transactions::Signer as SignerT;
|
||||
use subxt::config::{Config, HashFor, substrate};
|
||||
|
||||
use super::*;
|
||||
|
||||
enum StubEthRuntimeConfig {}
|
||||
#[derive(Debug, Clone)]
|
||||
struct StubEthRuntimeConfig;
|
||||
|
||||
impl Config for StubEthRuntimeConfig {
|
||||
type AccountId = AccountId20;
|
||||
type Address = AccountId20;
|
||||
type Signature = Signature;
|
||||
type Hasher = substrate::BlakeTwo256;
|
||||
type Header = substrate::SubstrateHeader<u32, substrate::BlakeTwo256>;
|
||||
type ExtrinsicParams = SubstrateExtrinsicParams<Self>;
|
||||
type Header = substrate::SubstrateHeader<HashFor<Self>>;
|
||||
type ExtrinsicParams = substrate::SubstrateExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
//! Enable the `subxt` feature to enable use of this [`sr25519::Keypair`] in signing
|
||||
//! subxt transactions for chains supporting sr25519 signatures.
|
||||
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
@@ -24,22 +23,18 @@ mod crypto;
|
||||
|
||||
// An sr25519 key pair implementation.
|
||||
#[cfg(feature = "sr25519")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "sr25519")))]
|
||||
pub mod sr25519;
|
||||
|
||||
// An ecdsa key pair implementation.
|
||||
#[cfg(feature = "ecdsa")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))]
|
||||
pub mod ecdsa;
|
||||
|
||||
// An ethereum signer implementation.
|
||||
#[cfg(feature = "unstable-eth")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-eth")))]
|
||||
pub mod eth;
|
||||
|
||||
/// A polkadot-js account json loader.
|
||||
#[cfg(feature = "polkadot-js-compat")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "polkadot-js-compat")))]
|
||||
pub mod polkadot_js_compat;
|
||||
|
||||
// Re-export useful bits and pieces for generating a Pair from a phrase,
|
||||
|
||||
@@ -76,6 +76,9 @@ struct KeyringPairJson {
|
||||
address: AccountId32,
|
||||
}
|
||||
|
||||
// Re-export this type which is used above.
|
||||
pub use subxt_utils_accountid32::AccountId32;
|
||||
|
||||
// This can be removed once split_array is stabilized.
|
||||
fn slice_to_u32(slice: &[u8]) -> u32 {
|
||||
u32::from_le_bytes(slice.try_into().expect("Slice should be 4 bytes."))
|
||||
|
||||
@@ -287,15 +287,11 @@ pub mod dev {
|
||||
// Make `Keypair` usable to sign transactions in Subxt. This is optional so that
|
||||
// `subxt-signer` can be used entirely independently of Subxt.
|
||||
#[cfg(feature = "subxt")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "subxt")))]
|
||||
mod subxt_compat {
|
||||
use super::*;
|
||||
|
||||
use subxt_core::{
|
||||
Config,
|
||||
tx::signer::Signer as SignerT,
|
||||
utils::{AccountId32, MultiAddress, MultiSignature},
|
||||
};
|
||||
use subxt::Config;
|
||||
use subxt::transactions::Signer as SignerT;
|
||||
use subxt::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
|
||||
impl From<Signature> for MultiSignature {
|
||||
fn from(value: Signature) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user