dethcrypto / dethcrypto/TypeChain

[Feature Request] Support for Solidity v0.8.4 Custom Errors

Open
#667 3 comments 9 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

Greetings,
From the release of Solidity 0.8.4 there's a new preferred way of reporting failures by using [Custom Errors](https://blog.soliditylang.org/2021/04/21/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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.