Skip to content

Commit

Permalink
feat: Add trace_raw_transaction and trace_replay_block_transactions (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebolon authored and ben186 committed Jul 27, 2024
1 parent 41a09c4 commit f2e49ff
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion crates/provider/src/ext/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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, TraceType};
use alloy_rpc_types_trace::parity::{
LocalizedTransactionTrace, TraceResults, TraceResultsWithTransactionHash, TraceType,
};
use alloy_transport::{Transport, TransportResult};

/// List of trace calls for use with [`TraceApi::trace_call_many`]
Expand Down Expand Up @@ -47,6 +49,13 @@ where
hash: TxHash,
) -> TransportResult<Vec<LocalizedTransactionTrace>>;

/// Trace the given raw transaction.
async fn trace_raw_transaction(
&self,
data: &[u8],
trace_type: &[TraceType],
) -> TransportResult<TraceResults>;

/// Trace all transactions in the given block.
///
/// # Note
Expand All @@ -63,6 +72,13 @@ where
hash: TxHash,
trace_type: &[TraceType],
) -> TransportResult<TraceResults>;

/// Replays all transactions in the given block.
async fn trace_replay_block_transactions(
&self,
block: BlockNumberOrTag,
trace_type: &[TraceType],
) -> TransportResult<Vec<TraceResultsWithTransactionHash>>;
}

#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
Expand Down Expand Up @@ -96,6 +112,14 @@ where
self.client().request("trace_transaction", (hash,)).await
}

async fn trace_raw_transaction(
&self,
data: &[u8],
trace_type: &[TraceType],
) -> TransportResult<TraceResults> {
self.client().request("trace_rawTransaction", (data, trace_type)).await
}

async fn trace_block(
&self,
block: BlockNumberOrTag,
Expand All @@ -110,6 +134,14 @@ where
) -> TransportResult<TraceResults> {
self.client().request("trace_replayTransaction", (hash, trace_type)).await
}

async fn trace_replay_block_transactions(
&self,
block: BlockNumberOrTag,
trace_type: &[TraceType],
) -> TransportResult<Vec<TraceResultsWithTransactionHash>> {
self.client().request("trace_replayBlockTransactions", (block, trace_type)).await
}
}

#[cfg(test)]
Expand Down

0 comments on commit f2e49ff

Please sign in to comment.