Replace #[async_trait] with ->imp for traits in rpc_testing_util (#6757)

This commit is contained in:
Abner Zheng
2024-02-24 00:45:38 +08:00
committed by GitHub
parent 34402caeee
commit be1ebeea62
4 changed files with 10 additions and 14 deletions

1
Cargo.lock generated
View File

@@ -6732,7 +6732,6 @@ dependencies = [
name = "reth-rpc-api-testing-util"
version = "0.1.0-alpha.19"
dependencies = [
"async-trait",
"futures",
"jsonrpsee",
"reth-primitives",

View File

@@ -18,7 +18,6 @@ reth-rpc-types.workspace = true
reth-rpc-api = { workspace = true, features = ["client"] }
# async
async-trait.workspace = true
futures.workspace = true
# misc

View File

@@ -12,9 +12,11 @@ use reth_rpc_types::{
TransactionRequest,
};
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
const NOOP_TRACER: &str = include_str!("../assets/noop-tracer.js");
const JS_TRACER_TEMPLATE: &str = include_str!("../assets/tracer-template.js");
@@ -26,24 +28,23 @@ pub type DebugTraceBlockResult =
Result<(Vec<TraceResult<GethTrace, String>>, BlockId), (RpcError, BlockId)>;
/// An extension trait for the Trace API.
#[async_trait::async_trait]
pub trait DebugApiExt {
/// The provider type that is used to make the requests.
type Provider;
/// Same as [DebugApiClient::debug_trace_transaction] but returns the result as json.
async fn debug_trace_transaction_json(
fn debug_trace_transaction_json(
&self,
hash: B256,
opts: GethDebugTracingOptions,
) -> Result<serde_json::Value, jsonrpsee::core::Error>;
) -> impl Future<Output = Result<serde_json::Value, jsonrpsee::core::Error>> + Send;
/// Trace all transactions in a block individually with the given tracing opts.
async fn debug_trace_transactions_in_block<B>(
fn debug_trace_transactions_in_block<B>(
&self,
block: B,
opts: GethDebugTracingOptions,
) -> Result<DebugTraceTransactionsStream<'_>, jsonrpsee::core::Error>
) -> impl Future<Output = Result<DebugTraceTransactionsStream<'_>, jsonrpsee::core::Error>> + Send
where
B: Into<BlockId> + Send;
@@ -59,21 +60,20 @@ pub trait DebugApiExt {
B: Into<BlockId> + Send;
/// method for debug_traceCall
async fn debug_trace_call_json(
fn debug_trace_call_json(
&self,
request: TransactionRequest,
opts: GethDebugTracingOptions,
) -> Result<serde_json::Value, jsonrpsee::core::Error>;
) -> impl Future<Output = Result<serde_json::Value, jsonrpsee::core::Error>> + Send;
/// method for debug_traceCall using raw JSON strings for the request and options.
async fn debug_trace_call_raw_json(
fn debug_trace_call_raw_json(
&self,
request_json: String,
opts_json: String,
) -> Result<serde_json::Value, RpcError>;
) -> impl Future<Output = Result<serde_json::Value, RpcError>> + Send;
}
#[async_trait::async_trait]
impl<T: DebugApiClient + Sync> DebugApiExt for T
where
T: EthApiClient,

View File

@@ -46,7 +46,6 @@ pub type TraceFilterResult =
pub type TraceCallResult = Result<TraceResults, (RpcError, TraceCallRequest)>;
/// An extension trait for the Trace API.
#[async_trait::async_trait]
pub trait TraceApiExt {
/// The provider type that is used to make the requests.
type Provider;
@@ -236,7 +235,6 @@ impl<'a> std::fmt::Debug for ReplayTransactionStream<'a> {
}
}
#[async_trait::async_trait]
impl<T: TraceApiClient + Sync> TraceApiExt for T {
type Provider = T;