Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resolve a few TODO + no jsonrpc deps
  • Loading branch information
niklasad1 committed Sep 3, 2021
commit 4471cb71e2430dcb5eec74d093f276afe92c0e67
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ members = [
"bin/node/executor",
"bin/node/primitives",
"bin/node/rpc",
# TODO(niklasad1): bring back once rpsee macros is a thing.
# "bin/node/rpc-client",
"bin/node/rpc-client",
"bin/node/runtime",
"bin/node/testing",
"bin/utils/chain-spec-builder",
Expand Down Expand Up @@ -198,8 +197,7 @@ members = [
"utils/frame/remote-externalities",
"utils/frame/frame-utilities-cli",
"utils/frame/try-runtime/cli",
# TODO(niklasad1): port this to jsonrpsee
# "utils/frame/rpc/support",
"utils/frame/rpc/support",
"utils/frame/rpc/system",
"utils/prometheus",
"utils/wasm-builder",
Expand Down
5 changes: 2 additions & 3 deletions bin/node/rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.3.16"
jsonrpc-core-client = { version = "18.0.0", default-features = false, features = [
"http",
] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "macros"] }
tokio = { version = "1.10", features = ["full"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
sp-tracing = { version = "4.0.0-dev", path = "../../../primitives/tracing" }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
50 changes: 26 additions & 24 deletions bin/node/rpc-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
//! This module shows how you can write a Rust RPC client that connects to a running
//! substrate node and use statically typed RPC wrappers.

use futures::{Future, TryFutureExt};
use jsonrpc_core_client::{transports::http, RpcError};
use futures::TryFutureExt;
use jsonrpsee::{types::Error, ws_client::WsClientBuilder};
use node_primitives::Hash;
use sc_rpc::author::{hash::ExtrinsicOrHash, AuthorClient};
use sc_rpc::author::{hash::ExtrinsicOrHash, AuthorApiClient};

fn main() -> Result<(), RpcError> {
#[tokio::main]
async fn main() -> Result<(), Error> {
sp_tracing::try_init_simple();

futures::executor::block_on(async {
let uri = "http://localhost:9933";

http::connect(uri)
.and_then(|client: AuthorClient<Hash, Hash>| remove_all_extrinsics(client))
.await
})
// NOTE(niklasad1): changed this to the WS client because that jsonrpsee proc macros
// requires trait bound `SubscriptionClient` that is not implemented.
WsClientBuilder::default()
.build("ws://localhost:9944")
.and_then(|client| remove_all_extrinsics(client))
.await
}

/// Remove all pending extrinsics from the node.
Expand All @@ -47,17 +47,19 @@ fn main() -> Result<(), RpcError> {
///
/// As the result of running the code the entire content of the transaction pool is going
/// to be removed and the extrinsics are going to be temporarily banned.
fn remove_all_extrinsics(
client: AuthorClient<Hash, Hash>,
) -> impl Future<Output = Result<(), RpcError>> {
client
.pending_extrinsics()
.and_then(move |pending| {
client.remove_extrinsic(
pending.into_iter().map(|tx| ExtrinsicOrHash::Extrinsic(tx.into())).collect(),
)
})
.map_ok(|removed| {
println!("Removed extrinsics: {:?}", removed);
})
async fn remove_all_extrinsics<C>(client: C) -> Result<(), Error>
where
C: AuthorApiClient<Hash, Hash> + Sync,
{
let pending_exts = client.pending_extrinsics().await?;
let removed = client
.remove_extrinsic(
pending_exts
.into_iter()
.map(|tx| ExtrinsicOrHash::Extrinsic(tx.into()))
.collect(),
)
.await?;
println!("Removed extrinsics: {:?}", removed);
Ok(())
}
249 changes: 0 additions & 249 deletions client/rpc-servers/src/middleware.rs

This file was deleted.

2 changes: 1 addition & 1 deletion utils/frame/rpc/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.3.16"
jsonrpc-client-transports = { version = "18.0.0", features = ["http"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "types"] }
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde = "1"
frame-support = { version = "4.0.0-dev", path = "../../../../frame/support" }
Expand Down
Loading