fix: Add workspace dependencies for vendored pezkuwi-subxt and zombienet-sdk

- Add all missing workspace dependencies required by vendor crates
- Include external crates: scale-*, sp-core, sc-chain-spec, kube, etc.
- Include subxt dependencies: smoldot, web-time, wasm-bindgen, etc.
- Regenerate umbrella crate with updated dependencies
- Apply zepter std feature propagation fixes to vendor crates
- Apply rustfmt formatting to vendor and pezframe files
This commit is contained in:
2025-12-23 00:18:55 +03:00
parent 70ddb6516f
commit 49485a882c
133 changed files with 1070 additions and 697 deletions
+1 -1
View File
@@ -8,8 +8,8 @@ use pezkuwi_subxt_metadata::PalletMetadata;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_typegen::{
typegen::ir::{type_ir::CompositeIRKind, ToTokensWithSettings},
TypeGenerator,
typegen::ir::{ToTokensWithSettings, type_ir::CompositeIRKind},
};
/// Generate calls from the provided pallet's metadata. Each call returns a `StaticPayload`
+1 -1
View File
@@ -6,7 +6,7 @@ use heck::ToSnakeCase as _;
use pezkuwi_subxt_metadata::PalletMetadata;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_typegen::{TypeGenerator, typegen::ir::ToTokensWithSettings};
use scale_typegen::{typegen::ir::ToTokensWithSettings, TypeGenerator};
use super::CodegenError;
+1 -1
View File
@@ -4,7 +4,7 @@
use heck::ToSnakeCase as _;
use pezkuwi_subxt_metadata::{CustomValueMetadata, Metadata};
use scale_typegen::{TypeGenerator, typegen::ir::ToTokensWithSettings};
use scale_typegen::{typegen::ir::ToTokensWithSettings, TypeGenerator};
use std::collections::HashSet;
use proc_macro2::TokenStream as TokenStream2;
+1 -1
View File
@@ -6,7 +6,7 @@ use super::CodegenError;
use pezkuwi_subxt_metadata::PalletMetadata;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use scale_typegen::{TypeGenerator, typegen::ir::ToTokensWithSettings};
use scale_typegen::{typegen::ir::ToTokensWithSettings, TypeGenerator};
/// Generate events from the provided pallet metadata.
///
+9 -7
View File
@@ -15,17 +15,17 @@ mod storage;
use pezkuwi_subxt_metadata::Metadata;
use scale_typegen::{
TypeGenerator,
typegen::{
ir::{
ToTokensWithSettings,
type_ir::{CompositeFieldIR, CompositeIR, CompositeIRKind},
ToTokensWithSettings,
},
type_params::TypeParameters,
type_path::TypePath,
},
TypeGenerator,
};
use syn::{Ident, parse_quote};
use syn::{parse_quote, Ident};
use crate::{
api::custom_values::generate_custom_values, error::CodegenError, ir, subxt_type_gen_settings,
@@ -438,16 +438,18 @@ pub fn generate_type_alias_mod(
CompositeIRKind::NoFields => {
return quote!(); // no types mod generated for unit structs.
},
CompositeIRKind::Named(named) =>
CompositeIRKind::Named(named) => {
for (name, field) in named.iter_mut() {
let alias_name = format_ident!("{}", name.to_string().to_upper_camel_case());
modify_field_to_be_type_alias(field, alias_name);
},
CompositeIRKind::Unnamed(unnamed) =>
}
},
CompositeIRKind::Unnamed(unnamed) => {
for (i, field) in unnamed.iter_mut().enumerate() {
let alias_name = format_ident!("Field{}", i);
modify_field_to_be_type_alias(field, alias_name);
},
}
},
};
let types_mod_ident = type_gen.types_mod_ident();
@@ -8,7 +8,7 @@ use crate::CodegenError;
use pezkuwi_subxt_metadata::{PalletMetadata, ViewFunctionMetadata};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_typegen::{TypeGenerator, typegen::ir::ToTokensWithSettings};
use scale_typegen::{typegen::ir::ToTokensWithSettings, TypeGenerator};
use std::collections::HashSet;
pub fn generate_pallet_view_functions(
+1 -1
View File
@@ -7,7 +7,7 @@ use std::collections::HashSet;
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
use pezkuwi_subxt_metadata::{Metadata, RuntimeApiMetadata};
use scale_typegen::{TypeGenerator, typegen::ir::ToTokensWithSettings};
use scale_typegen::{typegen::ir::ToTokensWithSettings, TypeGenerator};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
+1 -1
View File
@@ -172,7 +172,7 @@ fn generate_storage_entry_fns(
mod tests {
use frame_metadata::v15;
use pezkuwi_subxt_metadata::Metadata;
use scale_info::{MetaType, meta_type};
use scale_info::{meta_type, MetaType};
// TODO: Think about adding tests for storage codegen which can use this sort of function.
#[allow(dead_code)]
+1 -1
View File
@@ -19,8 +19,8 @@ use getrandom as _;
use api::RuntimeGenerator;
use proc_macro2::TokenStream as TokenStream2;
use scale_typegen::{
typegen::settings::{substitutes::absolute_path, AllocCratePath},
DerivesRegistry, TypeGeneratorSettings, TypeSubstitutes, TypegenError,
typegen::settings::{AllocCratePath, substitutes::absolute_path},
};
use std::collections::HashMap;
use syn::parse_quote;
+5
View File
@@ -30,6 +30,11 @@ std = [
"serde/std",
"serde_json/std",
"tracing/std",
"bitvec/std",
"blake2/std",
"frame-decode/std",
"keccak-hash/std",
"pezkuwi-subxt-signer/std"
]
[dependencies]
@@ -3,13 +3,13 @@
// see LICENSE for license details.
use crate::{
Metadata,
config::{
Config, TransactionExtension,
transaction_extensions::{ChargeAssetTxPayment, ChargeTransactionPayment, CheckNonce},
Config, TransactionExtension,
},
dynamic::Value,
error::ExtrinsicError,
Metadata,
};
use alloc::borrow::ToOwned;
use frame_decode::extrinsics::ExtrinsicExtensions;
+5 -5
View File
@@ -3,10 +3,10 @@
// see LICENSE for license details.
use crate::{
Metadata,
blocks::extrinsic_transaction_extensions::ExtrinsicTransactionExtensions,
config::{Config, HashFor, Hasher},
error::{ExtrinsicDecodeErrorAt, ExtrinsicDecodeErrorAtReason, ExtrinsicError},
Metadata,
};
use alloc::{sync::Arc, vec::Vec};
use frame_decode::extrinsics::Extrinsic;
@@ -284,8 +284,8 @@ where
/// Attempt to decode these [`ExtrinsicDetails`] into a type representing the extrinsic fields.
/// Such types are exposed in the codegen as `pallet_name::calls::types::CallName` types.
pub fn as_extrinsic<E: StaticExtrinsic>(&self) -> Result<Option<E>, ExtrinsicError> {
if self.decoded_info().pallet_name() == E::PALLET &&
self.decoded_info().call_name() == E::CALL
if self.decoded_info().pallet_name() == E::PALLET
&& self.decoded_info().call_name() == E::CALL
{
let mut fields = self.decoded_info().call_data().map(|d| {
let name = if d.name().is_empty() { None } else { Some(d.name()) };
@@ -340,13 +340,13 @@ mod tests {
use assert_matches::assert_matches;
use codec::{Decode, Encode};
use frame_metadata::{
RuntimeMetadataPrefixed,
v15::{
CustomMetadata, ExtrinsicMetadata, OuterEnums, PalletCallMetadata, PalletMetadata,
RuntimeMetadataV15,
},
RuntimeMetadataPrefixed,
};
use scale_info::{TypeInfo, meta_type};
use scale_info::{meta_type, TypeInfo};
use scale_value::Value;
// Extrinsic needs to contain at least the generic type parameter "Call"
+1 -1
View File
@@ -69,7 +69,7 @@ mod extrinsics;
mod static_extrinsic;
pub use crate::error::ExtrinsicError;
use crate::{Metadata, config::Config, error::ExtrinsicDecodeErrorAt};
use crate::{config::Config, error::ExtrinsicDecodeErrorAt, Metadata};
use alloc::vec::Vec;
pub use extrinsic_transaction_extensions::{
ExtrinsicTransactionExtension, ExtrinsicTransactionExtensions,
+1 -1
View File
@@ -5,8 +5,8 @@
//! A couple of client types that we use elsewhere.
use crate::{
Metadata,
config::{Config, HashFor},
Metadata,
};
use derive_where::derive_where;
@@ -4,7 +4,7 @@
use crate::config::transaction_extensions::CheckMortalityParams;
use super::{Config, ExtrinsicParams, HashFor, transaction_extensions};
use super::{transaction_extensions, Config, ExtrinsicParams, HashFor};
/// The default [`super::ExtrinsicParams`] implementation understands common signed extensions
/// and how to apply them to a given chain.
+5 -3
View File
@@ -11,8 +11,8 @@
mod default_extrinsic_params;
mod extrinsic_params;
pub mod pezkuwi;
pub mod bizinikiwi;
pub mod pezkuwi;
pub mod transaction_extensions;
use codec::{Decode, Encode};
@@ -20,12 +20,14 @@ use core::fmt::Debug;
use pezkuwi_subxt_metadata::Metadata;
use scale_decode::DecodeAsType;
use scale_encode::EncodeAsType;
use serde::{Serialize, de::DeserializeOwned};
use serde::{de::DeserializeOwned, Serialize};
pub use bizinikiwi::{
BizinikiwConfig, BizinikiwiExtrinsicParams, BizinikiwiExtrinsicParamsBuilder,
};
pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
pub use extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder};
pub use pezkuwi::{PezkuwiConfig, PezkuwiExtrinsicParams, PezkuwiExtrinsicParamsBuilder};
pub use bizinikiwi::{BizinikiwConfig, BizinikiwiExtrinsicParams, BizinikiwiExtrinsicParamsBuilder};
pub use transaction_extensions::TransactionExtension;
/// Runtime types.
@@ -398,13 +398,14 @@ impl<T: Config> CheckMortalityParams<T> {
impl<T: Config> Params<T> for CheckMortalityParams<T> {
fn inject_block(&mut self, from_block_n: u64, from_block_hash: HashFor<T>) {
match &self.0 {
CheckMortalityParamsInner::MortalForBlocks(n) |
CheckMortalityParamsInner::MortalForBlocksOrImmortalIfNotPossible(n) =>
CheckMortalityParamsInner::MortalForBlocks(n)
| CheckMortalityParamsInner::MortalForBlocksOrImmortalIfNotPossible(n) => {
self.0 = CheckMortalityParamsInner::MortalFromBlock {
for_n_blocks: *n,
from_block_n,
from_block_hash,
},
}
},
_ => {
// Don't change anything if explicit Immortal or explicit block set.
},
@@ -670,10 +671,10 @@ fn is_type_empty(type_id: u32, types: &scale_info::PortableRegistry) -> bool {
TypeDef::Array(a) => a.len == 0 || is_type_empty(a.type_param.id, types),
TypeDef::Tuple(t) => t.fields.iter().all(|f| is_type_empty(f.id, types)),
// Explicitly list these in case any additions are made in the future.
TypeDef::BitSequence(_) |
TypeDef::Variant(_) |
TypeDef::Sequence(_) |
TypeDef::Compact(_) |
TypeDef::Primitive(_) => false,
TypeDef::BitSequence(_)
| TypeDef::Variant(_)
| TypeDef::Sequence(_)
| TypeDef::Compact(_)
| TypeDef::Primitive(_) => false,
}
}
+1 -1
View File
@@ -40,7 +40,7 @@
pub mod address;
use crate::{Metadata, error::ConstantError};
use crate::{error::ConstantError, Metadata};
use address::Address;
use alloc::{borrow::ToOwned, string::ToString, vec::Vec};
use frame_decode::constants::ConstantTypeInfo;
+2 -2
View File
@@ -32,7 +32,7 @@
pub mod address;
use crate::{Metadata, error::CustomValueError, utils::Maybe};
use crate::{error::CustomValueError, utils::Maybe, Metadata};
use address::Address;
use alloc::vec::Vec;
use frame_decode::custom_values::CustomValueTypeInfo;
@@ -99,7 +99,7 @@ mod tests {
use alloc::collections::BTreeMap;
use codec::Encode;
use scale_decode::DecodeAsType;
use scale_info::{TypeInfo, form::PortableForm};
use scale_info::{form::PortableForm, TypeInfo};
use alloc::{borrow::ToOwned, string::String, vec};
+5 -5
View File
@@ -46,9 +46,9 @@ use pezkuwi_subxt_metadata::PalletMetadata;
use scale_decode::{DecodeAsFields, DecodeAsType};
use crate::{
Metadata,
config::{Config, HashFor},
error::EventsError,
Metadata,
};
/// Create a new [`Events`] instance from the given bytes.
@@ -466,16 +466,16 @@ pub struct EventMetadataDetails<'a> {
#[cfg(test)]
pub(crate) mod test_utils {
use super::*;
use crate::config::{HashFor, BizinikiwConfig};
use crate::config::{BizinikiwConfig, HashFor};
use codec::Encode;
use frame_metadata::{
RuntimeMetadataPrefixed,
v15::{
CustomMetadata, ExtrinsicMetadata, OuterEnums, PalletEventMetadata, PalletMetadata,
RuntimeMetadataV15,
},
RuntimeMetadataPrefixed,
};
use scale_info::{TypeInfo, meta_type};
use scale_info::{meta_type, TypeInfo};
/// An "outer" events enum containing exactly one event.
#[derive(
@@ -611,7 +611,7 @@ pub(crate) mod test_utils {
#[cfg(test)]
mod tests {
use super::{
test_utils::{AllEvents, EventRecord, event_record, events, events_raw},
test_utils::{event_record, events, events_raw, AllEvents, EventRecord},
*,
};
use crate::{config::BizinikiwConfig, events::Phase};
+6 -2
View File
@@ -43,7 +43,7 @@
pub mod payload;
use crate::{Metadata, error::RuntimeApiError};
use crate::{error::RuntimeApiError, Metadata};
use alloc::{
format,
string::{String, ToString},
@@ -75,7 +75,11 @@ pub fn validate<P: Payload>(payload: P, metadata: &Metadata) -> Result<(), Runti
method_name: method_name.to_string(),
})?;
if hash != api_method.hash() { Err(RuntimeApiError::IncompatibleCodegen) } else { Ok(()) }
if hash != api_method.hash() {
Err(RuntimeApiError::IncompatibleCodegen)
} else {
Ok(())
}
}
/// Return the name of the runtime API call from the payload.
+7 -3
View File
@@ -53,12 +53,12 @@ mod storage_value;
pub mod address;
use crate::{Metadata, error::StorageError};
use crate::{error::StorageError, Metadata};
use address::Address;
use alloc::string::ToString;
pub use prefix_of::{EqualOrPrefixOf, PrefixOf};
pub use storage_entry::{StorageEntry, entry};
pub use storage_entry::{entry, StorageEntry};
pub use storage_key::{StorageHasher, StorageKey, StorageKeyPart};
pub use storage_key_value::StorageKeyValue;
pub use storage_value::StorageValue;
@@ -86,5 +86,9 @@ pub fn validate<Addr: Address>(address: Addr, metadata: &Metadata) -> Result<(),
}
})?;
if storage_hash != hash { Err(StorageError::IncompatibleCodegen) } else { Ok(()) }
if storage_hash != hash {
Err(StorageError::IncompatibleCodegen)
} else {
Ok(())
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::{PrefixOf, StorageKeyValue, StorageValue, address::Address};
use super::{address::Address, PrefixOf, StorageKeyValue, StorageValue};
use crate::{error::StorageError, utils::YesMaybe};
use alloc::{sync::Arc, vec::Vec};
use frame_decode::storage::{IntoEncodableValues, StorageInfo};
+11 -3
View File
@@ -60,10 +60,10 @@ pub mod payload;
pub mod signer;
use crate::{
Metadata,
config::{Config, ExtrinsicParams, ExtrinsicParamsEncoder, HashFor, Hasher},
error::ExtrinsicError,
utils::Encoded,
Metadata,
};
use alloc::{borrow::Cow, string::ToString, vec::Vec};
use codec::{Compact, Encode};
@@ -95,7 +95,11 @@ pub fn validate<Call: Payload>(call: &Call, metadata: &Metadata) -> Result<(), E
call_name: call_name.to_string(),
})?;
if details.hash != expected_hash { Err(ExtrinsicError::IncompatibleCodegen) } else { Ok(()) }
if details.hash != expected_hash {
Err(ExtrinsicError::IncompatibleCodegen)
} else {
Ok(())
}
}
/// Returns the suggested transaction versions to build for a given chain, or an error
@@ -252,7 +256,11 @@ impl<T: Config> PartialTransactionV4<T> {
self.additional_and_extra_params.encode_signer_payload_value_to(&mut bytes);
self.additional_and_extra_params.encode_implicit_to(&mut bytes);
if bytes.len() > 256 { f(Cow::Borrowed(&blake2_256(&bytes))) } else { f(Cow::Owned(bytes)) }
if bytes.len() > 256 {
f(Cow::Borrowed(&blake2_256(&bytes)))
} else {
f(Cow::Owned(bytes))
}
}
/// Return the V4 signer payload for this extrinsic. These are the bytes that must
+1 -1
View File
@@ -5,7 +5,7 @@
//! This module contains the trait and types used to represent
//! transactions that can be submitted.
use crate::{Metadata, error::ExtrinsicError};
use crate::{error::ExtrinsicError, Metadata};
use alloc::{
borrow::Cow,
boxed::Box,
+1 -1
View File
@@ -8,8 +8,8 @@ use alloc::{vec, vec::Vec};
use codec::{Compact, Input};
use core::marker::PhantomData;
use scale_bits::{
Bits,
scale::format::{Format, OrderFormat, StoreFormat},
Bits,
};
use scale_decode::{IntoVisitor, TypeResolver};
+4 -4
View File
@@ -5,12 +5,12 @@
use alloc::{format, vec::Vec};
use codec::{Decode, Encode};
use scale_decode::{
IntoVisitor, TypeResolver, Visitor,
ext::scale_type_resolver,
visitor::{
TypeIdFor,
types::{Composite, Variant},
TypeIdFor,
},
IntoVisitor, TypeResolver, Visitor,
};
use scale_encode::EncodeAsType;
@@ -81,8 +81,8 @@ impl codec::Encode for Era {
Self::Immortal => output.push_byte(0),
Self::Mortal { period, phase } => {
let quantize_factor = (*period >> 12).max(1);
let encoded = (period.trailing_zeros() - 1).clamp(1, 15) as u16 |
((phase / quantize_factor) << 4) as u16;
let encoded = (period.trailing_zeros() - 1).clamp(1, 15) as u16
| ((phase / quantize_factor) << 4) as u16;
encoded.encode_to(output);
},
}
+2 -2
View File
@@ -3,7 +3,7 @@
// see LICENSE for license details.
use codec::{Decode, Encode};
use scale_decode::{IntoVisitor, TypeResolver, Visitor, visitor::DecodeAsTypeResult};
use scale_decode::{visitor::DecodeAsTypeResult, IntoVisitor, TypeResolver, Visitor};
use scale_encode::EncodeAsType;
use alloc::vec::Vec;
@@ -45,7 +45,7 @@ impl<T: Decode, R: TypeResolver> Visitor for StaticDecodeAsTypeVisitor<T, R> {
_type_id: R::TypeId,
_types: &'info R,
) -> DecodeAsTypeResult<Self, Result<Self::Value<'scale, 'info>, Self::Error>> {
use scale_decode::{Error, visitor::DecodeError};
use scale_decode::{visitor::DecodeError, Error};
let decoded = T::decode(input)
.map(Static)
.map_err(|e| Error::new(DecodeError::CodecError(e).into()));
+5 -5
View File
@@ -12,7 +12,7 @@
use core::marker::PhantomData;
use codec::{Decode, Encode};
use scale_decode::{DecodeAsType, IntoVisitor, TypeResolver, Visitor, visitor::DecodeAsTypeResult};
use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, IntoVisitor, TypeResolver, Visitor};
use super::{Encoded, Static};
use alloc::vec::Vec;
@@ -32,7 +32,7 @@ impl<Address, Call, Signature, Extra> UncheckedExtrinsic<Address, Call, Signatur
/// Get the bytes of the encoded extrinsic.
pub fn bytes(&self) -> &[u8] {
self.0.0.0.as_slice()
self.0 .0 .0.as_slice()
}
}
@@ -75,7 +75,7 @@ impl<Address, Call, Signature, Extra> From<UncheckedExtrinsic<Address, Call, Sig
for Vec<u8>
{
fn from(bytes: UncheckedExtrinsic<Address, Call, Signature, Extra>) -> Self {
bytes.0.0.0
bytes.0 .0 .0
}
}
@@ -106,8 +106,8 @@ impl<Address, Call, Signature, Extra> IntoVisitor
type AnyVisitor<R: TypeResolver> =
UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R>;
fn into_visitor<R: TypeResolver>()
-> UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R> {
fn into_visitor<R: TypeResolver>(
) -> UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R> {
UncheckedExtrinsicDecodeAsTypeVisitor(PhantomData)
}
}
+8 -5
View File
@@ -5,7 +5,7 @@
use super::PhantomDataSendSync;
use codec::{Compact, Decode, DecodeAll, Encode};
use derive_where::derive_where;
use scale_decode::{IntoVisitor, TypeResolver, Visitor, ext::scale_type_resolver::visitor};
use scale_decode::{ext::scale_type_resolver::visitor, IntoVisitor, TypeResolver, Visitor};
use scale_encode::EncodeAsType;
use alloc::{format, vec::Vec};
@@ -108,9 +108,12 @@ impl<T, R: TypeResolver> Visitor for WrapperKeepOpaqueVisitor<T, R> {
};
if value.name() != Some("WrapperKeepOpaque") {
return Err(Error::new(ErrorKind::VisitorDecodeError(DecodeError::TypeResolvingError(
format!("Expected a type named 'WrapperKeepOpaque', got: {:?}", value.name()),
))));
return Err(Error::new(ErrorKind::VisitorDecodeError(
DecodeError::TypeResolvingError(format!(
"Expected a type named 'WrapperKeepOpaque', got: {:?}",
value.name()
)),
)));
}
if value.remaining() != 2 {
@@ -159,7 +162,7 @@ mod test {
impl<T: scale_info::TypeInfo + 'static> scale_info::TypeInfo for WrapperKeepOpaque<T> {
type Identity = Self;
fn type_info() -> scale_info::Type {
use scale_info::{Path, Type, TypeParameter, build::Fields, meta_type};
use scale_info::{build::Fields, meta_type, Path, Type, TypeParameter};
Type::builder()
.path(Path::new("WrapperKeepOpaque", module_path!()))
+6 -2
View File
@@ -7,7 +7,7 @@
pub mod payload;
use crate::{Metadata, error::ViewFunctionError};
use crate::{error::ViewFunctionError, Metadata};
use alloc::{string::ToString, vec::Vec};
use payload::Payload;
use scale_decode::IntoVisitor;
@@ -33,7 +33,11 @@ pub fn validate<P: Payload>(payload: P, metadata: &Metadata) -> Result<(), ViewF
function_name: function_name.to_string(),
})?;
if hash != view_function.hash() { Err(ViewFunctionError::IncompatibleCodegen) } else { Ok(()) }
if hash != view_function.hash() {
Err(ViewFunctionError::IncompatibleCodegen)
} else {
Ok(())
}
}
/// The name of the Runtime API call which can execute
+2 -2
View File
@@ -2,8 +2,8 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{JsonRpcError, LightClientRpcError, rpc::RpcResponse, shared_client::SharedClient};
use futures::{FutureExt, stream::StreamExt};
use crate::{rpc::RpcResponse, shared_client::SharedClient, JsonRpcError, LightClientRpcError};
use futures::{stream::StreamExt, FutureExt};
use serde_json::value::RawValue;
use smoldot_light::platform::PlatformRef;
use std::{collections::HashMap, str::FromStr};
+1 -1
View File
@@ -11,7 +11,7 @@ mod wasm_platform;
#[cfg(feature = "web")]
mod wasm_socket;
pub use helpers::{DefaultPlatform, build_platform};
pub use helpers::{build_platform, DefaultPlatform};
#[cfg(feature = "native")]
mod helpers {
@@ -8,7 +8,7 @@
use super::wasm_socket::WasmSocket;
use core::time::Duration;
use futures_util::{FutureExt, future};
use futures_util::{future, FutureExt};
pub fn now_from_unix_epoch() -> Duration {
web_time::SystemTime::now()
@@ -89,9 +89,9 @@ impl PlatformRef for SubxtPlatform {
fn supports_connection_type(&self, connection_type: ConnectionType) -> bool {
let result = matches!(
connection_type,
ConnectionType::WebSocketIpv4 { .. } |
ConnectionType::WebSocketIpv6 { .. } |
ConnectionType::WebSocketDns { .. }
ConnectionType::WebSocketIpv4 { .. }
| ConnectionType::WebSocketIpv6 { .. }
| ConnectionType::WebSocketDns { .. }
);
tracing::trace!(
@@ -4,7 +4,7 @@
use futures::{io, prelude::*};
use send_wrapper::SendWrapper;
use wasm_bindgen::{JsCast, prelude::*};
use wasm_bindgen::{prelude::*, JsCast};
use std::{
collections::VecDeque,
+2 -2
View File
@@ -5,7 +5,7 @@
//! Subxt macro for generating Bizinikiwi runtime interfaces.
use codec::Decode;
use darling::{FromMeta, ast::NestedMeta};
use darling::{ast::NestedMeta, FromMeta};
use pezkuwi_subxt_codegen::{CodegenBuilder, CodegenError, Metadata};
use proc_macro::TokenStream;
use proc_macro_error2::{abort_call_site, proc_macro_error};
@@ -261,7 +261,7 @@ fn fetch_metadata(
},
#[cfg(feature = "runtime-metadata-insecure-url")]
(None, Some(url_string)) => {
use pezkuwi_subxt_utils_fetchmetadata::{MetadataVersion, Url, from_url_blocking};
use pezkuwi_subxt_utils_fetchmetadata::{from_url_blocking, MetadataVersion, Url};
let url = Url::parse(url_string).unwrap_or_else(|_| {
abort_call_site!("Cannot download metadata; invalid url: {}", url_string)
+8 -1
View File
@@ -15,7 +15,14 @@ description = "Command line utilities for checking metadata compatibility betwee
[features]
default = ["legacy", "std"]
std = ["frame-metadata/std", "scale-info/std"]
std = [
"frame-metadata/std",
"scale-info/std",
"bitvec/std",
"frame-decode/std",
"codec/std",
"pezsp-crypto-hashing/std"
]
# Enable decoding of legacy metadata, too.
# std required by frame-metadata to decode <V14.
+2 -2
View File
@@ -3,8 +3,8 @@ mod portable_registry_builder;
mod tests;
use crate::{
Metadata,
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
Metadata,
};
use alloc::{borrow::ToOwned, collections::BTreeMap, format, string::ToString, vec::Vec};
use frame_decode::{
@@ -15,7 +15,7 @@ use frame_decode::{
};
use frame_metadata::v15;
use portable_registry_builder::PortableRegistryBuilder;
use scale_info_legacy::{TypeRegistrySet, type_registry::RuntimeApiName};
use scale_info_legacy::{type_registry::RuntimeApiName, TypeRegistrySet};
/// Options to configure the legacy translating.
pub(crate) struct Opts {
@@ -4,8 +4,8 @@ use alloc::{
string::ToString,
vec::Vec,
};
use scale_info::{PortableRegistry, PortableType, form::PortableForm};
use scale_info_legacy::{LookupName, TypeRegistrySet, type_registry::TypeRegistryResolveError};
use scale_info::{form::PortableForm, PortableRegistry, PortableType};
use scale_info_legacy::{type_registry::TypeRegistryResolveError, LookupName, TypeRegistrySet};
use scale_type_resolver::{
BitsOrderFormat, BitsStoreFormat, FieldIter, PathIter, Primitive, ResolvedTypeVisitor,
UnhandledKind, VariantIter,
@@ -459,9 +459,9 @@ fn prepare_path<'info, Path: PathIter<'info>>(
// Non-compliant paths are converted to our default path
let non_compliant_path = path[0..path.len() - 1].iter().any(|&p| {
p.is_empty() ||
p.starts_with(|c: char| !c.is_ascii_alphabetic()) ||
p.contains(|c: char| !c.is_ascii_alphanumeric() || c.is_ascii_uppercase())
p.is_empty()
|| p.starts_with(|c: char| !c.is_ascii_alphabetic())
|| p.contains(|c: char| !c.is_ascii_alphanumeric() || c.is_ascii_uppercase())
});
if non_compliant_path {
let last = *path.last().unwrap();
+15 -10
View File
@@ -432,16 +432,21 @@ fn codegen_works() {
};
match &metadata {
RuntimeMetadata::V9(m) =>
pezkuwi_subxt_codegen::Metadata::from_v9(m, &types_for_spec),
RuntimeMetadata::V10(m) =>
pezkuwi_subxt_codegen::Metadata::from_v10(m, &types_for_spec),
RuntimeMetadata::V11(m) =>
pezkuwi_subxt_codegen::Metadata::from_v11(m, &types_for_spec),
RuntimeMetadata::V12(m) =>
pezkuwi_subxt_codegen::Metadata::from_v12(m, &types_for_spec),
RuntimeMetadata::V13(m) =>
pezkuwi_subxt_codegen::Metadata::from_v13(m, &types_for_spec),
RuntimeMetadata::V9(m) => {
pezkuwi_subxt_codegen::Metadata::from_v9(m, &types_for_spec)
},
RuntimeMetadata::V10(m) => {
pezkuwi_subxt_codegen::Metadata::from_v10(m, &types_for_spec)
},
RuntimeMetadata::V11(m) => {
pezkuwi_subxt_codegen::Metadata::from_v11(m, &types_for_spec)
},
RuntimeMetadata::V12(m) => {
pezkuwi_subxt_codegen::Metadata::from_v12(m, &types_for_spec)
},
RuntimeMetadata::V13(m) => {
pezkuwi_subxt_codegen::Metadata::from_v13(m, &types_for_spec)
},
_ => panic!("Metadata version {} not expected", metadata.version()),
}
.expect("Could not convert to pezkuwi_subxt_metadata::Metadata")
+42 -28
View File
@@ -53,34 +53,48 @@ impl TryFrom<frame_metadata::RuntimeMetadataPrefixed> for crate::Metadata {
fn try_from(value: frame_metadata::RuntimeMetadataPrefixed) -> Result<Self, Self::Error> {
match value.1 {
frame_metadata::RuntimeMetadata::V0(_) =>
Err(TryFromError::UnsupportedMetadataVersion(0)),
frame_metadata::RuntimeMetadata::V1(_) =>
Err(TryFromError::UnsupportedMetadataVersion(1)),
frame_metadata::RuntimeMetadata::V2(_) =>
Err(TryFromError::UnsupportedMetadataVersion(2)),
frame_metadata::RuntimeMetadata::V3(_) =>
Err(TryFromError::UnsupportedMetadataVersion(3)),
frame_metadata::RuntimeMetadata::V4(_) =>
Err(TryFromError::UnsupportedMetadataVersion(4)),
frame_metadata::RuntimeMetadata::V5(_) =>
Err(TryFromError::UnsupportedMetadataVersion(5)),
frame_metadata::RuntimeMetadata::V6(_) =>
Err(TryFromError::UnsupportedMetadataVersion(6)),
frame_metadata::RuntimeMetadata::V7(_) =>
Err(TryFromError::UnsupportedMetadataVersion(7)),
frame_metadata::RuntimeMetadata::V8(_) =>
Err(TryFromError::UnsupportedMetadataVersion(8)),
frame_metadata::RuntimeMetadata::V9(_) =>
Err(TryFromError::UnsupportedMetadataVersion(9)),
frame_metadata::RuntimeMetadata::V10(_) =>
Err(TryFromError::UnsupportedMetadataVersion(10)),
frame_metadata::RuntimeMetadata::V11(_) =>
Err(TryFromError::UnsupportedMetadataVersion(11)),
frame_metadata::RuntimeMetadata::V12(_) =>
Err(TryFromError::UnsupportedMetadataVersion(12)),
frame_metadata::RuntimeMetadata::V13(_) =>
Err(TryFromError::UnsupportedMetadataVersion(13)),
frame_metadata::RuntimeMetadata::V0(_) => {
Err(TryFromError::UnsupportedMetadataVersion(0))
},
frame_metadata::RuntimeMetadata::V1(_) => {
Err(TryFromError::UnsupportedMetadataVersion(1))
},
frame_metadata::RuntimeMetadata::V2(_) => {
Err(TryFromError::UnsupportedMetadataVersion(2))
},
frame_metadata::RuntimeMetadata::V3(_) => {
Err(TryFromError::UnsupportedMetadataVersion(3))
},
frame_metadata::RuntimeMetadata::V4(_) => {
Err(TryFromError::UnsupportedMetadataVersion(4))
},
frame_metadata::RuntimeMetadata::V5(_) => {
Err(TryFromError::UnsupportedMetadataVersion(5))
},
frame_metadata::RuntimeMetadata::V6(_) => {
Err(TryFromError::UnsupportedMetadataVersion(6))
},
frame_metadata::RuntimeMetadata::V7(_) => {
Err(TryFromError::UnsupportedMetadataVersion(7))
},
frame_metadata::RuntimeMetadata::V8(_) => {
Err(TryFromError::UnsupportedMetadataVersion(8))
},
frame_metadata::RuntimeMetadata::V9(_) => {
Err(TryFromError::UnsupportedMetadataVersion(9))
},
frame_metadata::RuntimeMetadata::V10(_) => {
Err(TryFromError::UnsupportedMetadataVersion(10))
},
frame_metadata::RuntimeMetadata::V11(_) => {
Err(TryFromError::UnsupportedMetadataVersion(11))
},
frame_metadata::RuntimeMetadata::V12(_) => {
Err(TryFromError::UnsupportedMetadataVersion(12))
},
frame_metadata::RuntimeMetadata::V13(_) => {
Err(TryFromError::UnsupportedMetadataVersion(13))
},
frame_metadata::RuntimeMetadata::V14(m) => m.try_into(),
frame_metadata::RuntimeMetadata::V15(m) => m.try_into(),
frame_metadata::RuntimeMetadata::V16(m) => m.try_into(),
+1 -1
View File
@@ -5,9 +5,9 @@
use super::TryFromError;
use crate::{
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
ConstantMetadata, CustomMetadataInner, ExtrinsicMetadata, Metadata, OuterEnumsMetadata,
PalletMetadataInner, StorageEntryMetadata, StorageMetadata, TransactionExtensionMetadataInner,
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
};
use alloc::{borrow::ToOwned, collections::BTreeMap, format, string::String, vec, vec::Vec};
use frame_decode::storage::StorageTypeInfo;
+1 -1
View File
@@ -5,10 +5,10 @@
use super::TryFromError;
use crate::{
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
ConstantMetadata, ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner,
RuntimeApiMetadataInner, RuntimeApiMethodMetadataInner, StorageEntryMetadata, StorageMetadata,
TransactionExtensionMetadataInner,
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
};
use alloc::{collections::BTreeMap, vec, vec::Vec};
use frame_decode::{runtime_apis::RuntimeApiTypeInfo, storage::StorageTypeInfo};
+1 -1
View File
@@ -5,10 +5,10 @@
use super::TryFromError;
use crate::{
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
ConstantMetadata, ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner,
RuntimeApiMetadataInner, RuntimeApiMethodMetadataInner, StorageEntryMetadata, StorageMetadata,
TransactionExtensionMetadataInner, ViewFunctionMetadataInner,
utils::{ordered_map::OrderedMap, variant_index::VariantIndex},
};
use frame_decode::{
runtime_apis::RuntimeApiTypeInfo, storage::StorageTypeInfo,
+3 -3
View File
@@ -43,15 +43,15 @@ use frame_decode::{
};
use hashbrown::HashMap;
use scale_info::{PortableRegistry, Variant, form::PortableForm};
use scale_info::{form::PortableForm, PortableRegistry, Variant};
use utils::{
ordered_map::OrderedMap,
validation::{HASH_LEN, get_custom_value_hash},
validation::{get_custom_value_hash, HASH_LEN},
variant_index::VariantIndex,
};
pub use frame_decode::storage::StorageHasher;
pub use from::{SUPPORTED_METADATA_VERSIONS, TryFromError};
pub use from::{TryFromError, SUPPORTED_METADATA_VERSIONS};
pub use utils::validation::MetadataHasher;
#[cfg(feature = "legacy")]
+17 -5
View File
@@ -10,7 +10,7 @@ use crate::{
};
use alloc::vec::Vec;
use hashbrown::HashMap;
use scale_info::{Field, PortableRegistry, TypeDef, TypeDefVariant, Variant, form::PortableForm};
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
// The number of bytes our `hash` function produces.
pub(crate) const HASH_LEN: usize = 32;
@@ -115,7 +115,11 @@ fn get_type_def_variant_hash(
.as_ref()
.map(|only_these_variants| only_these_variants.contains(&var.name.as_str()))
.unwrap_or(true);
if should_hash { xor(bytes, get_variant_hash(registry, var, cache)) } else { bytes }
if should_hash {
xor(bytes, get_variant_hash(registry, var, cache))
} else {
bytes
}
});
concat_and_hash2(&variant_id_bytes, &variant_field_bytes)
}
@@ -521,7 +525,11 @@ impl<'a> MetadataHasher<'a> {
.unwrap_or(true);
// We don't care what order the pallets are seen in, so XOR their
// hashes together to be order independent.
if should_hash { xor(bytes, get_pallet_hash(pallet)) } else { bytes }
if should_hash {
xor(bytes, get_pallet_hash(pallet))
} else {
bytes
}
});
let apis_hash = metadata.runtime_api_traits().fold([0u8; HASH_LEN], |bytes, api| {
@@ -534,7 +542,11 @@ impl<'a> MetadataHasher<'a> {
.unwrap_or(true);
// We don't care what order the runtime APIs are seen in, so XOR their
// hashes together to be order independent.
if should_hash { xor(bytes, get_runtime_apis_hash(api)) } else { bytes }
if should_hash {
xor(bytes, get_runtime_apis_hash(api))
} else {
bytes
}
});
let outer_enums_hash = concat_and_hash3(
@@ -566,7 +578,7 @@ mod tests {
use super::*;
use bitvec::{order::Lsb0, vec::BitVec};
use frame_metadata::v15;
use scale_info::{Registry, meta_type};
use scale_info::{meta_type, Registry};
// Define recursive types.
#[allow(dead_code)]
+1 -1
View File
@@ -4,7 +4,7 @@
use alloc::{borrow::ToOwned, string::String};
use hashbrown::HashMap;
use scale_info::{PortableRegistry, TypeDef, Variant, form::PortableForm};
use scale_info::{form::PortableForm, PortableRegistry, TypeDef, Variant};
/// Given some type ID and type registry, build a couple of
/// indexes to look up variants by index or name. If the ID provided
+1 -1
View File
@@ -51,5 +51,5 @@ pub use round_robin_rpc_client::RoundRobinRpcClient;
mod rpc_client;
mod rpc_client_t;
pub use rpc_client::{RpcClient, RpcParams, RpcSubscription, rpc_params};
pub use rpc_client::{rpc_params, RpcClient, RpcParams, RpcSubscription};
pub use rpc_client_t::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClientT};
@@ -28,8 +28,8 @@
use super::{RawRpcFuture, RawRpcSubscription, RpcClientT};
use std::sync::{
Arc,
atomic::{AtomicUsize, Ordering},
Arc,
};
/// A simple RPC client which is provided a set of clients on initialization and
+1 -1
View File
@@ -5,7 +5,7 @@
use super::{RawRpcSubscription, RpcClientT};
use crate::Error;
use futures::{Stream, StreamExt};
use serde::{Serialize, de::DeserializeOwned};
use serde::{de::DeserializeOwned, Serialize};
use serde_json::value::RawValue;
use std::{pin::Pin, sync::Arc, task::Poll};
+5 -5
View File
@@ -7,8 +7,8 @@
//! methods exposed here.
use crate::{
client::{rpc_params, RpcClient, RpcSubscription},
Error, Hash, RpcConfig,
client::{RpcClient, RpcSubscription, rpc_params},
};
use derive_where::derive_where;
use futures::{Stream, StreamExt};
@@ -891,10 +891,10 @@ impl<H: Hash> Stream for TransactionSubscription<H> {
if let Poll::Ready(Some(Ok(res))) = &res {
if matches!(
res,
TransactionStatus::Dropped { .. } |
TransactionStatus::Error { .. } |
TransactionStatus::Invalid { .. } |
TransactionStatus::Finalized { .. }
TransactionStatus::Dropped { .. }
| TransactionStatus::Error { .. }
| TransactionStatus::Invalid { .. }
| TransactionStatus::Finalized { .. }
) {
// No more events will occur after these ones.
self.done = true
+1 -1
View File
@@ -5,8 +5,8 @@
//! An interface to call the raw legacy RPC methods.
use crate::{
client::{rpc_params, RpcClient, RpcSubscription},
Error, RpcConfig,
client::{RpcClient, RpcSubscription, rpc_params},
};
use codec::Decode;
use derive_where::derive_where;
+5 -1
View File
@@ -26,5 +26,9 @@ pub fn url_is_secure(url: &str) -> Result<bool, Error> {
/// 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::InsecureUrl(url.into())) } else { Ok(()) }
if !url_is_secure(url)? {
Err(Error::InsecureUrl(url.into()))
} else {
Ok(())
}
}
+10
View File
@@ -29,6 +29,16 @@ std = [
"serde?/std",
"serde_json?/std",
"sha2/std",
"bip32?/std",
"getrandom?/std",
"hex/std",
"keccak-hash?/std",
"codec/std",
"pezkuwi-subxt-core?/std",
"pezsp-core/std",
"pezsp-crypto-hashing/std",
"pezsp-keyring/std",
"zeroize/std"
]
# Pick the signer implementation(s) you need by enabling the
+5 -1
View File
@@ -94,6 +94,10 @@ impl<T: AsRef<str>> From<T> for DeriveJunction {
DeriveJunction::soft(code)
};
if hard { res.harden() } else { res }
if hard {
res.harden()
} else {
res
}
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ mod secret_uri;
mod seed_from_entropy;
pub use derive_junction::DeriveJunction;
pub use secret_uri::{DEV_PHRASE, SecretUri, SecretUriError};
pub use secret_uri::{SecretUri, SecretUriError, DEV_PHRASE};
#[cfg(any(feature = "sr25519", feature = "ecdsa"))]
pub use seed_from_entropy::seed_from_entropy;
+5 -4
View File
@@ -5,10 +5,10 @@
//! An ecdsa keypair implementation.
use codec::Encode;
use crate::crypto::{DeriveJunction, SecretUri, seed_from_entropy};
use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri};
use core::str::FromStr;
use hex::FromHex;
use secp256k1::{Message, Secp256k1, SecretKey, ecdsa::RecoverableSignature};
use secp256k1::{ecdsa::RecoverableSignature, Message, Secp256k1, SecretKey};
use secrecy::ExposeSecret;
use thiserror::Error as DeriveError;
@@ -135,9 +135,10 @@ impl Keypair {
for junction in junctions {
match junction {
DeriveJunction::Soft(_) => return Err(Error::SoftJunction),
DeriveJunction::Hard(junction_bytes) =>
DeriveJunction::Hard(junction_bytes) => {
acc = ("Secp256k1HDKD", acc, junction_bytes)
.using_encoded(pezsp_crypto_hashing::blake2_256),
.using_encoded(pezsp_crypto_hashing::blake2_256)
},
}
}
Self::from_secret_key(acc)
+2 -2
View File
@@ -106,7 +106,7 @@ impl Keypair {
/// Obtain the [`eth::PublicKey`] of this keypair.
pub fn public_key(&self) -> PublicKey {
let uncompressed = self.0.0.public_key().serialize_uncompressed();
let uncompressed = self.0 .0.public_key().serialize_uncompressed();
PublicKey(uncompressed)
}
@@ -576,7 +576,7 @@ mod test {
for (case_idx, (keypair, exp_account_id, exp_priv_key)) in cases.into_iter().enumerate() {
let act_account_id = keypair.public_key().to_account_id().checksum();
let act_priv_key = format!("0x{}", &keypair.0.0.display_secret());
let act_priv_key = format!("0x{}", &keypair.0 .0.display_secret());
assert_eq!(exp_account_id, act_account_id, "account ID mismatch in {case_idx}");
assert_eq!(exp_priv_key, act_priv_key, "private key mismatch in {case_idx}");
+1 -1
View File
@@ -52,4 +52,4 @@ pub use secrecy::{ExposeSecret, SecretString};
// SecretUri's can be parsed from strings and used to generate key pairs.
// DeriveJunctions are the "path" part of these SecretUris.
pub use crypto::{DEV_PHRASE, DeriveJunction, SecretUri, SecretUriError};
pub use crypto::{DeriveJunction, SecretUri, SecretUriError, DEV_PHRASE};
+10 -10
View File
@@ -6,8 +6,8 @@
use base64::Engine;
use crypto_secretbox::{
Key, Nonce, XSalsa20Poly1305,
aead::{Aead, KeyInit},
Key, Nonce, XSalsa20Poly1305,
};
use pezkuwi_subxt_core::utils::AccountId32;
use serde::Deserialize;
@@ -86,11 +86,11 @@ impl KeyringPairJson {
fn decrypt(self, password: &str) -> Result<sr25519::Keypair, Error> {
// Check encoding.
// https://github.com/pezkuwi-js/common/blob/37fa211fdb141d4f6eb32e8f377a4651ed2d9068/packages/keyring/src/keyring.ts#L166
if self.encoding.version != "3" ||
!self.encoding.content.contains(&"pkcs8".to_owned()) ||
!self.encoding.content.contains(&"sr25519".to_owned()) ||
!self.encoding.r#type.contains(&"scrypt".to_owned()) ||
!self.encoding.r#type.contains(&"xsalsa20-poly1305".to_owned())
if self.encoding.version != "3"
|| !self.encoding.content.contains(&"pkcs8".to_owned())
|| !self.encoding.content.contains(&"sr25519".to_owned())
|| !self.encoding.r#type.contains(&"scrypt".to_owned())
|| !self.encoding.r#type.contains(&"xsalsa20-poly1305".to_owned())
{
return Err(Error::UnsupportedEncoding);
}
@@ -139,8 +139,8 @@ impl KeyringPairJson {
let div = &plaintext[80..85];
let public_key = &plaintext[85..117];
if header != [48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32] ||
div != [161, 35, 3, 33, 0]
if header != [48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]
|| div != [161, 35, 3, 33, 0]
{
return Err(Error::InvalidKeys);
}
@@ -149,8 +149,8 @@ impl KeyringPairJson {
let keypair = sr25519::Keypair::from_ed25519_bytes(secret_key)?;
// Ensure keys are correct.
if keypair.public_key().0 != public_key ||
keypair.public_key().to_account_id() != self.address
if keypair.public_key().0 != public_key
|| keypair.public_key().to_account_id() != self.address
{
return Err(Error::InvalidKeys);
}
+3 -3
View File
@@ -10,12 +10,12 @@
use core::str::FromStr;
use crate::crypto::{DeriveJunction, SecretUri, seed_from_entropy};
use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri};
use hex::FromHex;
use schnorrkel::{
ExpansionMode, MiniSecretKey,
derive::{ChainCode, Derivation},
ExpansionMode, MiniSecretKey,
};
use secrecy::ExposeSecret;
@@ -283,9 +283,9 @@ mod subxt_compat {
use super::*;
use pezkuwi_subxt_core::{
Config,
tx::signer::Signer as SignerT,
utils::{AccountId32, MultiAddress, MultiSignature},
Config,
};
impl From<Signature> for MultiSignature {
@@ -6,8 +6,8 @@
#![allow(missing_docs, unused)]
use sp_core::{Pair as _, sr25519};
use pezkuwi_subxt::{Config, OnlineClient, PezkuwiConfig, config::bizinikiwi::MultiAddress};
use pezkuwi_subxt::{config::bizinikiwi::MultiAddress, Config, OnlineClient, PezkuwiConfig};
use sp_core::{sr25519, Pair as _};
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
pub mod pezkuwi {}
@@ -16,14 +16,14 @@ pub mod pezkuwi {}
/// and that PezkuwiConfig is the runtime configuration.
mod pair_signer {
use super::*;
use sp_runtime::{
MultiSignature as SpMultiSignature,
traits::{IdentifyAccount, Verify},
};
use pezkuwi_subxt::{
config::bizinikiwi::{AccountId32, MultiSignature},
tx::Signer,
};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
MultiSignature as SpMultiSignature,
};
/// A [`Signer`] implementation for [`sp_core::sr25519::Pair`].
#[derive(Clone)]
@@ -1,7 +1,7 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
utils::{AccountId32, MultiAddress},
OnlineClient, PezkuwiConfig,
};
use codec::Decode;
@@ -55,5 +55,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
fn display_address(addr: &MultiAddress<AccountId32, ()>) -> String {
if let MultiAddress::Id(id32) = addr { format!("{id32}") } else { "MultiAddress::...".into() }
if let MultiAddress::Id(id32) = addr {
format!("{id32}")
} else {
"MultiAddress::...".into()
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, dynamic::Value};
use pezkuwi_subxt::{dynamic::Value, OnlineClient, PezkuwiConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use futures::StreamExt;
use pezkuwi_subxt::{PezkuwiConfig, client::OnlineClient, lightclient::LightClient};
use pezkuwi_subxt::{client::OnlineClient, lightclient::LightClient, PezkuwiConfig};
// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
@@ -1,11 +1,11 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{
PezkuwiConfig,
client::OnlineClient,
lightclient::{ChainConfig, LightClient},
utils::fetch_chainspec_from_rpc_node,
PezkuwiConfig,
};
use pezkuwi_subxt_signer::sr25519::dev;
// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
+2 -2
View File
@@ -1,10 +1,10 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
backend::{legacy::LegacyRpcMethods, rpc::RpcClient},
config::DefaultExtrinsicParamsBuilder as Params,
OnlineClient, PezkuwiConfig,
};
use pezkuwi_subxt_signer::sr25519::dev;
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
pub mod pezkuwi {}
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{config::PezkuwiConfig, utils::AccountId32, OnlineClient};
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, config::PezkuwiConfig, utils::AccountId32};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -13,8 +13,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// but since we know the input + return types we can pass them directly.
// There is one input argument, so the inputs are a tuple of one element.
let account: AccountId32 = dev::alice().public_key().into();
let runtime_api_call =
pezkuwi_subxt::dynamic::runtime_api_call::<_, u64>("AccountNonceApi", "account_nonce", (account,));
let runtime_api_call = pezkuwi_subxt::dynamic::runtime_api_call::<_, u64>(
"AccountNonceApi",
"account_nonce",
(account,),
);
// Submit the call to get back a result.
let nonce = api.runtime_api().at_latest().await?.call(runtime_api_call).await?;
+1 -1
View File
@@ -1,10 +1,10 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
ext::{
codec::{Compact, Decode},
frame_metadata::RuntimeMetadataPrefixed,
},
OnlineClient, PezkuwiConfig,
};
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{config::PezkuwiConfig, OnlineClient};
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, config::PezkuwiConfig};
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
pub mod pezkuwi {}
@@ -1,13 +1,13 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{
backend::rpc::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClient, RpcClientT},
OnlineClient, PezkuwiConfig,
};
use std::{
fmt::Write,
pin::Pin,
sync::{Arc, Mutex},
};
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
backend::rpc::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClient, RpcClientT},
};
// A dummy RPC client that doesn't actually handle requests properly
// at all, but instead just logs what requests to it were made.
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{
OfflineClient, config::PezkuwiConfig, ext::codec::Decode, metadata::Metadata, utils::H256,
config::PezkuwiConfig, ext::codec::Decode, metadata::Metadata, utils::H256, OfflineClient,
};
#[tokio::main]
@@ -1,8 +1,8 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::config::{
Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, PezkuwiConfig, BizinikiwConfig,
BizinikiwConfig, Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, PezkuwiConfig,
};
use pezkuwi_subxt_signer::sr25519::dev;
#[pezkuwi_subxt::subxt(
runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
+3 -3
View File
@@ -1,13 +1,13 @@
#![allow(missing_docs)]
use codec::Encode;
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{
client::ClientState,
config::{
Config, ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError, HashFor,
transaction_extensions::Params,
transaction_extensions::Params, Config, ExtrinsicParams, ExtrinsicParamsEncoder,
ExtrinsicParamsError, HashFor,
},
};
use pezkuwi_subxt_signer::sr25519::dev;
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale")]
pub mod runtime {}
@@ -1,15 +1,15 @@
#![allow(missing_docs)]
use codec::Encode;
use pezkuwi_subxt_signer::sr25519::dev;
use scale_encode::EncodeAsType;
use scale_info::PortableRegistry;
use pezkuwi_subxt::{
client::ClientState,
config::{
Config, DefaultExtrinsicParamsBuilder, ExtrinsicParams, ExtrinsicParamsEncoder,
ExtrinsicParamsError, transaction_extensions,
transaction_extensions, Config, DefaultExtrinsicParamsBuilder, ExtrinsicParams,
ExtrinsicParamsEncoder, ExtrinsicParamsError,
},
};
use pezkuwi_subxt_signer::sr25519::dev;
use scale_encode::EncodeAsType;
use scale_info::PortableRegistry;
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
pub mod runtime {}
@@ -10,8 +10,8 @@ use std::time::Duration;
use futures::StreamExt;
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
backend::rpc::reconnecting_rpc_client::{ExponentialBackoff, RpcClient},
OnlineClient, PezkuwiConfig,
};
// Generate an interface that we can use from the node's metadata.
@@ -4,11 +4,11 @@
use futures::StreamExt;
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
backend::{
chain_head::{ChainHeadBackend, ChainHeadBackendBuilder},
rpc::RpcClient,
},
OnlineClient, PezkuwiConfig,
};
// Generate an interface that we can use from the node's metadata.
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
use pezkuwi_subxt_signer::sr25519::dev;
// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
@@ -1,10 +1,10 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
dynamic::{At, Value},
utils::AccountId32,
OnlineClient, PezkuwiConfig,
};
use pezkuwi_subxt_signer::sr25519::dev;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -16,7 +16,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// to access a value; an AccountId32. In this example we don't know the
// return type and so we set it to `Value`, which anything can decode into.
let account: AccountId32 = dev::alice().public_key().into();
let storage_query = pezkuwi_subxt::dynamic::storage::<(AccountId32,), Value>("System", "Account");
let storage_query =
pezkuwi_subxt::dynamic::storage::<(AccountId32,), Value>("System", "Account");
// Use that query to access a storage entry, fetch a result and decode the value.
let client_at = api.storage().at_latest().await?;
+1 -1
View File
@@ -1,5 +1,5 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, ext::futures::StreamExt};
use pezkuwi_subxt::{ext::futures::StreamExt, OnlineClient, PezkuwiConfig};
// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
@@ -1,9 +1,9 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig,
dynamic::{At, Value},
ext::futures::StreamExt,
utils::AccountId32,
OnlineClient, PezkuwiConfig,
};
#[tokio::main]
@@ -15,7 +15,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// here, we assume that there is one value to provide at this entry
// to access a value; an AccountId32. In this example we don't know the
// return type and so we set it to `Value`, which anything can decode into.
let storage_query = pezkuwi_subxt::dynamic::storage::<(AccountId32,), Value>("System", "Account");
let storage_query =
pezkuwi_subxt::dynamic::storage::<(AccountId32,), Value>("System", "Account");
// Use that query to access a storage entry, iterate over it and decode values.
let client_at = api.storage().at_latest().await?;
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
use pezkuwi_subxt_signer::sr25519::dev;
// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
+6 -4
View File
@@ -5,9 +5,9 @@
#![allow(missing_docs)]
use pezkuwi_subxt_core::utils::AccountId20;
use pezkuwi_subxt_signer::eth::{Signature, dev};
use pezkuwi_subxt::OnlineClient;
use pezkuwi_subxt_core::utils::AccountId20;
use pezkuwi_subxt_signer::eth::{dev, Signature};
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/frontier_metadata_small.scale")]
mod eth_runtime {}
@@ -19,8 +19,10 @@ impl pezkuwi_subxt::Config for EthRuntimeConfig {
type Address = AccountId20;
type Signature = Signature;
type Hasher = pezkuwi_subxt::config::bizinikiwi::BlakeTwo256;
type Header =
pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<u32, pezkuwi_subxt::config::bizinikiwi::BlakeTwo256>;
type Header = pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<
u32,
pezkuwi_subxt::config::bizinikiwi::BlakeTwo256,
>;
type ExtrinsicParams = pezkuwi_subxt::config::BizinikiwiExtrinsicParams<Self>;
type AssetId = u32;
}
+2 -2
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
use pezkuwi_subxt_signer::sr25519::dev;
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
pub mod pezkuwi {}
@@ -36,7 +36,7 @@ fn remark() -> Box<dyn pezkuwi_subxt::tx::Payload> {
}
fn dynamic_remark() -> Box<dyn pezkuwi_subxt::tx::Payload> {
use pezkuwi_subxt::dynamic::{Value, tx};
use pezkuwi_subxt::dynamic::{tx, Value};
let tx_payload = tx("System", "remark", vec![Value::from_bytes("Hello")]);
Box::new(tx_payload)
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
use pezkuwi_subxt_signer::sr25519::dev;
type BoxedError = Box<dyn std::error::Error + Send + Sync + 'static>;
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use pezkuwi_subxt::{tx::TxStatus, OnlineClient, PezkuwiConfig};
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, tx::TxStatus};
// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
+2 -2
View File
@@ -1,8 +1,8 @@
#![allow(missing_docs)]
use pezkuwi_subxt_signer::sr25519::dev;
use pezkuwi_subxt::{
OnlineClient, PezkuwiConfig, config::pezkuwi::PezkuwiExtrinsicParamsBuilder as Params,
config::pezkuwi::PezkuwiExtrinsicParamsBuilder as Params, OnlineClient, PezkuwiConfig,
};
use pezkuwi_subxt_signer::sr25519::dev;
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
pub mod pezkuwi {}
@@ -227,8 +227,8 @@ pub(super) mod test_utils {
BestBlockChanged, Finalized, Initialized, NewBlock,
};
use std::sync::{
Arc,
atomic::{AtomicUsize, Ordering},
Arc,
};
/// Given some events, returns a follow stream getter that we can use in
@@ -297,10 +297,12 @@ impl<H: Hash> Shared<H> {
.collect();
shared.block_events_for_new_subscriptions.retain(|ev| match ev {
FollowEvent::NewBlock(new_block_ev) =>
!to_remove.contains(&new_block_ev.block_hash.hash()),
FollowEvent::BestBlockChanged(best_block_ev) =>
!to_remove.contains(&best_block_ev.best_block_hash.hash()),
FollowEvent::NewBlock(new_block_ev) => {
!to_remove.contains(&new_block_ev.block_hash.hash())
},
FollowEvent::BestBlockChanged(best_block_ev) => {
!to_remove.contains(&best_block_ev.best_block_hash.hash())
},
_ => true,
});
},
@@ -2,7 +2,7 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::{ChainHeadRpcMethods, follow_stream::FollowStream};
use super::{follow_stream::FollowStream, ChainHeadRpcMethods};
use crate::{
config::{Config, Hash, HashFor},
error::BackendError,
@@ -229,20 +229,27 @@ impl<H: Hash> Stream for FollowStreamUnpin<H> {
FollowStreamMsg::Event(FollowEvent::Stop)
},
// These events aren't interesting; we just forward them on:
FollowStreamMsg::Event(FollowEvent::OperationBodyDone(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationBodyDone(details)),
FollowStreamMsg::Event(FollowEvent::OperationCallDone(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationCallDone(details)),
FollowStreamMsg::Event(FollowEvent::OperationStorageItems(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationStorageItems(details)),
FollowStreamMsg::Event(FollowEvent::OperationWaitingForContinue(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationWaitingForContinue(details)),
FollowStreamMsg::Event(FollowEvent::OperationStorageDone(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationStorageDone(details)),
FollowStreamMsg::Event(FollowEvent::OperationInaccessible(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationInaccessible(details)),
FollowStreamMsg::Event(FollowEvent::OperationError(details)) =>
FollowStreamMsg::Event(FollowEvent::OperationError(details)),
FollowStreamMsg::Event(FollowEvent::OperationBodyDone(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationBodyDone(details))
},
FollowStreamMsg::Event(FollowEvent::OperationCallDone(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationCallDone(details))
},
FollowStreamMsg::Event(FollowEvent::OperationStorageItems(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationStorageItems(details))
},
FollowStreamMsg::Event(FollowEvent::OperationWaitingForContinue(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationWaitingForContinue(details))
},
FollowStreamMsg::Event(FollowEvent::OperationStorageDone(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationStorageDone(details))
},
FollowStreamMsg::Event(FollowEvent::OperationInaccessible(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationInaccessible(details))
},
FollowStreamMsg::Event(FollowEvent::OperationError(details)) => {
FollowStreamMsg::Event(FollowEvent::OperationError(details))
},
};
// Return our event.
@@ -352,8 +359,8 @@ impl<H: Hash> FollowStreamUnpin<H> {
let mut blocks_to_unpin = vec![];
for (hash, details) in &self.pinned {
if rel_block_age.saturating_sub(details.rel_block_age) >= self.max_block_life ||
(unpin_flags.contains(hash) && details.can_be_unpinned)
if rel_block_age.saturating_sub(details.rel_block_age) >= self.max_block_life
|| (unpin_flags.contains(hash) && details.can_be_unpinned)
{
// The block is too old, or it's been flagged to be unpinned and won't be in a
// future backend event, so we can unpin it for real now.
@@ -460,7 +467,7 @@ impl<H: Hash> Drop for BlockRef<H> {
#[cfg(test)]
pub(super) mod test_utils {
use super::{
super::follow_stream::{FollowStream, test_utils::test_stream_getter},
super::follow_stream::{test_utils::test_stream_getter, FollowStream},
*,
};
use crate::config::bizinikiwi::H256;
+37 -26
View File
@@ -19,21 +19,21 @@ mod storage_items;
use self::follow_stream_driver::FollowStreamFinalizedHeads;
use crate::{
backend::{
Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf, StreamOfResults,
TransactionStatus, utils::retry,
utils::retry, Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf,
StreamOfResults, TransactionStatus,
},
config::{Config, Hash, HashFor},
error::{BackendError, RpcError},
};
use async_trait::async_trait;
use follow_stream_driver::{FollowStreamDriver, FollowStreamDriverHandle};
use futures::{Stream, StreamExt, future::Either};
use futures::{future::Either, Stream, StreamExt};
use pezkuwi_subxt_rpcs::{
RpcClient,
methods::chain_head::{
FollowEvent, MethodResponse, RuntimeEvent, StorageQuery, StorageQueryType,
StorageResultType,
},
RpcClient,
};
use std::{collections::HashMap, task::Poll};
use storage_items::StorageItems;
@@ -432,8 +432,9 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
.events()
.filter_map(|ev| {
let out = match ev {
FollowEvent::Initialized(init) =>
init.finalized_block_hashes.last().map(|b| b.clone().into()),
FollowEvent::Initialized(init) => {
init.finalized_block_hashes.last().map(|b| b.clone().into())
},
_ => None,
};
std::future::ready(out)
@@ -597,22 +598,28 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
match tx_status {
RpcTransactionStatus::Validated => TransactionStatus::Validated,
RpcTransactionStatus::Broadcasted => TransactionStatus::Broadcasted,
RpcTransactionStatus::BestChainBlockIncluded { block: None } =>
TransactionStatus::NoLongerInBestBlock,
RpcTransactionStatus::BestChainBlockIncluded { block: Some(block) } =>
RpcTransactionStatus::BestChainBlockIncluded { block: None } => {
TransactionStatus::NoLongerInBestBlock
},
RpcTransactionStatus::BestChainBlockIncluded { block: Some(block) } => {
TransactionStatus::InBestBlock {
hash: BlockRef::from_hash(block.hash),
},
RpcTransactionStatus::Finalized { block } =>
}
},
RpcTransactionStatus::Finalized { block } => {
TransactionStatus::InFinalizedBlock {
hash: BlockRef::from_hash(block.hash),
},
RpcTransactionStatus::Error { error } =>
TransactionStatus::Error { message: error },
RpcTransactionStatus::Invalid { error } =>
TransactionStatus::Invalid { message: error },
RpcTransactionStatus::Dropped { error } =>
TransactionStatus::Dropped { message: error },
}
},
RpcTransactionStatus::Error { error } => {
TransactionStatus::Error { message: error }
},
RpcTransactionStatus::Invalid { error } => {
TransactionStatus::Invalid { message: error }
},
RpcTransactionStatus::Dropped { error } => {
TransactionStatus::Dropped { message: error }
},
}
})
.map_err(Into::into)
@@ -782,15 +789,19 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
};
TransactionStatus::InBestBlock { hash: block_ref }
},
RpcTransactionStatus::BestChainBlockIncluded { block: None } =>
TransactionStatus::NoLongerInBestBlock,
RpcTransactionStatus::BestChainBlockIncluded { block: None } => {
TransactionStatus::NoLongerInBestBlock
},
RpcTransactionStatus::Broadcasted => TransactionStatus::Broadcasted,
RpcTransactionStatus::Dropped { error, .. } =>
TransactionStatus::Dropped { message: error },
RpcTransactionStatus::Error { error } =>
TransactionStatus::Error { message: error },
RpcTransactionStatus::Invalid { error } =>
TransactionStatus::Invalid { message: error },
RpcTransactionStatus::Dropped { error, .. } => {
TransactionStatus::Dropped { message: error }
},
RpcTransactionStatus::Error { error } => {
TransactionStatus::Error { message: error }
},
RpcTransactionStatus::Invalid { error } => {
TransactionStatus::Invalid { message: error }
},
RpcTransactionStatus::Validated => TransactionStatus::Validated,
};
return Poll::Ready(Some(Ok(tx_progress_ev)));
+10 -10
View File
@@ -8,15 +8,15 @@
use self::rpc_methods::TransactionStatus as RpcTransactionStatus;
use crate::{
backend::{
utils::{retry, retry_stream},
Backend, BlockRef, RuntimeVersion, StorageResponse, StreamOf, StreamOfResults,
TransactionStatus,
utils::{retry, retry_stream},
},
config::{Config, HashFor, Header},
error::BackendError,
};
use async_trait::async_trait;
use futures::{Future, FutureExt, Stream, StreamExt, TryStreamExt, future, future::Either, stream};
use futures::{future, future::Either, stream, Future, FutureExt, Stream, StreamExt, TryStreamExt};
use pezkuwi_subxt_rpcs::RpcClient;
use std::{
collections::VecDeque,
@@ -360,10 +360,10 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for LegacyBackend<T> {
let sub = self.methods.author_submit_and_watch_extrinsic(extrinsic).await?;
let sub = sub.filter_map(|r| {
let mapped = r
.map_err(|e| e.into())
.map(|tx| {
match tx {
let mapped =
r.map_err(|e| e.into())
.map(|tx| {
match tx {
// We ignore these because they don't map nicely to the new API. They don't
// signal "end states" so this should be fine.
RpcTransactionStatus::Future => None,
@@ -394,8 +394,8 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for LegacyBackend<T> {
.into(),
}),
}
})
.transpose();
})
.transpose();
future::ready(mapped)
});
@@ -504,8 +504,8 @@ impl<T: Config> Stream for StorageFetchDescendantKeysStream<T> {
match keys {
Ok(mut keys) => {
if this.pagination_start_key.is_some() &&
keys.first() == this.pagination_start_key.as_ref()
if this.pagination_start_key.is_some()
&& keys.first() == this.pagination_start_key.as_ref()
{
// Currently, Smoldot returns the "start key" as the first key in the
// input (see https://github.com/smol-dot/smoldot/issues/1692), whereas Bizinikiwi doesn't.
+11 -14
View File
@@ -25,9 +25,8 @@ use std::{pin::Pin, sync::Arc};
/// [`crate::ext::pezkuwi_subxt_rpcs`].
pub mod rpc {
pub use pezkuwi_subxt_rpcs::{
RpcClient, RpcClientT,
client::{RawRpcFuture, RawRpcSubscription, RawValue, RpcParams},
rpc_params,
rpc_params, RpcClient, RpcClientT,
};
crate::macros::cfg_reconnecting_rpc_client! {
@@ -123,7 +122,7 @@ pub trait Backend<T: Config>: sealed::Sealed + Send + Sync + 'static {
/// A stream of all new runtime versions as they occur.
async fn stream_runtime_version(&self)
-> Result<StreamOfResults<RuntimeVersion>, BackendError>;
-> Result<StreamOfResults<RuntimeVersion>, BackendError>;
/// A stream of all new block headers as they arrive.
async fn stream_all_block_headers(
@@ -390,10 +389,10 @@ mod test {
use crate::backend::StorageResponse;
use core::convert::Infallible;
use futures::StreamExt;
use pezkuwi_subxt_core::{Config, config::DefaultExtrinsicParams};
use pezkuwi_subxt_core::{config::DefaultExtrinsicParams, Config};
use pezkuwi_subxt_rpcs::client::{
MockRpcClient,
mock_rpc_client::{Json, MockRpcClientBuilder},
MockRpcClient,
};
use primitive_types::H256;
use rpc::RpcClientT;
@@ -429,7 +428,7 @@ mod test {
mod legacy {
use super::*;
use crate::{
backend::legacy::{LegacyBackend, rpc_methods::RuntimeVersion},
backend::legacy::{rpc_methods::RuntimeVersion, LegacyBackend},
error::RpcError,
};
@@ -688,7 +687,7 @@ mod test {
I: IntoIterator<Item = usize> + Send,
I::IntoIter: Send + Sync + 'static,
{
use pezkuwi_subxt_rpcs::{Error, UserError, client::mock_rpc_client::AndThen};
use pezkuwi_subxt_rpcs::{client::mock_rpc_client::AndThen, Error, UserError};
let recv = Arc::new(tokio::sync::Mutex::new(recv));
let mut ids = ids.into_iter();
@@ -824,13 +823,11 @@ mod test {
.await
.unwrap();
assert!(
response
.next()
.await
.unwrap()
.is_err_and(|e| matches!(e, BackendError::Other(e) if e == "error"))
);
assert!(response
.next()
.await
.unwrap()
.is_err_and(|e| matches!(e, BackendError::Other(e) if e == "error")));
assert!(response.next().await.is_none());
}
+1 -1
View File
@@ -2,7 +2,7 @@
use super::{StreamOf, StreamOfResults};
use crate::error::BackendError;
use futures::{FutureExt, Stream, StreamExt, future::BoxFuture};
use futures::{future::BoxFuture, FutureExt, Stream, StreamExt};
use std::{future::Future, pin::Pin, task::Poll};
/// Resubscribe callback.
+1 -1
View File
@@ -3,7 +3,7 @@
// see LICENSE for license details.
use crate::{
blocks::block_types::{CachedEvents, get_events},
blocks::block_types::{get_events, CachedEvents},
client::{OfflineClientT, OnlineClientT},
config::{Config, HashFor},
error::{EventsError, ExtrinsicDecodeErrorAt, ExtrinsicError},
+1 -1
View File
@@ -67,7 +67,7 @@
//! ```rust,ignore
#![doc = include_str!("../../examples/tx_basic.rs")]
//! ```
//!
//!
//! This example assumes that a Pezkuwi node is running locally (Subxt endeavors to support all
//! recent releases). Typically, to use Subxt to talk to some custom Bizinikiwi node (for example a
//! parachain node), you'll want to:
+1 -1
View File
@@ -45,7 +45,7 @@
//! ```rust,ignore
#![doc = include_str!("../../../examples/setup_client_custom_rpc.rs")]
//! ```
//!
//!
//! ### Creating an [`crate::OfflineClient`]:
//! ```rust,ignore
#![doc = include_str!("../../../examples/setup_client_offline.rs")]
+2 -2
View File
@@ -161,7 +161,7 @@
//! ```rust,ignore
#![doc = include_str ! ("../../../examples/setup_config_transaction_extension.rs")]
//! ```
//!
//!
//! ### Implementing [`crate::config::ExtrinsicParams`] from scratch
//!
//! Alternately, you are free to implement [`crate::config::ExtrinsicParams`] entirely from scratch if you know exactly what "extra" and
@@ -171,7 +171,7 @@
//! ```rust,ignore
#![doc = include_str ! ("../../../examples/setup_config_custom.rs")]
//! ```
//!
//!
//! ### Using a type from the metadata as a config parameter
//!
//! You can also use types that are generated from chain metadata as type parameters of the Config trait.
+3 -3
View File
@@ -58,7 +58,7 @@
//! ```rust,ignore
#![doc = include_str!("../../../examples/blocks_subscribing.rs")]
//! ```
//!
//!
//! ### Statically decode the extrinsic into [a specific pallet call](crate::blocks::ExtrinsicDetails::as_extrinsic())
//!
//! This is useful if you are expecting a specific extrinsic to be part of some block. If the extrinsic you try to decode
@@ -73,7 +73,7 @@
//! ```rust,ignore
#![doc = include_str!("../../../examples/block_decoding_static.rs")]
//! ```
//!
//!
//! ### Dynamically decode the extrinsic
//!
//! Sometimes you might use subxt with metadata that is not known at compile time. In this case, you do not
@@ -87,7 +87,7 @@
//! ```rust,ignore
#![doc = include_str!("../../../examples/block_decoding_dynamic.rs")]
//! ```
//!
//!
//! ## Decoding transaction extensions
//!
//! Extrinsics can contain transaction extensions. The transaction extensions can be different across chains.

Some files were not shown because too many files have changed in this diff Show More