Skip to content

Commit

Permalink
Remove unneded level of arrays
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Sep 23, 2024
1 parent 0b807d1 commit 3a2d032
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/lib/types/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ pub enum BlockStatus {
#[serde(untagged)]
pub enum CallTracerResultWithNestedResult {
CallTrace(ResultDebugCall),
FlattCallTrace(Vec<DebugCallFlat>),
FlattCallTrace(DebugCallFlat),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
11 changes: 6 additions & 5 deletions core/node/api_server/src/web3/namespaces/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,19 @@ impl DebugNamespace {
.map_err(DalError::generalize)?;

let mut calls = vec![];
let mut flat_calls = vec![];
for (call_trace, hash, index) in call_traces {
match Self::map_call(call_trace, index, hash, options) {
CallTracerResult::CallTrace(call) => calls.push(
CallTracerResultWithNestedResult::CallTrace(ResultDebugCall { result: call }),
),
CallTracerResult::FlattCallTrace(mut call) => flat_calls.append(&mut call),
CallTracerResult::FlattCallTrace(call) => calls.append(
&mut call
.into_iter()
.map(CallTracerResultWithNestedResult::FlattCallTrace)
.collect(),
),
}
}
if calls.is_empty() && !flat_calls.is_empty() {
calls.push(CallTracerResultWithNestedResult::FlattCallTrace(flat_calls))
}

Ok(calls)
}
Expand Down
1 change: 0 additions & 1 deletion core/node/api_server/src/web3/tests/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ impl HttpTest for TraceBlockFlatTest {
else {
unreachable!()
};
let top_level_trace = top_level_trace.first().unwrap();
assert_eq!(top_level_trace.action.from, Address::zero());
assert_eq!(top_level_trace.action.to, BOOTLOADER_ADDRESS);
assert_eq!(
Expand Down

0 comments on commit 3a2d032

Please sign in to comment.