Skip to content

Commit

Permalink
🐛 Workaround for Anvil constructor revert missing data bug
Browse files Browse the repository at this point in the history
  • Loading branch information
michprev committed Jul 22, 2023
1 parent 28baec7 commit 0b7ba19
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions woke/development/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,20 @@ def raw_error(self) -> Optional[UnknownTransactionRevertedError]:

chain_interface = self._chain.chain_interface

if isinstance(chain_interface, AnvilChainInterface):
assert self._tx_receipt is not None
# due to a bug, Anvil does not return revert data for failed contract creations
# "contractAddress" key is always present, so the first if branch is never taken
# keep this code for when the bug is fixed
if (
isinstance(chain_interface, AnvilChainInterface)
and "contractAddress" not in self._tx_receipt
):
self._fetch_trace_transaction()
assert self._trace_transaction is not None
revert_data = bytes.fromhex(
self._trace_transaction[0]["result"]["output"][2:]
)
elif isinstance(chain_interface, GanacheChainInterface):
elif isinstance(chain_interface, (AnvilChainInterface, GanacheChainInterface)):
self._fetch_debug_trace_transaction()
assert self._debug_trace_transaction is not None

Expand Down

0 comments on commit 0b7ba19

Please sign in to comment.