Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add trace_filter method #946

Merged
merged 5 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions crates/provider/src/ext/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use crate::{Provider, RpcWithBlock};
use alloy_eips::BlockNumberOrTag;
use alloy_network::Network;
use alloy_primitives::TxHash;
use alloy_rpc_types_trace::parity::{
LocalizedTransactionTrace, TraceResults, TraceResultsWithTransactionHash, TraceType,
use alloy_rpc_types_trace::{
filter::TraceFilter,
parity::{LocalizedTransactionTrace, TraceResults, TraceResultsWithTransactionHash, TraceType},
};
use alloy_transport::{Transport, TransportResult};

Expand Down Expand Up @@ -56,6 +57,12 @@ where
trace_type: &[TraceType],
) -> TransportResult<TraceResults>;

/// Traces matching given filter.
async fn trace_filter(
&self,
tracer: &TraceFilter,
) -> TransportResult<Vec<LocalizedTransactionTrace>>;

/// Trace all transactions in the given block.
///
/// # Note
Expand Down Expand Up @@ -120,6 +127,13 @@ where
self.client().request("trace_rawTransaction", (data, trace_type)).await
}

async fn trace_filter(
&self,
tracer: &TraceFilter,
) -> TransportResult<Vec<LocalizedTransactionTrace>> {
self.client().request("trace_filter", (tracer,)).await
}

async fn trace_block(
&self,
block: BlockNumberOrTag,
Expand Down