From 6fc30d4ae5acb7058946f419f341ad9631692043 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 13 Jul 2023 23:52:21 +0200 Subject: [PATCH] fix: add missing null check --- crates/rpc/rpc-types/src/eth/trace/geth/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 092efa438559..eb9a33acd28c 100644 --- a/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs +++ b/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs @@ -209,6 +209,9 @@ impl GethDebugTracerConfig { /// Returns the [CallConfig] if it is a call config. pub fn into_call_config(self) -> Result { + if self.0.is_null() { + return Ok(Default::default()) + } self.from_value() } @@ -219,6 +222,9 @@ impl GethDebugTracerConfig { /// Returns the [PreStateConfig] if it is a call config. pub fn into_pre_state_config(self) -> Result { + if self.0.is_null() { + return Ok(Default::default()) + } self.from_value() } } @@ -370,6 +376,18 @@ fn serialize_string_storage_map_opt( mod tests { use super::*; + #[test] + fn test_tracer_config() { + let s = "{\"tracer\": \"callTracer\"}"; + let opts = serde_json::from_str::(s).unwrap(); + assert_eq!( + opts.tracer, + Some(GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer)) + ); + let _call_config = opts.tracer_config.clone().into_call_config().unwrap(); + let _prestate_config = opts.tracer_config.into_pre_state_config().unwrap(); + } + #[test] fn test_memory_capture() { let mut config = GethDefaultTracingOptions::default();