Skip to content

Commit

Permalink
REVM: FFI cheatcode updates (#955)
Browse files Browse the repository at this point in the history
* feat: only strip 0x in ffi output if present

Ports #904

* Update forge/src/executor/inspector/cheatcodes/ext.rs

Co-authored-by: Georgios Konstantopoulos <[email protected]>
  • Loading branch information
onbjerg and gakonst committed Mar 21, 2022
1 parent d33f1ec commit 8a57471
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion forge/src/executor/inspector/cheatcodes/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ fn ffi(args: &[String]) -> Result<Bytes, Bytes> {
.map_err(|err| err.to_string().encode())?
.stdout;
let output = unsafe { std::str::from_utf8_unchecked(&output) };
let decoded = hex::decode(&output.trim()[2..]).map_err(|err| err.to_string().encode())?;
let decoded = hex::decode(&output.trim().strip_prefix("0x").unwrap_or(output))
.map_err(|err| err.to_string().encode())?;

Ok(abi::encode(&[Token::Bytes(decoded.to_vec())]).into())
}
Expand Down

0 comments on commit 8a57471

Please sign in to comment.