Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FFI hex string decoding more flexible #904

Merged
merged 2 commits into from
Mar 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions evm-adapters/src/sputnik/cheatcodes/cheatcode_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,15 @@ 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 mut output = output.trim();
//remove "0x" only if present
if output.starts_with("0x") {
output = &output[2..]
}
gakonst marked this conversation as resolved.
Show resolved Hide resolved
//decode hex
let decoded = match hex::decode(output) {
Ok(res) => res,
Err(err) => return evm_error(&err.to_string()),
};
Expand Down