mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
broken fractured commits, only a few errors remaining
This commit is contained in:
Generated
+1
@@ -4395,6 +4395,7 @@ dependencies = [
|
||||
"getrandom 0.2.12",
|
||||
"hex",
|
||||
"impl-serde",
|
||||
"instant",
|
||||
"jsonrpsee",
|
||||
"parity-scale-codec",
|
||||
"primitive-types",
|
||||
|
||||
@@ -68,6 +68,7 @@ frame-metadata = { workspace = true }
|
||||
derivative = { workspace = true, features = ["use_core"] }
|
||||
derive_more = { workspace = true }
|
||||
either = { workspace = true }
|
||||
instant = { workspace = true }
|
||||
|
||||
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
|
||||
impl-serde = { workspace = true }
|
||||
|
||||
@@ -13,7 +13,6 @@ use crate::backend::{
|
||||
TransactionStatus,
|
||||
};
|
||||
use crate::{config::Header, Config, Error};
|
||||
use crate::prelude::*;
|
||||
use async_trait::async_trait;
|
||||
use futures::{future, future::Either, stream, Future, FutureExt, Stream, StreamExt};
|
||||
use std::collections::VecDeque;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
use crate::backend::rpc::{rpc_params, RpcClient, RpcSubscription};
|
||||
use crate::metadata::Metadata;
|
||||
use crate::prelude::*;
|
||||
use crate::{Config, Error};
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
@@ -20,7 +19,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[derivative(Clone(bound = ""), Debug(bound = ""))]
|
||||
pub struct LegacyRpcMethods<T> {
|
||||
client: RpcClient,
|
||||
_marker: PhantomData<T>,
|
||||
_marker: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Config> LegacyRpcMethods<T> {
|
||||
@@ -28,7 +27,7 @@ impl<T: Config> LegacyRpcMethods<T> {
|
||||
pub fn new(client: RpcClient) -> Self {
|
||||
LegacyRpcMethods {
|
||||
client,
|
||||
_marker: PhantomData,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ pub mod unstable;
|
||||
use crate::error::Error;
|
||||
use crate::metadata::Metadata;
|
||||
use crate::Config;
|
||||
use crate::prelude::*;
|
||||
use async_trait::async_trait;
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{Stream, StreamExt};
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
use super::{RawRpcFuture, RawRpcSubscription, RpcClientT};
|
||||
use crate::error::RpcError;
|
||||
use crate::prelude::*;
|
||||
use futures::stream::{StreamExt, TryStreamExt};
|
||||
use jsonrpsee::{
|
||||
core::{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
use super::{RawRpcSubscription, RpcClientT};
|
||||
use crate::error::Error;
|
||||
use crate::prelude::*;
|
||||
use futures::{Stream, StreamExt};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde_json::value::RawValue;
|
||||
@@ -181,7 +180,7 @@ impl RpcParams {
|
||||
/// [`StreamExt`] extension trait.
|
||||
pub struct RpcSubscription<Res> {
|
||||
inner: RawRpcSubscription,
|
||||
_marker: PhantomData<Res>,
|
||||
_marker: std::marker::PhantomData<Res>,
|
||||
}
|
||||
|
||||
impl<Res> std::fmt::Debug for RpcSubscription<Res> {
|
||||
@@ -198,7 +197,7 @@ impl<Res> RpcSubscription<Res> {
|
||||
pub fn new(inner: RawRpcSubscription) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
_marker: PhantomData,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::RpcError;
|
||||
use crate::prelude::*;
|
||||
use futures::Stream;
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
use super::rpc_methods::{FollowEvent, UnstableRpcMethods};
|
||||
use crate::config::Config;
|
||||
use crate::error::Error;
|
||||
use crate::prelude::*;
|
||||
use futures::{FutureExt, Stream, StreamExt};
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
@@ -6,7 +6,6 @@ use super::follow_stream_unpin::{BlockRef, FollowStreamMsg, FollowStreamUnpin};
|
||||
use crate::backend::unstable::rpc_methods::{FollowEvent, Initialized, RuntimeEvent};
|
||||
use crate::config::BlockHash;
|
||||
use crate::error::Error;
|
||||
use crate::prelude::*;
|
||||
use futures::stream::{Stream, StreamExt};
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::ops::DerefMut;
|
||||
@@ -46,19 +45,20 @@ impl<Hash: BlockHash> Stream for FollowStreamDriver<Hash> {
|
||||
type Item = Result<(), Error>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let item = match self.inner.poll_next_unpin(cx) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
match self.inner.poll_next_unpin(cx) {
|
||||
Poll::Pending => Poll::Pending,
|
||||
Poll::Ready(None) => {
|
||||
// Mark ourselves as done so that everything can end.
|
||||
self.shared.done();
|
||||
return Poll::Ready(None);
|
||||
Poll::Ready(None)
|
||||
}
|
||||
Poll::Ready(Some(Err(e))) => return Poll::Ready(Some(Err(e))),
|
||||
Poll::Ready(Some(Ok(item))) => item,
|
||||
};
|
||||
|
||||
self.shared.push_item(item);
|
||||
Poll::Ready(Some(Ok(())))
|
||||
Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))),
|
||||
Poll::Ready(Some(Ok(item))) => {
|
||||
// Push item to any subscribers.
|
||||
self.shared.push_item(item);
|
||||
Poll::Ready(Some(Ok(())))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use crate::backend::unstable::rpc_methods::{
|
||||
};
|
||||
use crate::config::{BlockHash, Config};
|
||||
use crate::error::Error;
|
||||
use crate::prelude::*;
|
||||
use futures::stream::{FuturesUnordered, Stream, StreamExt};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::future::Future;
|
||||
@@ -75,10 +74,11 @@ impl<Hash: BlockHash> Stream for FollowStreamUnpin<Hash> {
|
||||
let mut this = self.as_mut();
|
||||
|
||||
loop {
|
||||
// Poll the unpin tasks while they are completing. if we get back None, then
|
||||
// no tasks in the list, and if pending, we'll be woken when we can poll again.
|
||||
if let Poll::Ready(Some(())) = this.unpin_futs.poll_next_unpin(cx) {
|
||||
continue;
|
||||
// Poll any queued unpin tasks.
|
||||
let unpin_futs_are_pending = match this.unpin_futs.poll_next_unpin(cx) {
|
||||
Poll::Ready(Some(())) => continue,
|
||||
Poll::Ready(None) => false,
|
||||
Poll::Pending => true,
|
||||
};
|
||||
|
||||
// Poll the inner stream for the next event.
|
||||
@@ -86,9 +86,14 @@ impl<Hash: BlockHash> Stream for FollowStreamUnpin<Hash> {
|
||||
return Poll::Pending;
|
||||
};
|
||||
|
||||
// No more progress to be made if inner stream done.
|
||||
let Some(ev) = ev else {
|
||||
return Poll::Ready(None);
|
||||
// if the stream is done, but `unpin_futs` are still pending, then
|
||||
// return pending here so that they are still driven to completion.
|
||||
// Else, return `Ready(None)` to signal nothing left to do.
|
||||
return match unpin_futs_are_pending {
|
||||
true => Poll::Pending,
|
||||
false => Poll::Ready(None),
|
||||
};
|
||||
};
|
||||
|
||||
// Error? just return it and do nothing further.
|
||||
|
||||
@@ -27,7 +27,6 @@ use crate::backend::{
|
||||
};
|
||||
use crate::config::BlockHash;
|
||||
use crate::error::{Error, RpcError};
|
||||
use crate::prelude::*;
|
||||
use crate::Config;
|
||||
use async_trait::async_trait;
|
||||
use follow_stream_driver::{FollowStreamDriver, FollowStreamDriverHandle};
|
||||
@@ -43,7 +42,7 @@ pub use rpc_methods::UnstableRpcMethods;
|
||||
/// Configure and build an [`UnstableBackend`].
|
||||
pub struct UnstableBackendBuilder<T> {
|
||||
max_block_life: usize,
|
||||
_marker: PhantomData<T>,
|
||||
_marker: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Config> Default for UnstableBackendBuilder<T> {
|
||||
@@ -57,7 +56,7 @@ impl<T: Config> UnstableBackendBuilder<T> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
max_block_life: usize::MAX,
|
||||
_marker: PhantomData,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,24 +480,43 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
|
||||
// with chainHead_follow.
|
||||
let mut finalized_hash: Option<T::Hash> = None;
|
||||
|
||||
// Record the start time so that we can time out if things appear to take too long.
|
||||
let start_instant = instant::Instant::now();
|
||||
|
||||
// A quick helper to return a generic error.
|
||||
let err_other = |s: &str| Some(Err(Error::Other(s.into())));
|
||||
|
||||
// Now we can attempt to associate tx events with pinned blocks.
|
||||
let tx_stream = futures::stream::poll_fn(move |cx| {
|
||||
loop {
|
||||
// Bail early if no more tx events; we don't want to keep polling for pinned blocks.
|
||||
// Bail early if we're finished; nothing else to do.
|
||||
if done {
|
||||
return Poll::Ready(None);
|
||||
}
|
||||
|
||||
// Make a note of new or finalized blocks that have come in since we started the TX.
|
||||
if let Poll::Ready(Some(seen_block)) = seen_blocks_sub.poll_next_unpin(cx) {
|
||||
match seen_block {
|
||||
FollowEvent::Initialized(ev) => {
|
||||
// Just in case this stream is really slow to start or something..
|
||||
seen_blocks.insert(
|
||||
ev.finalized_block_hash.hash(),
|
||||
(SeenBlockMarker::Finalized, ev.finalized_block_hash),
|
||||
);
|
||||
}
|
||||
// Bail if we exceed 4 mins; something very likely went wrong.
|
||||
if start_instant.elapsed().as_secs() > 240 {
|
||||
return Poll::Ready(err_other(
|
||||
"Timeout waiting for the transaction to be finalized",
|
||||
));
|
||||
}
|
||||
|
||||
// Poll for a follow event, and error if the stream has unexpectedly ended.
|
||||
let follow_ev_poll = match seen_blocks_sub.poll_next_unpin(cx) {
|
||||
Poll::Ready(None) => {
|
||||
return Poll::Ready(err_other("chainHead_follow stream ended unexpectedly"))
|
||||
}
|
||||
Poll::Ready(Some(follow_ev)) => Poll::Ready(follow_ev),
|
||||
Poll::Pending => Poll::Pending,
|
||||
};
|
||||
let follow_ev_is_pending = follow_ev_poll.is_pending();
|
||||
|
||||
// If there was a follow event, then handle it and loop around to see if there are more.
|
||||
// We want to buffer follow events until we hit Pending, so that we are as up-to-date as possible
|
||||
// for when we see a BestBlockChanged event, so that we have the best change of already having
|
||||
// seen the block that it mentions and returning a proper pinned block.
|
||||
if let Poll::Ready(follow_ev) = follow_ev_poll {
|
||||
match follow_ev {
|
||||
FollowEvent::NewBlock(ev) => {
|
||||
// Optimization: once we have a `finalized_hash`, we only care about finalized
|
||||
// block refs now and can avoid bothering to save new blocks.
|
||||
@@ -522,7 +540,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
|
||||
// in which we may lose the finaliuzed block that the TX is in. For now, just error if
|
||||
// this happens, to prevent the case in which we never see a finalized block and wait
|
||||
// forever.
|
||||
return Poll::Ready(Some(Err(Error::Other("chainHead_follow emitted 'stop' event during transaction submission".into()))));
|
||||
return Poll::Ready(err_other("chainHead_follow emitted 'stop' event during transaction submission"));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -541,25 +559,27 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
|
||||
};
|
||||
return Poll::Ready(Some(Ok(ev)));
|
||||
} else {
|
||||
// Keep waiting for more finalized blocks until we find it (get rid of any other block refs
|
||||
// now, since none of them were what we were looking for anyway).
|
||||
// Not found it! If follow ev is pending, then return pending here and wait for
|
||||
// a new one to come in, else loop around and see if we get another one immediately.
|
||||
seen_blocks.clear();
|
||||
continue;
|
||||
if follow_ev_is_pending {
|
||||
return Poll::Pending;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, we are still watching for tx events:
|
||||
let ev = match tx_progress.poll_next_unpin(cx) {
|
||||
// If we don't have a finalized block yet, we keep polling for tx progress events.
|
||||
let tx_progress_ev = match tx_progress.poll_next_unpin(cx) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
Poll::Ready(None) => {
|
||||
done = true;
|
||||
return Poll::Ready(None);
|
||||
}
|
||||
Poll::Ready(None) => return Poll::Ready(err_other("No more transaction progress events, but we haven't seen a Finalized one yet")),
|
||||
Poll::Ready(Some(Err(e))) => return Poll::Ready(Some(Err(e))),
|
||||
Poll::Ready(Some(Ok(ev))) => ev,
|
||||
};
|
||||
|
||||
// When we get one, map it to the correct format (or for finalized ev, wait for the pinned block):
|
||||
let ev = match ev {
|
||||
let tx_progress_ev = match tx_progress_ev {
|
||||
rpc_methods::TransactionStatus::Finalized { block } => {
|
||||
// We'll wait until we have seen this hash, to try to guarantee
|
||||
// that when we return this event, the corresponding block is
|
||||
@@ -597,7 +617,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
|
||||
}
|
||||
rpc_methods::TransactionStatus::Validated => TransactionStatus::Validated,
|
||||
};
|
||||
return Poll::Ready(Some(Ok(ev)));
|
||||
return Poll::Ready(Some(Ok(tx_progress_ev)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
use crate::backend::rpc::{rpc_params, RpcClient, RpcSubscription};
|
||||
use crate::config::BlockHash;
|
||||
use crate::prelude::*;
|
||||
use crate::{Config, Error};
|
||||
use derivative::Derivative;
|
||||
use futures::{Stream, StreamExt};
|
||||
@@ -23,7 +22,7 @@ use std::task::Poll;
|
||||
#[derivative(Clone(bound = ""), Debug(bound = ""))]
|
||||
pub struct UnstableRpcMethods<T> {
|
||||
client: RpcClient,
|
||||
_marker: PhantomData<T>,
|
||||
_marker: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Config> UnstableRpcMethods<T> {
|
||||
@@ -31,7 +30,7 @@ impl<T: Config> UnstableRpcMethods<T> {
|
||||
pub fn new(client: RpcClient) -> Self {
|
||||
UnstableRpcMethods {
|
||||
client,
|
||||
_marker: PhantomData,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,7 +746,6 @@ fn to_hex(bytes: impl AsRef<[u8]>) -> String {
|
||||
/// Attempt to deserialize either a string or integer into an integer.
|
||||
/// See <https://github.com/paritytech/json-rpc-interface-spec/issues/83>
|
||||
pub(crate) mod unsigned_number_as_string {
|
||||
use crate::prelude::*;
|
||||
use serde::de::{Deserializer, Visitor};
|
||||
use std::fmt;
|
||||
|
||||
@@ -756,10 +754,10 @@ pub(crate) mod unsigned_number_as_string {
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
deserializer.deserialize_any(NumberVisitor(PhantomData))
|
||||
deserializer.deserialize_any(NumberVisitor(std::marker::PhantomData))
|
||||
}
|
||||
|
||||
struct NumberVisitor<N>(PhantomData<N>);
|
||||
struct NumberVisitor<N>(std::marker::PhantomData<N>);
|
||||
|
||||
impl<'de, N: From<u64>> Visitor<'de> for NumberVisitor<N> {
|
||||
type Value = N;
|
||||
@@ -795,11 +793,11 @@ pub(crate) mod unsigned_number_as_string {
|
||||
///
|
||||
/// Adapted from <https://tikv.github.io/doc/serde_with/rust/hashmap_as_tuple_list>
|
||||
pub(crate) mod hashmap_as_tuple_list {
|
||||
use crate::prelude::*;
|
||||
use serde::de::{Deserialize, Deserializer, SeqAccess, Visitor};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::hash::{BuildHasher, Hash};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// Deserialize a [`HashMap`] from a list of tuples or object
|
||||
pub fn deserialize<'de, K, V, BH, D>(deserializer: D) -> Result<HashMap<K, V, BH>, D::Error>
|
||||
|
||||
@@ -9,7 +9,6 @@ use super::rpc_methods::{
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::error::{Error, RpcError};
|
||||
use crate::prelude::*;
|
||||
use futures::{FutureExt, Stream, StreamExt};
|
||||
use std::collections::VecDeque;
|
||||
use std::future::Future;
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
|
||||
use super::Block;
|
||||
use crate::{
|
||||
backend::{BlockRef, StreamOfResults},
|
||||
client::OnlineClientT,
|
||||
config::Config,
|
||||
error::{BlockError, Error},
|
||||
utils::PhantomDataSendSync,
|
||||
prelude::*,
|
||||
utils::PhantomDataSendSync,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use futures::StreamExt;
|
||||
@@ -18,6 +16,12 @@ use std::future::Future;
|
||||
type BlockStream<T> = StreamOfResults<T>;
|
||||
type BlockStreamRes<T> = Result<BlockStream<T>, Error>;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{
|
||||
backend::{BlockRef, StreamOfResults},
|
||||
client::OnlineClientT,
|
||||
};
|
||||
|
||||
/// A client for working with blocks.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Clone(bound = "Client: Clone"))]
|
||||
@@ -36,6 +40,7 @@ impl<T, Client> BlocksClient<T, Client> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, Client> BlocksClient<T, Client>
|
||||
where
|
||||
T: Config,
|
||||
|
||||
@@ -11,18 +11,21 @@ use crate::prelude::*;
|
||||
use crate::utils::strip_compact_prefix;
|
||||
use crate::{
|
||||
blocks::block_types::{get_events, CachedEvents},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
client::{OfflineClientT},
|
||||
config::{Config, Hasher},
|
||||
error::{BlockError, Error, MetadataError},
|
||||
events,
|
||||
metadata::types::PalletMetadata,
|
||||
Metadata,
|
||||
};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::client::OnlineClientT;
|
||||
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
use scale_decode::{DecodeAsFields, DecodeAsType};
|
||||
|
||||
use std::sync::Arc;
|
||||
use crate::prelude::sync::Arc;
|
||||
|
||||
/// Trait to uniquely identify the extrinsic's identity from the runtime metadata.
|
||||
///
|
||||
@@ -102,7 +105,7 @@ where
|
||||
let ids = self.ids;
|
||||
let mut index = 0;
|
||||
|
||||
std::iter::from_fn(move || {
|
||||
core::iter::from_fn(move || {
|
||||
if index == num_extrinsics {
|
||||
None
|
||||
} else {
|
||||
@@ -466,6 +469,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, C> ExtrinsicDetails<T, C>
|
||||
where
|
||||
T: Config,
|
||||
@@ -627,7 +631,7 @@ impl<'a, T: Config> ExtrinsicSignedExtensions<'a, T> {
|
||||
let mut byte_start_idx = 0;
|
||||
let metadata = &self.metadata;
|
||||
|
||||
std::iter::from_fn(move || {
|
||||
core::iter::from_fn(move || {
|
||||
if index == num_signed_extensions {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
|
||||
//! This module exposes the necessary functionality for working with events.
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod block_types;
|
||||
mod blocks_client;
|
||||
mod extrinsic_types;
|
||||
|
||||
/// A reference to a block.
|
||||
#[cfg(feature = "std")]
|
||||
pub use crate::backend::BlockRef;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use block_types::Block;
|
||||
#[cfg(feature = "std")]
|
||||
pub use blocks_client::BlocksClient;
|
||||
pub use extrinsic_types::{
|
||||
ExtrinsicDetails, ExtrinsicEvents, ExtrinsicSignedExtension, ExtrinsicSignedExtensions,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
//! access.
|
||||
|
||||
mod offline_client;
|
||||
#[cfg(feature = "std")]
|
||||
mod online_client;
|
||||
|
||||
crate::macros::cfg_unstable_light_client! {
|
||||
@@ -20,6 +21,8 @@ crate::macros::cfg_unstable_light_client! {
|
||||
}
|
||||
|
||||
pub use offline_client::{OfflineClient, OfflineClientT};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use online_client::{
|
||||
ClientRuntimeUpdater, OnlineClient, OnlineClientT, RuntimeUpdaterStream, Update, UpgradeError,
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
use crate::prelude::*;
|
||||
use derivative::Derivative;
|
||||
|
||||
use std::sync::Arc;
|
||||
use sync::Arc;
|
||||
|
||||
/// A trait representing a client that can perform
|
||||
/// offline-only actions.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
use super::{OfflineClient, OfflineClientT};
|
||||
use crate::custom_values::CustomValuesClient;
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
backend::{
|
||||
legacy::LegacyBackend, rpc::RpcClient, Backend, BackendExt, RuntimeVersion, StreamOfResults,
|
||||
|
||||
@@ -33,6 +33,7 @@ pub enum ExtrinsicParamsError {
|
||||
UnknownSignedExtension(String),
|
||||
/// Some custom error.
|
||||
#[display(fmt = "Error constructing extrinsic parameters: {_0}")]
|
||||
#[cfg(feature = "std")]
|
||||
Custom(CustomExtrinsicParamsError),
|
||||
}
|
||||
|
||||
@@ -40,13 +41,17 @@ pub enum ExtrinsicParamsError {
|
||||
impl std::error::Error for ExtrinsicParamsError {}
|
||||
|
||||
/// A custom error.
|
||||
#[cfg(feature = "std")]
|
||||
pub type CustomExtrinsicParamsError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
||||
|
||||
impl From<std::convert::Infallible> for ExtrinsicParamsError {
|
||||
fn from(value: std::convert::Infallible) -> Self {
|
||||
|
||||
impl From<core::convert::Infallible> for ExtrinsicParamsError {
|
||||
fn from(value: core::convert::Infallible) -> Self {
|
||||
match value {}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl From<CustomExtrinsicParamsError> for ExtrinsicParamsError {
|
||||
fn from(value: CustomExtrinsicParamsError) -> Self {
|
||||
ExtrinsicParamsError::Custom(value)
|
||||
|
||||
@@ -76,7 +76,7 @@ pub trait BlockHash:
|
||||
+ Encode
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ std::hash::Hash
|
||||
+ core::hash::Hash
|
||||
{
|
||||
}
|
||||
impl<T> BlockHash for T where
|
||||
@@ -91,7 +91,7 @@ impl<T> BlockHash for T where
|
||||
+ Encode
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ std::hash::Hash
|
||||
+ core::hash::Hash
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,12 @@ use crate::prelude::*;
|
||||
use crate::utils::Era;
|
||||
use crate::{client::OfflineClientT, Config};
|
||||
use codec::{Compact, Encode};
|
||||
use collections::BTreeMap;
|
||||
use core::fmt::Debug;
|
||||
use derivative::Derivative;
|
||||
use scale_decode::DecodeAsType;
|
||||
use scale_info::PortableRegistry;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// A single [`SignedExtension`] has a unique name, but is otherwise the
|
||||
/// same as [`ExtrinsicParams`] in describing how to encode the extra and
|
||||
/// additional data.
|
||||
@@ -393,7 +392,7 @@ macro_rules! impl_tuples {
|
||||
|
||||
// For each signed extension in the tuple, find the matching index in the metadata, if
|
||||
// there is one, and add it to a map with that index as the key.
|
||||
let mut exts_by_index = HashMap::new();
|
||||
let mut exts_by_index = BTreeMap::new();
|
||||
$({
|
||||
for (idx, e) in metadata.extrinsic().signed_extensions().iter().enumerate() {
|
||||
// Skip over any exts that have a match already:
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
//! Substrate specific configuration
|
||||
|
||||
use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, Hasher, Header};
|
||||
use codec::{Decode, Encode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::prelude::*;
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
use codec::{Decode, Encode};
|
||||
pub use primitive_types::{H256, U256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Default set of commonly used types by Substrate runtimes.
|
||||
// Note: We only use this at the type level, so it should be impossible to
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use crate::prelude::*;
|
||||
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata};
|
||||
use derivative::Derivative;
|
||||
use std::borrow::Cow;
|
||||
use borrow::Cow;
|
||||
|
||||
/// This represents a constant address. Anything implementing this trait
|
||||
/// can be used to fetch constants.
|
||||
|
||||
@@ -39,7 +39,7 @@ impl<T: Config, Client: OfflineClientT<T>> CustomValuesClient<T, Client> {
|
||||
let custom = metadata.custom();
|
||||
let custom_value = custom
|
||||
.get(address.name())
|
||||
.ok_or_else(|| MetadataError::CustomValueNameNotFound(address.name().to_string()))?;
|
||||
.ok_or_else(|| MetadataError::CustomValueNameNotFound(address.name().to_owned()))?;
|
||||
|
||||
let value = <Address::Target as DecodeWithMetadata>::decode_with_metadata(
|
||||
&mut custom_value.bytes(),
|
||||
@@ -62,7 +62,7 @@ impl<T: Config, Client: OfflineClientT<T>> CustomValuesClient<T, Client> {
|
||||
let custom = metadata.custom();
|
||||
let custom_value = custom
|
||||
.get(address.name())
|
||||
.ok_or_else(|| MetadataError::CustomValueNameNotFound(address.name().to_string()))?;
|
||||
.ok_or_else(|| MetadataError::CustomValueNameNotFound(address.name().to_owned()))?;
|
||||
|
||||
Ok(custom_value.bytes().to_vec())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::prelude::*;
|
||||
use core::fmt::Debug;
|
||||
use derive_more::Display;
|
||||
use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType};
|
||||
use std::borrow::Cow;
|
||||
use borrow::Cow;
|
||||
|
||||
use super::{Error, MetadataError};
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ pub use subxt_metadata::TryFromError as MetadataTryFromError;
|
||||
#[non_exhaustive]
|
||||
pub enum Error {
|
||||
/// Io error.
|
||||
#[cfg(feature = "std")]
|
||||
#[display(fmt = "Io error: {_0}")]
|
||||
Io(std::io::Error),
|
||||
/// Codec error.
|
||||
#[display(fmt = "Scale codec error: {_0}")]
|
||||
Codec(codec::Error),
|
||||
/// Rpc error.
|
||||
#[cfg(feature = "std")]
|
||||
#[display(fmt = "Rpc error: {_0}")]
|
||||
Rpc(RpcError),
|
||||
/// Serde serialization error
|
||||
@@ -102,8 +102,8 @@ impl From<String> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::convert::Infallible> for Error {
|
||||
fn from(value: std::convert::Infallible) -> Self {
|
||||
impl From<core::convert::Infallible> for Error {
|
||||
fn from(value: core::convert::Infallible) -> Self {
|
||||
match value {}
|
||||
}
|
||||
}
|
||||
@@ -111,13 +111,13 @@ impl From<std::convert::Infallible> for Error {
|
||||
/// An RPC error. Since we are generic over the RPC client that is used,
|
||||
/// the error is boxed and could be casted.
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[derive(Debug, Display)]
|
||||
#[non_exhaustive]
|
||||
pub enum RpcError {
|
||||
// Dev note: We need the error to be safely sent between threads
|
||||
// for `subscribe_to_block_headers_filling_in_gaps` and friends.
|
||||
/// Error related to the RPC client.
|
||||
#[cfg(feature = "std")]
|
||||
#[display(fmt = "RPC error: {_0}")]
|
||||
ClientError(Box<dyn std::error::Error + Send + Sync + 'static>),
|
||||
/// This error signals that the request was rejected for some reason.
|
||||
|
||||
@@ -2,11 +2,17 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::backend::{Backend, BackendExt, BlockRef};
|
||||
use crate::prelude::*;
|
||||
use crate::{client::OnlineClientT, error::Error, events::Events, Config};
|
||||
use crate::{error::Error, events::Events, Config};
|
||||
use derivative::Derivative;
|
||||
use std::future::Future;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{
|
||||
backend::{Backend, BackendExt, BlockRef},
|
||||
client::OnlineClientT,
|
||||
};
|
||||
|
||||
use core::future::Future;
|
||||
|
||||
/// A client for working with events.
|
||||
#[derive(Derivative)]
|
||||
@@ -26,6 +32,7 @@ impl<T, Client> EventsClient<T, Client> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, Client> EventsClient<T, Client>
|
||||
where
|
||||
T: Config,
|
||||
@@ -86,6 +93,7 @@ fn system_events_key() -> [u8; 32] {
|
||||
}
|
||||
|
||||
// Get the event bytes from the provided client, at the provided block hash.
|
||||
#[cfg(feature = "std")]
|
||||
pub(crate) async fn get_event_bytes<T: Config>(
|
||||
backend: &dyn Backend<T>,
|
||||
block_hash: T::Hash,
|
||||
|
||||
@@ -5,18 +5,20 @@
|
||||
//! A representation of a block of events.
|
||||
|
||||
use super::{Phase, StaticEvent};
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
client::OnlineClientT,
|
||||
error::{Error, MetadataError},
|
||||
events::events_client::get_event_bytes,
|
||||
metadata::types::PalletMetadata,
|
||||
Config, Metadata,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{client::OnlineClientT, events::events_client::get_event_bytes};
|
||||
|
||||
use codec::{Compact, Decode};
|
||||
use derivative::Derivative;
|
||||
use scale_decode::DecodeAsType;
|
||||
use std::sync::Arc;
|
||||
use sync::Arc;
|
||||
|
||||
/// A collection of events obtained from a block, bundled with the necessary
|
||||
/// information needed to decode and iterate over them.
|
||||
@@ -34,8 +36,8 @@ pub struct Events<T: Config> {
|
||||
}
|
||||
|
||||
// Ignore the Metadata when debug-logging events; it's big and distracting.
|
||||
impl<T: Config> std::fmt::Debug for Events<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl<T: Config> core::fmt::Debug for Events<T> {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("Events")
|
||||
.field("block_hash", &self.block_hash)
|
||||
.field("event_bytes", &self.event_bytes)
|
||||
@@ -77,6 +79,7 @@ impl<T: Config> Events<T> {
|
||||
/// latest metadata version.
|
||||
/// - The client may not be able to obtain the block at the given hash. Only
|
||||
/// archive nodes keep hold of all past block information.
|
||||
#[cfg(feature = "std")]
|
||||
pub async fn new_from_client<Client>(
|
||||
metadata: Metadata,
|
||||
block_hash: T::Hash,
|
||||
@@ -120,7 +123,7 @@ impl<T: Config> Events<T> {
|
||||
|
||||
let mut pos = self.start_idx;
|
||||
let mut index = 0;
|
||||
std::iter::from_fn(move || {
|
||||
core::iter::from_fn(move || {
|
||||
if event_bytes.len() <= pos || num_events == index {
|
||||
None
|
||||
} else {
|
||||
|
||||
+6
-2
@@ -43,6 +43,7 @@ use tracing_subscriber as _;
|
||||
#[allow(unused_imports)]
|
||||
pub use getrandom as _;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod backend;
|
||||
pub mod blocks;
|
||||
pub mod client;
|
||||
@@ -53,11 +54,11 @@ pub mod dynamic;
|
||||
pub mod error;
|
||||
pub mod events;
|
||||
pub mod metadata;
|
||||
pub mod prelude;
|
||||
pub mod runtime_api;
|
||||
pub mod storage;
|
||||
pub mod tx;
|
||||
pub mod utils;
|
||||
pub mod prelude;
|
||||
|
||||
// Internal helper macros
|
||||
#[macro_use]
|
||||
@@ -66,12 +67,15 @@ mod macros;
|
||||
// Expose a few of the most common types at root,
|
||||
// but leave most types behind their respective modules.
|
||||
pub use crate::{
|
||||
client::{OfflineClient, OnlineClient},
|
||||
client::OfflineClient,
|
||||
config::{Config, PolkadotConfig, SubstrateConfig},
|
||||
error::Error,
|
||||
metadata::Metadata,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use crate::client::OnlineClient;
|
||||
|
||||
/// Re-export external crates that are made use of in the subxt API.
|
||||
pub mod ext {
|
||||
pub use codec;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use crate::error::MetadataError;
|
||||
use crate::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use sync::Arc;
|
||||
|
||||
/// A cheaply clone-able representation of the runtime metadata received from a node.
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -12,7 +12,7 @@ pub struct Metadata {
|
||||
inner: Arc<subxt_metadata::Metadata>,
|
||||
}
|
||||
|
||||
impl std::ops::Deref for Metadata {
|
||||
impl core::ops::Deref for Metadata {
|
||||
type Target = subxt_metadata::Metadata;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.inner
|
||||
|
||||
@@ -16,6 +16,7 @@ cfg_if! {
|
||||
pub use std::{
|
||||
any,
|
||||
borrow,
|
||||
borrow::ToOwned,
|
||||
boxed::{Box},
|
||||
cmp,
|
||||
collections,
|
||||
@@ -29,8 +30,8 @@ cfg_if! {
|
||||
string::{String},
|
||||
str,
|
||||
sync,
|
||||
time,
|
||||
vec,
|
||||
time,
|
||||
rc,
|
||||
iter,
|
||||
};
|
||||
@@ -38,15 +39,16 @@ cfg_if! {
|
||||
} else {
|
||||
pub use alloc::{
|
||||
borrow,
|
||||
borrow::ToOwned,
|
||||
boxed::{Box},
|
||||
collections,
|
||||
format,
|
||||
string::{String},
|
||||
sync,
|
||||
vec::{Vec},
|
||||
vec,
|
||||
rc,
|
||||
};
|
||||
pub use std::vec::Vec;
|
||||
pub use alloc::vec::Vec;
|
||||
pub use core::{
|
||||
any,
|
||||
cmp,
|
||||
|
||||
@@ -4,10 +4,18 @@
|
||||
|
||||
//! Types associated with executing runtime API calls.
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod runtime_client;
|
||||
|
||||
mod runtime_payload;
|
||||
#[cfg(feature = "std")]
|
||||
mod runtime_types;
|
||||
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use runtime_client::RuntimeApiClient;
|
||||
|
||||
pub use runtime_payload::{dynamic, DynamicRuntimeApiPayload, Payload, RuntimeApiPayload};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use runtime_types::RuntimeApi;
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
use super::runtime_types::RuntimeApi;
|
||||
|
||||
use crate::{backend::BlockRef, client::OnlineClientT, error::Error, Config};
|
||||
use crate::prelude::*;
|
||||
use crate::{error::Error, Config};
|
||||
use derivative::Derivative;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{backend::BlockRef, client::OnlineClientT};
|
||||
|
||||
/// Execute runtime API calls.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Clone(bound = "Client: Clone"))]
|
||||
@@ -27,6 +29,7 @@ impl<T, Client> RuntimeApiClient<T, Client> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, Client> RuntimeApiClient<T, Client>
|
||||
where
|
||||
T: Config,
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
use derivative::Derivative;
|
||||
use scale_encode::EncodeAsFields;
|
||||
use scale_value::Composite;
|
||||
use std::borrow::Cow;
|
||||
use crate::prelude::*;
|
||||
use borrow::Cow;
|
||||
|
||||
use crate::dynamic::DecodedValueThunk;
|
||||
use crate::error::MetadataError;
|
||||
@@ -69,7 +70,7 @@ pub trait RuntimeApiPayload {
|
||||
#[derive(Derivative)]
|
||||
#[derivative(
|
||||
Clone(bound = "ArgsData: Clone"),
|
||||
Debug(bound = "ArgsData: std::fmt::Debug")
|
||||
Debug(bound = "ArgsData: core::fmt::Debug")
|
||||
)]
|
||||
pub struct Payload<ArgsData, ReturnTy> {
|
||||
trait_name: Cow<'static, str>,
|
||||
|
||||
@@ -3,12 +3,18 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{
|
||||
backend::{BackendExt, BlockRef},
|
||||
client::OnlineClientT,
|
||||
|
||||
error::{Error, MetadataError},
|
||||
metadata::DecodeWithMetadata,
|
||||
Config,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{
|
||||
backend::{BackendExt, BlockRef},
|
||||
client::OnlineClientT,
|
||||
}
|
||||
|
||||
use crate::prelude::*;
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
@@ -36,6 +42,7 @@ impl<T: Config, Client> RuntimeApi<T, Client> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, Client> RuntimeApi<T, Client>
|
||||
where
|
||||
T: Config,
|
||||
|
||||
@@ -6,12 +6,15 @@
|
||||
|
||||
mod storage_address;
|
||||
mod storage_client;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod storage_type;
|
||||
|
||||
pub mod utils;
|
||||
|
||||
pub use storage_client::StorageClient;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use storage_type::Storage;
|
||||
|
||||
/// Types representing an address which describes where a storage
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use scale_info::TypeDef;
|
||||
use std::borrow::Cow;
|
||||
use borrow::Cow;
|
||||
use subxt_metadata::{StorageEntryType, StorageHasher};
|
||||
|
||||
/// This represents a storage address. Anything implementing this trait
|
||||
@@ -56,7 +56,7 @@ 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>,
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::{
|
||||
storage_type::{validate_storage_address, Storage},
|
||||
utils, StorageAddress,
|
||||
};
|
||||
use super::{utils, StorageAddress};
|
||||
use crate::prelude::*;
|
||||
use crate::{client::OfflineClientT, error::Error, Config};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{
|
||||
backend::BlockRef,
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
error::Error,
|
||||
Config,
|
||||
client::OnlineClientT,
|
||||
storage::storage_type::{validate_storage_address, Storage},
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
use core::{future::Future, marker::PhantomData};
|
||||
use derivative::Derivative;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
/// Query the runtime storage.
|
||||
#[derive(Derivative)]
|
||||
@@ -68,6 +68,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, Client> StorageClient<T, Client>
|
||||
where
|
||||
T: Config,
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::{
|
||||
metadata::{DecodeWithMetadata, Metadata},
|
||||
Config,
|
||||
};
|
||||
|
||||
use crate::prelude::*;
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
|
||||
+5
-1
@@ -14,6 +14,8 @@ use crate::macros::cfg_substrate_compat;
|
||||
mod signer;
|
||||
mod tx_client;
|
||||
mod tx_payload;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod tx_progress;
|
||||
|
||||
// The PairSigner impl currently relies on Substrate bits and pieces, so make it an optional
|
||||
@@ -29,5 +31,7 @@ pub use self::{
|
||||
ValidationResult,
|
||||
},
|
||||
tx_payload::{dynamic, BoxedPayload, DynamicPayload, Payload, TxPayload},
|
||||
tx_progress::{TxInBlock, TxProgress, TxStatus},
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::tx_progress::{TxInBlock, TxProgress, TxStatus};
|
||||
|
||||
@@ -2,18 +2,24 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::prelude::*;
|
||||
use borrow::Cow;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::{
|
||||
backend::{BackendExt, BlockRef, TransactionStatus},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
client::OnlineClientT,
|
||||
tx::TxProgress,
|
||||
};
|
||||
use crate::{
|
||||
client::OfflineClientT,
|
||||
config::{Config, ExtrinsicParams, ExtrinsicParamsEncoder, Hasher},
|
||||
error::{Error, MetadataError},
|
||||
prelude::*,
|
||||
tx::{Signer as SignerT, TxPayload, TxProgress},
|
||||
tx::{Signer as SignerT, TxPayload},
|
||||
utils::{Encoded, PhantomDataSendSync},
|
||||
};
|
||||
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use derivative::Derivative;
|
||||
use sp_core_hashing::blake2_256;
|
||||
@@ -162,6 +168,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, C> TxClient<T, C>
|
||||
where
|
||||
T: Config,
|
||||
@@ -426,6 +433,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T, C> SubmittableExtrinsic<T, C>
|
||||
where
|
||||
T: Config,
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
//! This module contains the trait and types used to represent
|
||||
//! transactions that can be submitted.
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::prelude::{borrow::Cow, sync::Arc};
|
||||
use crate::{
|
||||
dynamic::Value,
|
||||
error::{Error, MetadataError},
|
||||
metadata::Metadata,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
use codec::Encode;
|
||||
use scale_encode::EncodeAsFields;
|
||||
use scale_value::{Composite, ValueDef, Variant};
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
|
||||
/// This represents a transaction payload that can be submitted
|
||||
/// to a node.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
//! Types representing extrinsics/transactions that have been submitted to a node.
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::utils::strip_compact_prefix;
|
||||
use crate::{
|
||||
backend::{BlockRef, StreamOfResults, TransactionStatus as BackendTxStatus},
|
||||
@@ -24,8 +23,8 @@ pub struct TxProgress<T: Config, C> {
|
||||
client: C,
|
||||
}
|
||||
|
||||
impl<T: Config, C> fmt::Debug for TxProgress<T, C> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
impl<T: Config, C> std::fmt::Debug for TxProgress<T, C> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("TxProgress")
|
||||
.field("sub", &"<subscription>")
|
||||
.field("ext_hash", &self.ext_hash)
|
||||
@@ -168,7 +167,7 @@ impl<T: Config, C: Clone> Stream for TxProgress<T, C> {
|
||||
|
||||
/// Possible transaction statuses returned from our [`TxProgress::next()`] call.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug(bound = "C: fmt::Debug"))]
|
||||
#[derivative(Debug(bound = "C: std::fmt::Debug"))]
|
||||
pub enum TxStatus<T: Config, C> {
|
||||
/// Transaction is part of the future queue.
|
||||
Validated,
|
||||
@@ -222,7 +221,7 @@ impl<T: Config, C> TxStatus<T, C> {
|
||||
|
||||
/// This struct represents a transaction that has made it into a block.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug(bound = "C: fmt::Debug"))]
|
||||
#[derivative(Debug(bound = "C: std::fmt::Debug"))]
|
||||
pub struct TxInBlock<T: Config, C> {
|
||||
block_ref: BlockRef<T::Hash>,
|
||||
ext_hash: T::Hash,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//! 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::vec;
|
||||
use crate::prelude::*;
|
||||
use codec::{Decode, Encode};
|
||||
use derive_more::Display;
|
||||
|
||||
@@ -55,7 +55,7 @@ pub(crate) fn strip_compact_prefix(bytes: &[u8]) -> Result<(u64, &[u8]), codec::
|
||||
///
|
||||
/// Returns an error if the the string could not be parsed into a URL.
|
||||
pub fn url_is_secure(url: &str) -> Result<bool, Error> {
|
||||
let url = Url::parse(url).map_err(|e| Error::Rpc(RpcError::ClientError(Box::new(e))))?;
|
||||
let url = Url::parse(url).map_err(|e| Error::Rpc(RpcError::InsecureUrl(url.to_owned())))?;
|
||||
|
||||
let secure_scheme = url.scheme() == "https" || url.scheme() == "wss";
|
||||
let is_localhost = url.host().is_some_and(|e| match e {
|
||||
|
||||
Reference in New Issue
Block a user