ape
ape copied to clipboard
Catch and re-throw w/ `CustomError` if `ErrorABI` match detected
Overview
If an error with a contract is encoded using Solidity's custom error feature, currently ape displays this message:
ERROR: (ContractLogicError) custom error e0b4aa5a:00000000000000000000000000000000…00000000000000000000000000030931 (64 bytes)
This is not enough to actually be able to decode into a CustomError object (available from ContractInstance._errors_)
Further, if the data is available, there is not an easy way to decode that exception from bytes back into the custom error type
Specification
Add method to catch a contract logic error and instead generate a CustomError type that gets re-thrown
Dependencies
This may impact/simplify the custom error reverts checking logic that the testing-only reverts manager employs
We should be doing this already. What provider are you using? (changed to bug because this feature exists and works for many cases)
@wavey0x or @fp-crypto had this issue I think
@wavey0x or @fp-crypto had this issue I think
I try to repro tomorrow with providers i know they use but otherwise that is the most desired info I need as each provider shows the hex different and we have to make sure we are passing expected-styles to compiler.enrich_error for it to work, lots of players in this game!
I have tried on:
- foundry
- eth tester
- geth (dev)
- hardhat
- ethereum:local:http://127.0.0.1:8545 (pointed it various local nodes)
using solidity v0.8.24... and I am getting custom errors just fine.
more info please :))) Ill keep trying to repro.
here we encode WRAP_ETH(dev, 1 ether). the first one should work, the second should fail with InsufficientETH().
from ape import Contract, accounts
def main():
universal_router = Contract('0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD')
dev = accounts.test_accounts[0]
for value in [10**18, 0]:
receipt = universal_router.execute('0x0b', ['0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000de0b6b3a7640000'], sender=dev, value=value)
receipt.show_trace()
ape run bug --network :mainnet-fork
it shows this for me