Skip to content

Commit d90e997

Browse files
fmorisanklkvr
andauthored
fix(cheatcodes): fail when trying to parse malformatted strings as addresses (#8779)
* fix(cheatcodes): fail when trying to parse malformatted strings as addresses * test: check non-address and badly checksummed addresses * fix: add check for address parsing when input is one-off * fix: do not error out on non-checksummed addresses * fix: remove custom address validation on typed json parsing * fix: change error message displayed on address parsing failure Co-authored-by: Arsenii Kulikov <[email protected]> --------- Co-authored-by: Arsenii Kulikov <[email protected]>
1 parent 386ca06 commit d90e997

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crates/cheatcodes/src/json.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ pub(super) fn json_value_to_token(value: &Value) -> Result<DynSolValue> {
569569
Value::String(string) => {
570570
if let Some(mut val) = string.strip_prefix("0x") {
571571
let s;
572+
if val.len() == 39 {
573+
return Err(format!("Cannot parse \"{val}\" as an address. If you want to specify address, prepend zero to the value.").into())
574+
}
572575
if val.len() % 2 != 0 {
573576
s = format!("0{val}");
574577
val = &s[..];

0 commit comments

Comments
 (0)