mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
feat(rpc): impl parity trace_transaction (#1765)
This commit is contained in:
@@ -10,6 +10,20 @@ use std::collections::BTreeMap;
|
||||
/// Result type for parity style transaction trace
|
||||
pub type TraceResult = crate::trace::common::TraceResult<TraceOutput, String>;
|
||||
|
||||
// === impl TraceResult ===
|
||||
|
||||
impl TraceResult {
|
||||
/// Wraps the result type in a [TraceResult::Success] variant
|
||||
pub fn parity_success(result: TraceOutput) -> Self {
|
||||
TraceResult::Success { result }
|
||||
}
|
||||
|
||||
/// Wraps the result type in a [TraceResult::Error] variant
|
||||
pub fn parity_error(error: String) -> Self {
|
||||
TraceResult::Error { error }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TraceType {
|
||||
@@ -190,10 +204,18 @@ pub struct TransactionTrace {
|
||||
pub struct LocalizedTransactionTrace {
|
||||
#[serde(flatten)]
|
||||
pub trace: TransactionTrace,
|
||||
/// Transaction index within the block, None if pending.
|
||||
pub transaction_position: Option<usize>,
|
||||
/// Hash of the transaction
|
||||
pub transaction_hash: Option<H256>,
|
||||
pub block_number: U64,
|
||||
pub block_hash: H256,
|
||||
/// Block number the transaction is included in, None if pending.
|
||||
///
|
||||
/// Note: this deviates from <https://openethereum.github.io/JSONRPC-trace-module#trace_transaction> which always returns a block number
|
||||
pub block_number: Option<u64>,
|
||||
/// Hash of the block, if not pending
|
||||
///
|
||||
/// Note: this deviates from <https://openethereum.github.io/JSONRPC-trace-module#trace_transaction> which always returns a block number
|
||||
pub block_hash: Option<H256>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
17
crates/rpc/rpc-types/src/eth/transaction/common.rs
Normal file
17
crates/rpc/rpc-types/src/eth/transaction/common.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
//! Commonly used additional types that are not part of the JSON RPC spec but are often required
|
||||
//! when working with RPC types, such as [Transaction](crate::Transaction)
|
||||
|
||||
use reth_primitives::{TxHash, H256};
|
||||
|
||||
/// Additional fields in the context of a block that contains this transaction.
|
||||
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
|
||||
pub struct TransactionInfo {
|
||||
/// Hash of the transaction.
|
||||
pub hash: Option<TxHash>,
|
||||
/// Index of the transaction in the block
|
||||
pub index: Option<usize>,
|
||||
/// Hash of the block.
|
||||
pub block_hash: Option<H256>,
|
||||
/// Number of the block.
|
||||
pub block_number: Option<u64>,
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
mod common;
|
||||
mod receipt;
|
||||
mod request;
|
||||
mod signature;
|
||||
mod typed;
|
||||
|
||||
pub use common::TransactionInfo;
|
||||
pub use receipt::TransactionReceipt;
|
||||
pub use request::TransactionRequest;
|
||||
pub use signature::Signature;
|
||||
|
||||
Reference in New Issue
Block a user