From 5928b8ff5bafa9ee749a48fe22e8dd1f4ae66cc8 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Tue, 24 Aug 2021 21:12:29 +0000 Subject: [PATCH] fix: hardhat revert reasons middleware --- brownie/network/middlewares/hardhat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brownie/network/middlewares/hardhat.py b/brownie/network/middlewares/hardhat.py index c57eb943d..8106da689 100644 --- a/brownie/network/middlewares/hardhat.py +++ b/brownie/network/middlewares/hardhat.py @@ -1,3 +1,4 @@ +import re from typing import Callable, Dict, List, Optional from web3 import Web3 @@ -35,6 +36,8 @@ def process_request(self, make_request: Callable, method: str, params: List) -> data.update({"error": "revert", "reason": None}) elif message.startswith("revert"): data.update({"error": "revert", "reason": message[7:]}) + elif "reverted with reason string '" in message: + data.update(error="revert", reason=re.findall(".*?'(.*)'$", message)[0]) else: data["error"] = message return result