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 error_code decoding #1758

Merged
merged 1 commit into from
May 4, 2024
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
2 changes: 1 addition & 1 deletion brownie/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def decode_typed_error(data: str) -> str:
selector = data[:10]
if selector == "0x4e487b71":
# special case, solidity compiler panics
error_code = int(data[4:].hex(), 16)
error_code = int(HexBytes(data[10:]).hex(), 16)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a safer approach, in some cases the returned data is already formatted to HexBytes. Not sure why it's inconsistent to begin with..

Suggested change
error_code = int(HexBytes(data[10:]).hex(), 16)
error_code = int(HexBytes(data)[4:].hex(), 16)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh wait i didn't zoom out enough... your approach is correct

return SOLIDITY_ERROR_CODES.get(error_code, f"Unknown compiler Panic: {error_code}")
if selector in _errors:
types_list = get_type_strings(_errors[selector]["inputs"])
Expand Down