-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1064 from skellet0r/feat/upgrade-web3
Upgrade web3 dependency
- Loading branch information
Showing
41 changed files
with
399 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Callable, Dict, List, Optional | ||
|
||
from web3 import Web3 | ||
|
||
from brownie.network.middlewares import BrownieMiddlewareABC | ||
|
||
|
||
class TxRevertCatcherMiddleware(BrownieMiddlewareABC): | ||
|
||
""" | ||
Middleware to handle reverting transactions, bypasses web3 error formatting. | ||
As of web3.py version 5.13.0, a new error formatting middleware was added by default | ||
`raise_solidity_error_on_revert` which when a `eth_call` or `eth_estimateGas` tx | ||
raises a `ContractLogicError` instead of providing us with an RPCError dictionary. | ||
""" | ||
|
||
@classmethod | ||
def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: | ||
return -1 | ||
|
||
def process_request(self, make_request: Callable, method: str, params: List) -> Dict: | ||
"""Raise a ValueError when RPC.eth_call or RPC.eth_estimateGas errors.""" | ||
result = make_request(method, params) | ||
if method in ("eth_call", "eth_estimateGas"): | ||
if "error" in result: | ||
raise ValueError(result["error"]) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.