diff --git a/crates/rpc/rpc-types/src/eth/trace/geth/call.rs b/crates/rpc/rpc-types/src/eth/trace/geth/call.rs index 636bc19c5..00e605043 100644 --- a/crates/rpc/rpc-types/src/eth/trace/geth/call.rs +++ b/crates/rpc/rpc-types/src/eth/trace/geth/call.rs @@ -51,6 +51,20 @@ pub struct CallConfig { pub with_log: Option, } +impl CallConfig { + /// Sets the only top call flag + pub fn only_top_call(mut self) -> Self { + self.only_top_call = Some(true); + self + } + + /// Sets the with log flag + pub fn with_log(mut self) -> Self { + self.with_log = Some(true); + self + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs b/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs index 752a0c5be..ec1139f2e 100644 --- a/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs +++ b/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs @@ -4,7 +4,7 @@ use crate::{state::StateOverride, BlockOverrides}; use reth_primitives::{Bytes, B256, U256}; use serde::{de::DeserializeOwned, ser::SerializeMap, Deserialize, Serialize, Serializer}; -use std::collections::BTreeMap; +use std::{collections::BTreeMap, time::Duration}; // re-exports pub use self::{ @@ -186,6 +186,12 @@ pub enum GethDebugTracerType { JsTracer(String), } +impl From for GethDebugTracerType { + fn from(value: GethDebugBuiltInTracerType) -> Self { + GethDebugTracerType::BuiltInTracer(value) + } +} + /// Configuration of the tracer /// /// This is a simple wrapper around serde_json::Value. @@ -264,6 +270,34 @@ pub struct GethDebugTracingOptions { pub timeout: Option, } +impl GethDebugTracingOptions { + /// Sets the tracer to use + pub fn with_tracer(mut self, tracer: GethDebugTracerType) -> Self { + self.tracer = Some(tracer); + self + } + + /// Sets the timeout to use for tracing + pub fn with_timeout(mut self, duration: Duration) -> Self { + self.timeout = Some(format!("{}ms", duration.as_millis())); + self + } + + /// Configures a [CallConfig] + pub fn call_config(mut self, config: CallConfig) -> Self { + self.tracer_config = + GethDebugTracerConfig(serde_json::to_value(config).expect("is serializable")); + self + } + + /// Configures a [PreStateConfig] + pub fn prestate_config(mut self, config: PreStateConfig) -> Self { + self.tracer_config = + GethDebugTracerConfig(serde_json::to_value(config).expect("is serializable")); + self + } +} + /// Default tracing options for the struct looger. /// /// These are all known general purpose tracer options that may or not be supported by a given