Skip to content

Commit

Permalink
Make FFI hex string decoding more flexible (#904)
Browse files Browse the repository at this point in the history
* fix

* Update evm-adapters/src/sputnik/cheatcodes/cheatcode_handler.rs

Co-authored-by: Frankie <[email protected]>
Co-authored-by: Georgios Konstantopoulos <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2022
1 parent 9cf3150 commit 1d31ecb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions evm-adapters/src/sputnik/cheatcodes/cheatcode_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,11 @@ impl<'a, 'b, B: Backend, P: PrecompileSet> CheatcodeStackExecutor<'a, 'b, B, P>
Err(err) => return evm_error(&err.to_string()),
};

// get the hex string & decode it
// get the hex string
let output = unsafe { std::str::from_utf8_unchecked(&output) };
let decoded = match hex::decode(&output.trim()[2..]) {
let output = output.strip_prefix("0x").unwrap_or(output);
//decode hex
let decoded = match hex::decode(output) {
Ok(res) => res,
Err(err) => return evm_error(&err.to_string()),
};
Expand Down

0 comments on commit 1d31ecb

Please sign in to comment.