TypeChain
TypeChain copied to clipboard
[Feature Request] Support for Solidity v0.8.4 Custom Errors
Greetings, From the release of Solidity 0.8.4 there's a new preferred way of reporting failures by using Custom Errors when the transaction reverts.
Although full support seems to still be in the works on major Web3 libraries, it would still be nice if TypeChain could generate some types for these. As far I could tell, the current generated .ts files don't create anything related to errors defined in the smart contract.
This kind of feature would be useful for facilitating testing of these smart contracts. In my experience, the current not-so-elegant way to test custom errors is done by hard-coding the custom error names as strings:
- MyContract:
error MyError(); - Test:
await expect(tx).to.revertWith("MyError");
This is where I think TypeChain could potentially make this clearer and streamlined by at least generating the error names:
- Test:
await expect(tx).to.revertWith(myContract.MyError);or similar
This would be super useful as we find using errors much nicer than arbitrary strings or "string error codes" which we need to track outside of the code in a doc.
Definitely large +1
@fredlacs made a PR for this. please take a look: https://github.com/dethcrypto/TypeChain/pull/682
Is there any update?