mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Update to 2024 edition (#2001)
* Update to 2024 edition * Update to 2024 edition; fmt, use<> and remove refs * async functions
This commit is contained in:
@@ -218,8 +218,8 @@ impl<Hash> Stream for FollowStream<Hash> {
|
||||
pub(super) mod test_utils {
|
||||
use super::*;
|
||||
use crate::config::substrate::H256;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use subxt_rpcs::methods::chain_head::{BestBlockChanged, Finalized, Initialized, NewBlock};
|
||||
|
||||
/// Given some events, returns a follow stream getter that we can use in
|
||||
@@ -313,7 +313,7 @@ pub mod test {
|
||||
});
|
||||
|
||||
let s = FollowStream::new(stream_getter);
|
||||
let out: Vec<_> = s.filter_map(|e| async move { e.ok() }).collect().await;
|
||||
let out: Vec<_> = s.filter_map(async |e| e.ok()).collect().await;
|
||||
|
||||
// The expected response, given the above.
|
||||
assert_eq!(
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::follow_stream::FollowStream;
|
||||
use super::ChainHeadRpcMethods;
|
||||
use super::follow_stream::FollowStream;
|
||||
use crate::config::{Config, Hash, HashFor};
|
||||
use crate::error::Error;
|
||||
use futures::stream::{FuturesUnordered, Stream, StreamExt};
|
||||
@@ -468,7 +468,7 @@ impl<H: Hash> Drop for BlockRef<H> {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(super) mod test_utils {
|
||||
use super::super::follow_stream::{test_utils::test_stream_getter, FollowStream};
|
||||
use super::super::follow_stream::{FollowStream, test_utils::test_stream_getter};
|
||||
use super::*;
|
||||
use crate::config::substrate::H256;
|
||||
|
||||
@@ -573,10 +573,7 @@ mod test {
|
||||
10,
|
||||
);
|
||||
|
||||
let out: Vec<_> = follow_unpin
|
||||
.filter_map(|e| async move { e.ok() })
|
||||
.collect()
|
||||
.await;
|
||||
let out: Vec<_> = follow_unpin.filter_map(async |e| e.ok()).collect().await;
|
||||
|
||||
assert_eq!(
|
||||
out,
|
||||
|
||||
@@ -18,8 +18,8 @@ mod storage_items;
|
||||
|
||||
use self::follow_stream_driver::FollowStreamFinalizedHeads;
|
||||
use crate::backend::{
|
||||
utils::retry, Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf,
|
||||
StreamOfResults, TransactionStatus,
|
||||
Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf, StreamOfResults,
|
||||
TransactionStatus, utils::retry,
|
||||
};
|
||||
use crate::config::{Config, Hash, HashFor};
|
||||
use crate::error::{Error, RpcError};
|
||||
@@ -30,10 +30,10 @@ use futures::{Stream, StreamExt};
|
||||
use std::collections::HashMap;
|
||||
use std::task::Poll;
|
||||
use storage_items::StorageItems;
|
||||
use subxt_rpcs::RpcClient;
|
||||
use subxt_rpcs::methods::chain_head::{
|
||||
FollowEvent, MethodResponse, RuntimeEvent, StorageQuery, StorageQueryType, StorageResultType,
|
||||
};
|
||||
use subxt_rpcs::RpcClient;
|
||||
|
||||
/// Re-export RPC types and methods from [`subxt_rpcs::methods::chain_head`].
|
||||
pub mod rpc_methods {
|
||||
@@ -301,7 +301,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
StorageItems::from_methods(queries, at, &self.follow_handle, self.methods.clone())
|
||||
.await?;
|
||||
|
||||
let stream = storage_items.filter_map(|val| async move {
|
||||
let stream = storage_items.filter_map(async |val| {
|
||||
let val = match val {
|
||||
Ok(val) => val,
|
||||
Err(e) => return Some(Err(e)),
|
||||
@@ -366,7 +366,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
let storage_result_stream = storage_items.filter_map(|val| async move {
|
||||
let storage_result_stream = storage_items.filter_map(async |val| {
|
||||
let val = match val {
|
||||
Ok(val) => val,
|
||||
Err(e) => return Some(Err(e)),
|
||||
@@ -686,7 +686,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
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,
|
||||
@@ -722,7 +722,9 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
// in which we may lose the finalized 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(err_other("chainHead_follow emitted 'stop' event during transaction submission"));
|
||||
return Poll::Ready(err_other(
|
||||
"chainHead_follow emitted 'stop' event during transaction submission",
|
||||
));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -756,7 +758,11 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
// 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) => return Poll::Ready(err_other("No more transaction progress events, but we haven't seen a Finalized one yet")),
|
||||
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.into()))),
|
||||
Poll::Ready(Some(Ok(ev))) => ev,
|
||||
};
|
||||
|
||||
@@ -12,12 +12,12 @@ use crate::backend::{
|
||||
TransactionStatus,
|
||||
};
|
||||
use crate::{
|
||||
config::{Config, HashFor, Header},
|
||||
Error,
|
||||
config::{Config, HashFor, Header},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use futures::TryStreamExt;
|
||||
use futures::{future, future::Either, stream, Future, FutureExt, Stream, StreamExt};
|
||||
use futures::{Future, FutureExt, Stream, StreamExt, future, future::Either, stream};
|
||||
use std::collections::VecDeque;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
@@ -473,7 +473,7 @@ where
|
||||
Ok::<_, Error>(header)
|
||||
}
|
||||
})
|
||||
.filter_map(|h| async { h.transpose() });
|
||||
.filter_map(async |h| h.transpose());
|
||||
|
||||
// On the next iteration, we'll get details starting just after this end block.
|
||||
last_block_num = Some(end_block_num);
|
||||
|
||||
+22
-20
@@ -388,10 +388,10 @@ mod test {
|
||||
use primitive_types::H256;
|
||||
use rpc::RpcClientT;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use subxt_core::{config::DefaultExtrinsicParams, Config};
|
||||
use subxt_core::{Config, config::DefaultExtrinsicParams};
|
||||
use subxt_rpcs::client::{
|
||||
mock_rpc_client::{Json, MockRpcClientBuilder},
|
||||
MockRpcClient,
|
||||
mock_rpc_client::{Json, MockRpcClientBuilder},
|
||||
};
|
||||
|
||||
fn random_hash() -> H256 {
|
||||
@@ -427,7 +427,7 @@ mod test {
|
||||
mod legacy {
|
||||
use super::*;
|
||||
use crate::{
|
||||
backend::legacy::{rpc_methods::RuntimeVersion, LegacyBackend},
|
||||
backend::legacy::{LegacyBackend, rpc_methods::RuntimeVersion},
|
||||
error::RpcError,
|
||||
};
|
||||
|
||||
@@ -511,11 +511,11 @@ mod test {
|
||||
#[tokio::test]
|
||||
async fn storage_fetch_value() {
|
||||
let rpc_client = MockRpcClient::builder()
|
||||
.method_handler_once("state_getStorage", move |_params| async move {
|
||||
.method_handler_once("state_getStorage", async move |_params| {
|
||||
// Return "disconnected" error on first call
|
||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||
})
|
||||
.method_handler_once("state_getStorage", move |_param| async move {
|
||||
.method_handler_once("state_getStorage", async move |_param| {
|
||||
// Return some hex encoded storage value on the next one
|
||||
Json(hex::encode("Data1"))
|
||||
})
|
||||
@@ -550,11 +550,11 @@ mod test {
|
||||
async fn simple_fetch() {
|
||||
let hash = random_hash();
|
||||
let rpc_client = MockRpcClient::builder()
|
||||
.method_handler_once("chain_getBlockHash", move |_params| async move {
|
||||
.method_handler_once("chain_getBlockHash", async move |_params| {
|
||||
// Return "disconnected" error on first call
|
||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||
})
|
||||
.method_handler_once("chain_getBlockHash", move |_params| async move {
|
||||
.method_handler_once("chain_getBlockHash", async move |_params| {
|
||||
// Return the blockhash on next call
|
||||
Json(hash)
|
||||
})
|
||||
@@ -854,11 +854,13 @@ mod test {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(response
|
||||
.next()
|
||||
.await
|
||||
.unwrap()
|
||||
.is_err_and(|e| matches!(e, Error::Other(e) if e == "error")));
|
||||
assert!(
|
||||
response
|
||||
.next()
|
||||
.await
|
||||
.unwrap()
|
||||
.is_err_and(|e| matches!(e, Error::Other(e) if e == "error"))
|
||||
);
|
||||
assert!(response.next().await.is_none());
|
||||
}
|
||||
|
||||
@@ -868,11 +870,11 @@ mod test {
|
||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
let rpc_client = mock_client_builder(rx)
|
||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
||||
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||
// First call; return DisconnectedWillReconnect
|
||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||
})
|
||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
||||
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||
// Otherwise, return that we'll start sending a response, and spawn
|
||||
// task to send the relevant response via chainHead_follow.
|
||||
tokio::spawn(async move {
|
||||
@@ -925,11 +927,11 @@ mod test {
|
||||
let tx2 = tx.clone();
|
||||
|
||||
let rpc_client = mock_client_builder(rx)
|
||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
||||
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||
// First call; return DisconnectedWillReconnect
|
||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||
})
|
||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
||||
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||
// Next call, return a storage item and then a "waiting for continue".
|
||||
tokio::spawn(async move {
|
||||
tx.send(storage_items("Id1", &[storage_result("ID1", "Data1")]))
|
||||
@@ -938,11 +940,11 @@ mod test {
|
||||
});
|
||||
Ok(Json(response_started("Id1")))
|
||||
})
|
||||
.method_handler_once("chainHead_v1_continue", move |_params| async move {
|
||||
.method_handler_once("chainHead_v1_continue", async move |_params| {
|
||||
// First call; return DisconnectedWillReconnect
|
||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||
})
|
||||
.method_handler_once("chainHead_v1_continue", move |_params| async move {
|
||||
.method_handler_once("chainHead_v1_continue", async move |_params| {
|
||||
// Next call; acknowledge the "continue" and return reamining storage items.
|
||||
tokio::spawn(async move {
|
||||
tx2.send(storage_items("Id1", &[storage_result("ID2", "Data2")]))
|
||||
@@ -986,11 +988,11 @@ mod test {
|
||||
let hash = random_hash();
|
||||
let (_tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let rpc_client = mock_client_builder(rx)
|
||||
.method_handler_once("chainSpec_v1_genesisHash", move |_params| async move {
|
||||
.method_handler_once("chainSpec_v1_genesisHash", async move |_params| {
|
||||
// First call, return disconnected error.
|
||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||
})
|
||||
.method_handler_once("chainSpec_v1_genesisHash", move |_params| async move {
|
||||
.method_handler_once("chainSpec_v1_genesisHash", async move |_params| {
|
||||
// Next call, return the hash.
|
||||
Ok(Json(hash))
|
||||
})
|
||||
|
||||
@@ -246,7 +246,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn retry_sub_err_terminates_stream() {
|
||||
let stream = futures::stream::iter([Ok(1)]);
|
||||
let resubscribe = Box::new(move || async move { Err(custom_err()) }.boxed());
|
||||
let resubscribe = Box::new(|| async move { Err(custom_err()) }.boxed());
|
||||
|
||||
let retry_stream = RetrySubscription {
|
||||
state: Some(PendingOrStream::Stream(StreamOf::new(Box::pin(stream)))),
|
||||
@@ -259,7 +259,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn retry_sub_resubscribe_err() {
|
||||
let stream = futures::stream::iter([Ok(1), Err(disconnect_err())]);
|
||||
let resubscribe = Box::new(move || async move { Err(custom_err()) }.boxed());
|
||||
let resubscribe = Box::new(|| async move { Err(custom_err()) }.boxed());
|
||||
|
||||
let retry_stream = RetrySubscription {
|
||||
state: Some(PendingOrStream::Stream(StreamOf::new(Box::pin(stream)))),
|
||||
|
||||
@@ -161,7 +161,12 @@ where
|
||||
2 => u16::decode(cursor)?.into(),
|
||||
4 => u32::decode(cursor)?.into(),
|
||||
8 => u64::decode(cursor)?,
|
||||
_ => return Err(Error::Decode(DecodeError::custom_string(format!("state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)", account_nonce_bytes.len()))))
|
||||
_ => {
|
||||
return Err(Error::Decode(DecodeError::custom_string(format!(
|
||||
"state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)",
|
||||
account_nonce_bytes.len()
|
||||
))));
|
||||
}
|
||||
};
|
||||
Ok(account_nonce)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{
|
||||
blocks::block_types::{get_events, CachedEvents},
|
||||
blocks::block_types::{CachedEvents, get_events},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
config::{Config, HashFor},
|
||||
error::Error,
|
||||
@@ -81,7 +81,7 @@ where
|
||||
/// If an error occurs, all subsequent iterations return `None`.
|
||||
pub fn find<E: StaticExtrinsic>(
|
||||
&self,
|
||||
) -> impl Iterator<Item = Result<FoundExtrinsic<T, C, E>, Error>> + '_ {
|
||||
) -> impl Iterator<Item = Result<FoundExtrinsic<T, C, E>, Error>> {
|
||||
self.inner.find::<E>().map(|res| {
|
||||
match res {
|
||||
Err(e) => Err(Error::from(e)),
|
||||
@@ -308,7 +308,7 @@ impl<T: Config> ExtrinsicEvents<T> {
|
||||
///
|
||||
/// This works in the same way that [`events::Events::iter()`] does, with the
|
||||
/// exception that it filters out events not related to the submitted extrinsic.
|
||||
pub fn iter(&self) -> impl Iterator<Item = Result<events::EventDetails<T>, Error>> + '_ {
|
||||
pub fn iter(&self) -> impl Iterator<Item = Result<events::EventDetails<T>, Error>> {
|
||||
self.events.iter().filter(|ev| {
|
||||
ev.as_ref()
|
||||
.map(|ev| ev.phase() == events::Phase::ApplyExtrinsic(self.idx))
|
||||
@@ -320,7 +320,7 @@ impl<T: Config> ExtrinsicEvents<T> {
|
||||
///
|
||||
/// This works in the same way that [`events::Events::find()`] does, with the
|
||||
/// exception that it filters out events not related to the submitted extrinsic.
|
||||
pub fn find<Ev: events::StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
|
||||
pub fn find<Ev: events::StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> {
|
||||
self.iter()
|
||||
.filter_map(|ev| ev.and_then(|ev| ev.as_event::<Ev>()).transpose())
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use crate::custom_values::CustomValuesClient;
|
||||
use crate::{
|
||||
Metadata,
|
||||
blocks::BlocksClient,
|
||||
config::{Config, HashFor},
|
||||
constants::ConstantsClient,
|
||||
@@ -12,7 +13,6 @@ use crate::{
|
||||
storage::StorageClient,
|
||||
tx::TxClient,
|
||||
view_functions::ViewFunctionsClient,
|
||||
Metadata,
|
||||
};
|
||||
|
||||
use derive_where::derive_where;
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
use super::{OfflineClient, OfflineClientT};
|
||||
use crate::custom_values::CustomValuesClient;
|
||||
use crate::{
|
||||
backend::{legacy::LegacyBackend, rpc::RpcClient, Backend, BackendExt, StreamOfResults},
|
||||
Metadata,
|
||||
backend::{Backend, BackendExt, StreamOfResults, legacy::LegacyBackend, rpc::RpcClient},
|
||||
blocks::{BlockRef, BlocksClient},
|
||||
config::{Config, HashFor},
|
||||
constants::ConstantsClient,
|
||||
@@ -15,7 +16,6 @@ use crate::{
|
||||
storage::StorageClient,
|
||||
tx::TxClient,
|
||||
view_functions::ViewFunctionsClient,
|
||||
Metadata,
|
||||
};
|
||||
use derive_where::derive_where;
|
||||
use futures::future;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{client::OfflineClientT, error::Error, Config};
|
||||
use crate::{Config, client::OfflineClientT, error::Error};
|
||||
use derive_where::derive_where;
|
||||
use subxt_core::constants::address::Address;
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ mod constants_client;
|
||||
|
||||
pub use constants_client::ConstantsClient;
|
||||
pub use subxt_core::constants::address::{
|
||||
dynamic, Address, DefaultAddress, DynamicAddress, StaticAddress,
|
||||
Address, DefaultAddress, DynamicAddress, StaticAddress, dynamic,
|
||||
};
|
||||
|
||||
@@ -50,8 +50,8 @@ mod tests {
|
||||
use crate::{Metadata, OfflineClient, SubstrateConfig};
|
||||
use codec::Encode;
|
||||
use scale_decode::DecodeAsType;
|
||||
use scale_info::form::PortableForm;
|
||||
use scale_info::TypeInfo;
|
||||
use scale_info::form::PortableForm;
|
||||
use std::collections::BTreeMap;
|
||||
use subxt_core::client::RuntimeVersion;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
use crate::metadata::{DecodeWithMetadata, Metadata};
|
||||
use core::fmt::Debug;
|
||||
use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, TypeResolver};
|
||||
use scale_decode::{DecodeAsType, TypeResolver, visitor::DecodeAsTypeResult};
|
||||
|
||||
use std::{borrow::Cow, marker::PhantomData};
|
||||
|
||||
@@ -73,7 +73,9 @@ pub enum TokenError {
|
||||
#[error("Funds are unavailable.")]
|
||||
FundsUnavailable,
|
||||
/// Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved.
|
||||
#[error("Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved.")]
|
||||
#[error(
|
||||
"Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved."
|
||||
)]
|
||||
OnlyProvider,
|
||||
/// Account cannot exist with the funds that would be given.
|
||||
#[error("Account cannot exist with the funds that would be given.")]
|
||||
@@ -327,7 +329,9 @@ impl DispatchError {
|
||||
module_bytes[4],
|
||||
]
|
||||
} else {
|
||||
tracing::warn!("Can't decode error sp_runtime::DispatchError: bytes do not match known shapes");
|
||||
tracing::warn!(
|
||||
"Can't decode error sp_runtime::DispatchError: bytes do not match known shapes"
|
||||
);
|
||||
// Return _all_ of the bytes; every "unknown" return should be consistent.
|
||||
return Err(super::Error::Unknown(bytes.to_vec()));
|
||||
};
|
||||
|
||||
@@ -170,7 +170,9 @@ pub enum BlockError {
|
||||
#[error("Could not find a block with hash {0} (perhaps it was on a non-finalized fork?)")]
|
||||
NotFound(String),
|
||||
/// Leftover bytes found after decoding the extrinsic.
|
||||
#[error("After decoding the exntrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed")]
|
||||
#[error(
|
||||
"After decoding the exntrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed"
|
||||
)]
|
||||
LeftoverBytes {
|
||||
/// Index of the extrinsic that failed to decode.
|
||||
extrinsic_index: usize,
|
||||
@@ -222,7 +224,9 @@ impl BlockError {
|
||||
pub enum TransactionError {
|
||||
/// The block hash that the transaction was added to could not be found.
|
||||
/// This is probably because the block was retracted before being finalized.
|
||||
#[error("The block containing the transaction can no longer be found (perhaps it was on a non-finalized fork?)")]
|
||||
#[error(
|
||||
"The block containing the transaction can no longer be found (perhaps it was on a non-finalized fork?)"
|
||||
)]
|
||||
BlockNotFound,
|
||||
/// An error happened on the node that the transaction was submitted to.
|
||||
#[error("Error handling transaction: {0}")]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
config::{Config, HashFor},
|
||||
Error, Metadata,
|
||||
config::{Config, HashFor},
|
||||
};
|
||||
use derive_where::derive_where;
|
||||
use scale_decode::DecodeAsType;
|
||||
@@ -58,7 +58,7 @@ impl<T: Config> Events<T> {
|
||||
/// Iterate through the events using metadata to dynamically decode and skip
|
||||
/// them, and return only those which should decode to the provided `Ev` type.
|
||||
/// If an error occurs, all subsequent iterations return `None`.
|
||||
pub fn find<Ev: StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
|
||||
pub fn find<Ev: StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> {
|
||||
self.inner.find::<Ev>().map(|item| item.map_err(Into::into))
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
mod events_client;
|
||||
mod events_type;
|
||||
|
||||
use crate::client::OnlineClientT;
|
||||
use crate::Error;
|
||||
use crate::client::OnlineClientT;
|
||||
use subxt_core::{
|
||||
config::{Config, HashFor},
|
||||
Metadata,
|
||||
config::{Config, HashFor},
|
||||
};
|
||||
|
||||
pub use events_client::EventsClient;
|
||||
|
||||
+6
-6
@@ -58,10 +58,10 @@ pub mod view_functions;
|
||||
/// Polkadot node.
|
||||
pub mod config {
|
||||
pub use subxt_core::config::{
|
||||
polkadot, substrate, transaction_extensions, Config, DefaultExtrinsicParams,
|
||||
DefaultExtrinsicParamsBuilder, ExtrinsicParams, ExtrinsicParamsEncoder, Hash, HashFor,
|
||||
Hasher, Header, PolkadotConfig, PolkadotExtrinsicParams, SubstrateConfig,
|
||||
SubstrateExtrinsicParams, TransactionExtension,
|
||||
Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, ExtrinsicParams,
|
||||
ExtrinsicParamsEncoder, Hash, HashFor, Hasher, Header, PolkadotConfig,
|
||||
PolkadotExtrinsicParams, SubstrateConfig, SubstrateExtrinsicParams, TransactionExtension,
|
||||
polkadot, substrate, transaction_extensions,
|
||||
};
|
||||
pub use subxt_core::error::ExtrinsicParamsError;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ pub mod metadata {
|
||||
/// Submit dynamic transactions.
|
||||
pub mod dynamic {
|
||||
pub use subxt_core::dynamic::{
|
||||
constant, runtime_api_call, storage, tx, view_function_call, At, DecodedValue,
|
||||
DecodedValueThunk, Value,
|
||||
At, DecodedValue, DecodedValueThunk, Value, constant, runtime_api_call, storage, tx,
|
||||
view_function_call,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@ mod runtime_types;
|
||||
pub use runtime_client::RuntimeApiClient;
|
||||
pub use runtime_types::RuntimeApi;
|
||||
pub use subxt_core::runtime_api::payload::{
|
||||
dynamic, DefaultPayload, DynamicPayload, Payload, StaticPayload,
|
||||
DefaultPayload, DynamicPayload, Payload, StaticPayload, dynamic,
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ where
|
||||
&self,
|
||||
function: &'a str,
|
||||
call_parameters: Option<&'a [u8]>,
|
||||
) -> impl Future<Output = Result<Res, Error>> + 'a {
|
||||
) -> impl Future<Output = Result<Res, Error>> + use<'a, Res, Client, T> {
|
||||
let client = self.client.clone();
|
||||
let block_hash = self.block_ref.hash();
|
||||
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
||||
@@ -68,7 +68,7 @@ where
|
||||
pub fn call<Call: Payload>(
|
||||
&self,
|
||||
payload: Call,
|
||||
) -> impl Future<Output = Result<Call::ReturnType, Error>> {
|
||||
) -> impl Future<Output = Result<Call::ReturnType, Error>> + use<Call, Client, T> {
|
||||
let client = self.client.clone();
|
||||
let block_hash = self.block_ref.hash();
|
||||
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
||||
|
||||
@@ -10,5 +10,5 @@ mod storage_type;
|
||||
pub use storage_client::StorageClient;
|
||||
pub use storage_type::{Storage, StorageKeyValuePair};
|
||||
pub use subxt_core::storage::address::{
|
||||
dynamic, Address, DefaultAddress, DynamicAddress, StaticAddress, StaticStorageKey, StorageKey,
|
||||
Address, DefaultAddress, DynamicAddress, StaticAddress, StaticStorageKey, StorageKey, dynamic,
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ where
|
||||
pub fn fetch<'address, Addr>(
|
||||
&self,
|
||||
address: &'address Addr,
|
||||
) -> impl Future<Output = Result<Option<Addr::Target>, Error>> + 'address
|
||||
) -> impl Future<Output = Result<Option<Addr::Target>, Error>> + use<'address, Addr, Client, T>
|
||||
where
|
||||
Addr: Address<IsFetchable = Yes> + 'address,
|
||||
{
|
||||
@@ -142,7 +142,7 @@ where
|
||||
pub fn fetch_or_default<'address, Addr>(
|
||||
&self,
|
||||
address: &'address Addr,
|
||||
) -> impl Future<Output = Result<Addr::Target, Error>> + 'address
|
||||
) -> impl Future<Output = Result<Addr::Target, Error>> + use<'address, Addr, Client, T>
|
||||
where
|
||||
Addr: Address<IsFetchable = Yes, IsDefaultable = Yes> + 'address,
|
||||
{
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
mod tx_client;
|
||||
mod tx_progress;
|
||||
|
||||
pub use subxt_core::tx::payload::{dynamic, DefaultPayload, DynamicPayload, Payload};
|
||||
pub use subxt_core::tx::payload::{DefaultPayload, DynamicPayload, Payload, dynamic};
|
||||
pub use subxt_core::tx::signer::{self, Signer};
|
||||
pub use tx_client::{
|
||||
DefaultParams, PartialTransaction, SubmittableTransaction, TransactionInvalid,
|
||||
|
||||
@@ -89,10 +89,10 @@ where
|
||||
// Error scenarios; return the error.
|
||||
TxStatus::Error { message } => return Err(TransactionError::Error(message).into()),
|
||||
TxStatus::Invalid { message } => {
|
||||
return Err(TransactionError::Invalid(message).into())
|
||||
return Err(TransactionError::Invalid(message).into());
|
||||
}
|
||||
TxStatus::Dropped { message } => {
|
||||
return Err(TransactionError::Dropped(message).into())
|
||||
return Err(TransactionError::Dropped(message).into());
|
||||
}
|
||||
// Ignore and wait for next status event:
|
||||
_ => continue,
|
||||
@@ -321,11 +321,11 @@ mod test {
|
||||
use subxt_core::client::RuntimeVersion;
|
||||
|
||||
use crate::{
|
||||
Error, SubstrateConfig,
|
||||
backend::{StreamOfResults, TransactionStatus},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
config::{Config, HashFor},
|
||||
tx::TxProgress,
|
||||
Error, SubstrateConfig,
|
||||
};
|
||||
|
||||
type MockTxProgress = TxProgress<SubstrateConfig, MockClient>;
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
use crate::macros::cfg_jsonrpsee;
|
||||
|
||||
pub use subxt_core::utils::{
|
||||
bits, strip_compact_prefix, to_hex, AccountId32, Encoded, Era, KeyedVec, MultiAddress,
|
||||
MultiSignature, PhantomDataSendSync, Static, UncheckedExtrinsic, WrapperKeepOpaque, Yes, H160,
|
||||
H256, H512,
|
||||
AccountId32, Encoded, Era, H160, H256, H512, KeyedVec, MultiAddress, MultiSignature,
|
||||
PhantomDataSendSync, Static, UncheckedExtrinsic, WrapperKeepOpaque, Yes, bits,
|
||||
strip_compact_prefix, to_hex,
|
||||
};
|
||||
|
||||
pub use subxt_rpcs::utils::url_is_secure;
|
||||
|
||||
@@ -8,7 +8,7 @@ mod view_function_types;
|
||||
mod view_functions_client;
|
||||
|
||||
pub use subxt_core::view_functions::payload::{
|
||||
dynamic, DefaultPayload, DynamicPayload, Payload, StaticPayload,
|
||||
DefaultPayload, DynamicPayload, Payload, StaticPayload, dynamic,
|
||||
};
|
||||
pub use view_function_types::ViewFunctionsApi;
|
||||
pub use view_functions_client::ViewFunctionsClient;
|
||||
|
||||
@@ -48,7 +48,7 @@ where
|
||||
pub fn call<Call: Payload>(
|
||||
&self,
|
||||
payload: Call,
|
||||
) -> impl Future<Output = Result<Call::ReturnType, Error>> {
|
||||
) -> impl Future<Output = Result<Call::ReturnType, Error>> + use<Call, Client, T> {
|
||||
let client = self.client.clone();
|
||||
let block_hash = self.block_ref.hash();
|
||||
// Ensure that the returned future doesn't have a lifetime tied to api.view_functions(),
|
||||
|
||||
Reference in New Issue
Block a user