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

Fix create2 suffix regex #5802

Merged
merged 1 commit into from
Sep 9, 2023
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