Skip to content

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jul 21, 2024
1 parent 8776193 commit d16203f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions crates/revmc-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ pub fn read_code(code: Option<&str>, code_path: Option<&Path>) -> Result<Vec<u8>
pub fn read_code_string(contents: &[u8], ext: Option<&str>) -> Result<Vec<u8>> {
let has_prefix = contents.starts_with(b"0x") || contents.starts_with(b"0X");
let is_hex = ext != Some("bin") && (ext == Some("hex") || has_prefix);
let utf8 = || std::str::from_utf8(contents).wrap_err("given code is not valid UTF-8");
let utf8 =
|| std::str::from_utf8(contents).wrap_err("given code is not valid UTF-8").map(str::trim);
if is_hex {
let input = utf8()?.trim();
let input = utf8()?;
let mut lines = input.lines().map(str::trim);
let first_line = lines.next().unwrap_or_default();
hex::decode(first_line).wrap_err("given code is not valid hex")
} else if ext == Some("bin") || !contents.is_ascii() {
Ok(contents.to_vec())
} else if ext == Some("evm") || contents.is_ascii() {
} else if ext == Some("evm") {
parse_evm_dsl(utf8()?)
} else if contents.is_ascii() {
let s = utf8()?;
parse_evm_dsl(s).or_else(|_| hex::decode(s).wrap_err("given code is not valid hex"))
} else {
Err(eyre!("could not determine bytecode type"))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revmc/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ tests! {
kind: revm_interpreter::EOFCreateKind::Opcode {
initcode: primitives::Eof::decode(eof_subcontainer()).unwrap(),
input: 0x69_U256.to_be_bytes::<32>().into(),
created_address: DEF_ADDR.create2_from_code(0x70_U256.to_be_bytes::<32>(), &eof_subcontainer()),
created_address: DEF_ADDR.create2_from_code(0x70_U256.to_be_bytes::<32>(), eof_subcontainer()),
},
}),
},
Expand Down

0 comments on commit d16203f

Please sign in to comment.