-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ethers-v5] Add initial support for custom errors #682
base: master
Are you sure you want to change the base?
Conversation
|
I think what we'd want here is to cast the ErrorFragment to a typed version of the error |
Related: #667 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable. I am personally not a huge fan of custom errors and furthermore, ethersjs support is kinda minimal but the PR looks good!
Can you try fixing CI?
CI test(14.x) the test was failed |
@krzkaczor out of interest - what's the reasoning for not being a fan of custom errors? It feels like they provide a better opportunity to handle errors in clients, and can also reduce bytecode in deployed contracts. But i'm interested in any downsides too before using in a project |
Error: Process completed with exit code 1. |
This would be an awesome improvement for typechain and the web3 developer experience overall IMO. Really looking forward to see this one merged. Would also be interested in arguments against it, @krzkaczor. |
Would love to see this merged, will unblock an issue with hardhat not having access to the errors in the interface provided by typechain and therefore not being able to use assertion helpers such as |
@fredlacs @krzkaczor Is this pull request abandoned? Anything others can do to take it over the finish line? |
+1 for this feature. Can someone please re-trigger CI? The logs for last CI run are too old and disappeared. |
Having support for custom error in Typechain would be indeed very useful. |
@fredlacs @krzkaczor Poking again, since it's been more than a year since this PR has been posted and issue #667 has been raised. |
+1 for this feature. |
Any updates? |
This PR adds initial support for handling custom errors with Typechain.
Still WIP but opening a draft PR to be able to get input from others on the approach (currently heavily inspired on #457).
The idea here is to be able to handle errors in js/ts more cleanly when interacting with the chain.
Although the functionality isn't here yet, it would be cool to be able to use these to have cleaner try catches when doing interactions with ethersjs
The current setup returns "undefined" for the error objects but is inspired in this. A couple alternatives on how this could work (ie could rely on ethers and upstream something there or could just have a separate entrypoint). That said, I think only the typed error object exports themselves are already useful, could also have a utility function to get the signature / encode expected values