Closed dmytrotkk closed 3 years ago
Thanks for the report - Ganache indeed was not part of my test set. Will jump in here this afternoon.
@marcgarreau Here's the proposed fix:
if not isinstance(response['error'], dict):
raise ValueError('Error expected to be a dict')
data = response['error'].get('data', '')
# Ganache case:
if isinstance(data, dict) and data.get('stack'):
revert_msg = 'revert '
reason = data['stack'][data['stack'].find(revert_msg)+len(revert_msg):data['stack'].rfind('\\n')]
raise SolidityError(f'execution reverted: {reason}')
# Parity/OpenEthereum case:
if data.startswith('Reverted '):
Should I submit the PR or you will work on that?
PR would be great, thanks! The reason parsing logic is hairy, but I don't think there will be any particularly elegant/non-brittle solution. Can bikeshed in the PR.
@marcgarreau actually I decided to drop parsing logic and just return revert reason as is.
Encountering the same issue, also when using ganache. Before, fixes are patched, is there any workaround for web3.py usage? Thanks.
Closed in #1794. Thanks @dmitry-tk!
pip freeze
outputWhat was wrong?
The latest version of
web3py
was unable to handle Solidity revert thrown byganache
(Docker containertrufflesuite/ganache-cli:beta
):How can it be fixed?
Ganache response format looks like that:
And that's how
web3py
tries to parse error section:But
error
field inganache
response isdict
so this line fails. Additional handler forganache
should be added to this section.