Skip to content

Commit

Permalink
Fix trace error when stepping with return (#417)
Browse files Browse the repository at this point in the history
* fix: trace err when stepping with return

* fix: trace err when stepping with return

* fix: trace err when stepping with return
  • Loading branch information
jacob-chia authored Jan 3, 2024
1 parent fc8236d commit d6a0dab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/evm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ impl BoxedABI {

pub fn to_colored_string(&self) -> String {
if let Some(fn_sig) = self.get_func_signature() {
let fn_name = fn_sig.split('(').next().unwrap();
let mut args: String = self.b.to_colored_string();
let fn_name = fn_sig.split('(').next().unwrap().replace('!', "");
let mut args = self.b.to_colored_string();
if args.is_empty() {
args = "()".to_string();
}
Expand Down
16 changes: 14 additions & 2 deletions src/evm/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ impl ConciseEVMInput {
fn_call.push_str(&self.colored_value());
}

fn_call.push_str(format!("({}", parts[1]).as_str());
if parts.len() == 1 {
fn_call.push_str("()");
} else {
fn_call.push_str(format!("({}", parts[1]).as_str());
}
Some(format!("{}.{}", colored_address(&self.contract()), fn_call))
}

Expand Down Expand Up @@ -469,6 +473,14 @@ impl ConciseEVMInput {
))
}

#[allow(dead_code)]
#[inline]
fn as_stepping_with_return(&self, indent: &str, tree_level: i32) -> String {
// `receive()` or `fallback()`
let fn_call = self.pretty_txn().expect("Failed to print stepping with return");
format!("{}├─[{}] {}", indent, tree_level, fn_call)
}

#[inline]
fn append_liquidation(&self, indent: String, call: String) -> String {
if self.liquidation_percent == 0 || unsafe { !CAN_LIQUIDATE } {
Expand Down Expand Up @@ -910,7 +922,7 @@ impl ConciseSerde for ConciseEVMInput {

// Stepping with return
if self.step {
let res = format!("{}└─ ← ()", indent.clone());
let res = self.as_stepping_with_return(&indent, tree_level);
return self.append_liquidation(indent, res);
}

Expand Down

0 comments on commit d6a0dab

Please sign in to comment.