Skip to content
Merged
Changes from all commits
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
15 changes: 12 additions & 3 deletions crates/cast/bin/cmd/create2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ impl Create2Args {
));
}
if let Some(suffix) = ends_with {
regexs.push(
(get_regex_hex_string(suffix).wrap_err("invalid suffix hex provided")?).to_string(),
);
regexs.push(format!(
r"{}$",
get_regex_hex_string(suffix).wrap_err("invalid prefix hex provided")?
))
}

debug_assert!(
Expand Down Expand Up @@ -204,6 +205,14 @@ mod tests {

assert!(address.starts_with("aaa"));

// odd hex chars with 0x suffix
let args = Create2Args::parse_from(["foundry-cli", "--ends-with", "bb"]);
let create2_out = args.run().unwrap();
let address = create2_out.address;
let address = format!("{address:x}");

assert!(address.ends_with("bb"));

// check fails on wrong chars
let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xerr"]);
let create2_out = args.run();
Expand Down