Skip to content

Commit 862d70e

Browse files
committed
Fix auth translation
1 parent dea4abe commit 862d70e

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/cli/fuzzer_bridge/blocktest_builder.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,25 @@ def _parse_authorization_list(
4444
"""Parse authorization list from fuzzer data."""
4545
auth_tuples = []
4646
for auth_data in auth_list_data:
47-
# Handle numeric fields which might be in scientific notation
48-
chain_id = HexNumber(int(auth_data.get("chainId", 0)))
49-
nonce = HexNumber(int(auth_data.get("nonce", 0)))
50-
51-
# Handle v, r, s which might be in scientific notation (floating point)
52-
v = HexNumber(int(float(auth_data.get("v", 0))))
53-
r = HexNumber(int(float(auth_data.get("r", 0))))
54-
s = HexNumber(int(float(auth_data.get("s", 0))))
47+
# Handle values that could be hex strings or numeric (including scientific notation)
48+
def parse_value(val: Any, default: Any = 0) -> HexNumber:
49+
if val is None:
50+
val = default
51+
if isinstance(val, str) and val.startswith("0x"):
52+
# Already a hex string, HexNumber will handle it correctly
53+
return HexNumber(val)
54+
elif isinstance(val, str):
55+
# Scientific notation string like "1.0e+18"
56+
return HexNumber(int(float(val)))
57+
else:
58+
# Direct numeric value
59+
return HexNumber(int(val) if not isinstance(val, float) else int(val))
60+
61+
chain_id = parse_value(auth_data.get("chainId"))
62+
nonce = parse_value(auth_data.get("nonce"))
63+
v = parse_value(auth_data.get("v"))
64+
r = parse_value(auth_data.get("r"))
65+
s = parse_value(auth_data.get("s"))
5566

5667
auth_tuples.append(
5768
AuthorizationTuple(

0 commit comments

Comments
 (0)