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: trace_call and trace_callMany #277

Merged
merged 3 commits into from
Mar 12, 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
32 changes: 31 additions & 1 deletion crates/provider/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloy_primitives::{
use alloy_rpc_client::{ClientRef, RpcClient, WeakClient};
use alloy_rpc_trace_types::{
geth::{GethDebugTracingOptions, GethTrace},
parity::LocalizedTransactionTrace,
parity::{LocalizedTransactionTrace, TraceResults, TraceType},
};
use alloy_rpc_types::{
state::StateOverride, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag,
Expand Down Expand Up @@ -399,6 +399,36 @@ pub trait Provider<N: Network, T: Transport + Clone = BoxTransport>: Send + Sync
self.client().prepare("eth_createAccessList", (request, block.unwrap_or_default())).await
}

/// Executes the given transaction and returns a number of possible traces.
///
/// # Note
///
/// Not all nodes support this call.
async fn trace_call(
&self,
request: &N::TransactionRequest,
trace_type: &[TraceType],
block: Option<BlockId>,
) -> TransportResult<TraceResults> {
self.client().prepare("trace_call", (request, trace_type, block)).await
}

/// Traces multiple transactions on top of the same block, i.e. transaction `n` will be executed
/// on top of the given block with all `n - 1` transaction applied first.
///
/// Allows tracing dependent transactions.
///
/// # Note
///
/// Not all nodes support this call.
async fn trace_call_many(
&self,
request: &[(N::TransactionRequest, Vec<TraceType>)],
block: Option<BlockId>,
) -> TransportResult<TraceResults> {
self.client().prepare("trace_callMany", (request, block)).await
}

// todo: move to extension trait
/// Parity trace transaction.
async fn trace_transaction(
Expand Down
Loading