From 0b7ba19ad36d4f65aa6967e861e22fa319d210f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20P=C5=99evr=C3=A1til?= Date: Sat, 22 Jul 2023 21:14:23 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Workaround=20for=20Anvil=20const?= =?UTF-8?q?ructor=20revert=20missing=20data=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- woke/development/transactions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/woke/development/transactions.py b/woke/development/transactions.py index 7ffdb1b05..753f3bab0 100644 --- a/woke/development/transactions.py +++ b/woke/development/transactions.py @@ -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