diff --git a/Cargo.toml b/Cargo.toml index 310a84fe72..609d0578f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,13 +24,12 @@ chameleon = "0.1.0" scale-info = { version = "1.0.0", features = ["bit-vec"] } futures = "0.3.13" hex = "0.4.3" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "jsonrpsee-clients-expose-tls-feature", features = ["macros", "core-client", "client", "client-ws-transport"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "na-fix-core-client-feature", features = ["macros", "async-client", "client-ws-transport"] } log = "0.4.14" num-traits = { version = "0.2.14", default-features = false } serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0.64" thiserror = "1.0.24" -url = "2.2.1" subxt-macro = { version = "0.1.0", path = "macro" } diff --git a/client/Cargo.toml b/client/Cargo.toml index 5d419cb0d5..8fdc0f54e2 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -17,7 +17,7 @@ keywords = ["parity", "substrate", "blockchain"] [dependencies] async-std = { version = "1.8.0", features = ["tokio1"] } futures = "0.3.9" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "extract-async-client", features = ["client"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "na-fix-core-client-feature", features = ["async-client"] } log = "0.4.13" thiserror = "1.0.23" serde_json = "1" diff --git a/client/src/lib.rs b/client/src/lib.rs index d3d82fb8f0..39379347ed 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -31,14 +31,12 @@ use futures::{ sink::SinkExt, stream::StreamExt, }; -use jsonrpsee::{ - core_client::Client as JsonRpcClient, - types::{ - async_trait, - traits::{ - TransportReceiver, - TransportSender, - }, +use jsonrpsee::core::{ + async_trait, + client::Client as JsonRpcClient, + traits::{ + TransportReceiver, + TransportSender, }, }; use sc_network::config::TransportConfig; diff --git a/examples/submit_and_watch.rs b/examples/submit_and_watch.rs index 20dc21b81c..552d88db1c 100644 --- a/examples/submit_and_watch.rs +++ b/examples/submit_and_watch.rs @@ -61,7 +61,8 @@ async fn simple_transfer() -> Result<(), Box> { .sign_and_submit_then_watch(&signer) .await? .wait_for_finalized_success() - .await.unwrap()?; + .await + .unwrap()?; let transfer_event = balance_transfer.find_first_event::()?; @@ -93,7 +94,8 @@ async fn simple_transfer_separate_events() -> Result<(), Box. -use jsonrpsee::core::{DeserializeOwned, client::Subscription}; +use jsonrpsee::core::{ + client::Subscription, + DeserializeOwned, +}; use sp_core::{ storage::{ StorageChangeSet, diff --git a/src/transaction.rs b/src/transaction.rs index 1fc7f6375b..e14320c2d5 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -64,51 +64,54 @@ impl<'client, T: Config> TransactionProgress<'client, T> { // Return the next item otherwise: let res = sub.next().await?; - Some(res.map(|status| { - match status { - SubstrateTransactionStatus::Future => TransactionStatus::Future, - SubstrateTransactionStatus::Ready => TransactionStatus::Ready, - SubstrateTransactionStatus::Broadcast(peers) => { - TransactionStatus::Broadcast(peers) + Some( + res.map(|status| { + match status { + SubstrateTransactionStatus::Future => TransactionStatus::Future, + SubstrateTransactionStatus::Ready => TransactionStatus::Ready, + SubstrateTransactionStatus::Broadcast(peers) => { + TransactionStatus::Broadcast(peers) + } + SubstrateTransactionStatus::InBlock(hash) => { + TransactionStatus::InBlock(TransactionInBlock { + block_hash: hash, + ext_hash: self.ext_hash, + client: self.client, + }) + } + SubstrateTransactionStatus::Retracted(hash) => { + TransactionStatus::Retracted(hash) + } + SubstrateTransactionStatus::Usurped(hash) => { + TransactionStatus::Usurped(hash) + } + SubstrateTransactionStatus::Dropped => TransactionStatus::Dropped, + SubstrateTransactionStatus::Invalid => TransactionStatus::Invalid, + // Only the following statuses are actually considered "final" (see the substrate + // docs on `TransactionStatus`). Basically, either the transaction makes it into a + // block, or we eventually give up on waiting for it to make it into a block. + // Even `Dropped`/`Invalid`/`Usurped` transactions might make it into a block eventually. + // + // As an example, a transaction that is `Invalid` on one node due to having the wrong + // nonce might still be valid on some fork on another node which ends up being finalized. + // Equally, a transaction `Dropped` from one node may still be in the transaction pool, + // and make it into a block, on another node. Likewise with `Usurped`. + SubstrateTransactionStatus::FinalityTimeout(hash) => { + self.sub = None; + TransactionStatus::FinalityTimeout(hash) + } + SubstrateTransactionStatus::Finalized(hash) => { + self.sub = None; + TransactionStatus::Finalized(TransactionInBlock { + block_hash: hash, + ext_hash: self.ext_hash, + client: self.client, + }) + } } - SubstrateTransactionStatus::InBlock(hash) => { - TransactionStatus::InBlock(TransactionInBlock { - block_hash: hash, - ext_hash: self.ext_hash, - client: self.client, - }) - } - SubstrateTransactionStatus::Retracted(hash) => { - TransactionStatus::Retracted(hash) - } - SubstrateTransactionStatus::Usurped(hash) => { - TransactionStatus::Usurped(hash) - } - SubstrateTransactionStatus::Dropped => TransactionStatus::Dropped, - SubstrateTransactionStatus::Invalid => TransactionStatus::Invalid, - // Only the following statuses are actually considered "final" (see the substrate - // docs on `TransactionStatus`). Basically, either the transaction makes it into a - // block, or we eventually give up on waiting for it to make it into a block. - // Even `Dropped`/`Invalid`/`Usurped` transactions might make it into a block eventually. - // - // As an example, a transaction that is `Invalid` on one node due to having the wrong - // nonce might still be valid on some fork on another node which ends up being finalized. - // Equally, a transaction `Dropped` from one node may still be in the transaction pool, - // and make it into a block, on another node. Likewise with `Usurped`. - SubstrateTransactionStatus::FinalityTimeout(hash) => { - self.sub = None; - TransactionStatus::FinalityTimeout(hash) - } - SubstrateTransactionStatus::Finalized(hash) => { - self.sub = None; - TransactionStatus::Finalized(TransactionInBlock { - block_hash: hash, - ext_hash: self.ext_hash, - client: self.client, - }) - } - } - }).map_err(Into::into)) + }) + .map_err(Into::into), + ) } /// Wait for the transaction to be in a block (but not necessarily finalized), and return @@ -127,17 +130,20 @@ impl<'client, T: Config> TransactionProgress<'client, T> { ) -> Option, Error>> { loop { match self.next().await? { - Ok(status) => match status { - // Finalized or otherwise in a block! Return. - TransactionStatus::InBlock(s) | TransactionStatus::Finalized(s) => { - return Some(Ok(s)) + Ok(status) => { + match status { + // Finalized or otherwise in a block! Return. + TransactionStatus::InBlock(s) + | TransactionStatus::Finalized(s) => return Some(Ok(s)), + // Error scenarios; return the error. + TransactionStatus::FinalityTimeout(_) => { + return Some(Err( + TransactionError::FinalitySubscriptionTimeout.into(), + )) + } + // Ignore anything else and wait for next status event: + _ => continue, } - // Error scenarios; return the error. - TransactionStatus::FinalityTimeout(_) => { - return Some(Err(TransactionError::FinalitySubscriptionTimeout.into())) - } - // Ignore anything else and wait for next status event: - _ => continue, } Err(err) => return Some(Err(err)), } @@ -159,15 +165,19 @@ impl<'client, T: Config> TransactionProgress<'client, T> { ) -> Option, Error>> { loop { match self.next().await? { - Ok(status) => match status { - // finalized! return. - TransactionStatus::Finalized(s) => return Some(Ok(s)), - // error scenarios; return the error. - TransactionStatus::FinalityTimeout(_) => { - return Some(Err(TransactionError::FinalitySubscriptionTimeout.into())) + Ok(status) => { + match status { + // finalized! return. + TransactionStatus::Finalized(s) => return Some(Ok(s)), + // error scenarios; return the error. + TransactionStatus::FinalityTimeout(_) => { + return Some(Err( + TransactionError::FinalitySubscriptionTimeout.into(), + )) + } + // ignore and wait for next status event: + _ => continue, } - // ignore and wait for next status event: - _ => continue, } Err(err) => return Some(Err(err)), } @@ -185,7 +195,9 @@ impl<'client, T: Config> TransactionProgress<'client, T> { /// may well indicate with some probability that the transaction will not make it into a block, /// there is no guarantee that this is true. Thus, we prefer to "play it safe" here. Use the lower /// level [`TransactionProgress::next()`] API if you'd like to handle these statuses yourself. - pub async fn wait_for_finalized_success(self) -> Option, Error>> { + pub async fn wait_for_finalized_success( + self, + ) -> Option, Error>> { let finalized = match self.wait_for_finalized().await? { Ok(f) => f, Err(err) => return Some(Err(err)), diff --git a/test-runtime/Cargo.toml b/test-runtime/Cargo.toml index b53f138956..ee0c94f856 100644 --- a/test-runtime/Cargo.toml +++ b/test-runtime/Cargo.toml @@ -11,6 +11,6 @@ codec = { package = "parity-scale-codec", version = "2", default-features = fals [build-dependencies] subxt = { path = ".." } sp-core = { package = "sp-core", git = "https://github.com/paritytech/substrate/", branch = "master" } -jsonrpsee-http-client = { git = "https://github.com/paritytech/jsonrpsee/", branch = "extract-async-client" } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "na-fix-core-client-feature", features = ["http-client"] } async-std = { version = "1.9.0", features = ["attributes", "tokio1"] } which = "4.2.2" diff --git a/test-runtime/build.rs b/test-runtime/build.rs index 2d78b423ea..4e1545ad56 100644 --- a/test-runtime/build.rs +++ b/test-runtime/build.rs @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with subxt. If not, see . -use jsonrpsee_http_client::{ - types::traits::Client, - HttpClientBuilder, +use jsonrpsee::{ + core::client::ClientT, + http_client::HttpClientBuilder, }; use std::{ env,