Skip to content

Commit

Permalink
Merge pull request #639 from eth-brownie/fix-call-reverts
Browse files Browse the repository at this point in the history
fix: handle failed calls from geth
  • Loading branch information
iamdefinitelyahuman committed Jun 19, 2020
2 parents 980e574 + 86b8ba1 commit 312d496
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions brownie/network/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,12 @@ def call(self, *args: Tuple, block_identifier: Union[int, str, bytes] = None) ->
except ValueError as e:
raise VirtualMachineError(e) from None

if HexBytes(data)[:4].hex() == "0x08c379a0":
revert_str = eth_abi.decode_abi(["string"], HexBytes(data)[4:])[0]
raise ValueError(f"Call reverted: {revert_str}")
if self.abi["outputs"] and not data:
raise ValueError("No data was returned - the call likely reverted")

return self.decode_output(data)

def transact(self, *args: Tuple) -> TransactionReceiptType:
Expand Down

0 comments on commit 312d496

Please sign in to comment.