Skip to content

Commit e4130b3

Browse files
Merge pull request #1110 from SatoshiAndKin/solidity_0.8.4_errors
don't crash on solidity 0.8.4 typed errors
2 parents ce7ff49 + 3fdd307 commit e4130b3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Fixed subcalls to empty accounts not appearing in the subcalls property of TransactionReceipts ([#1106](https://github.com/eth-brownie/brownie/pull/1106))
1111
- Add support for `POLYGONSCAN_TOKEN` env var ([#1135](https://github.com/eth-brownie/brownie/pull/1135))
1212
- Add Multicall context manager ([#1125](https://github.com/eth-brownie/brownie/pull/1125))
13+
- Add initial support for Solidity 0.8's typed errors ([#1110](https://github.com/eth-brownie/brownie/pull/1110))
1314

1415
### Added
1516
- Added `LocalAccount.sign_message` method to sign `EIP712Message` objects ([#1097](https://github.com/eth-brownie/brownie/pull/1097))

brownie/network/transaction.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,20 @@ def _reverted_trace(self, trace: Sequence) -> None:
652652
if step["op"] == "REVERT" and int(step["stack"][-2], 16):
653653
# get returned error string from stack
654654
data = _get_memory(step, -1)
655-
if data[:4].hex() == "0x4e487b71": # keccak of Panic(uint256)
655+
656+
selector = data[:4].hex()
657+
658+
if selector == "0x4e487b71": # keccak of Panic(uint256)
656659
error_code = int(data[4:].hex(), 16)
657660
if error_code in SOLIDITY_ERROR_CODES:
658661
self._revert_msg = SOLIDITY_ERROR_CODES[error_code]
659662
else:
660663
self._revert_msg = f"Panic (error code: {error_code})"
661-
else:
664+
elif selector == "0x08c379a0": # keccak of Error(string)
662665
self._revert_msg = decode_abi(["string"], data[4:])[0]
666+
else:
667+
# TODO: actually parse the data
668+
self._revert_msg = f"typed error: {data.hex()}"
663669

664670
elif self.contract_address:
665671
self._revert_msg = "invalid opcode" if step["op"] == "INVALID" else ""

0 commit comments

Comments
 (0)