-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Reason strings for all require statements #1709
Comments
@nventuro I have started working on it :) |
@nventuro what about ERC721. I think it should be the same as |
@nventuro what about other requtire statement other than require(owner != address(0)). Like require(_exists(tokenId)) Should I write token doesn't exist? |
I think so, yes (unless we can also add |
I thought we had agreed not to use the word "null" for the zero address. It's a bit confusing because in the context of Ethereum transactions a null value in the |
|
What about just "zero" or "empty"? |
What about 'empty or zero transaction recipient'. |
* Error handling in ERC20 and ERC721 * Added message string for require. * Fixed solhint errors. * Updated PR as per issue #1709 * changes as per #1709 and openzeppelin forum. * Changes in require statement * Changes in require statement * build pipeline fix * Changes as per @nventuro's comment. * Update revert reason strings. * Fianal update of revert reason strings. * WIP: Updating reason strings in test cases * WIP: Added changes to ERC20 and ERC721 * Fixes linting errors in *.tes.js files * Achieved 100% code coverage * Updated the test cases with shouldFail.reverting.withMessage() * Fix package-lock. * address review comments * fix linter issues * fix remaining revert reasons
Closed via #1704. |
Supersedes #888.
This is way overdue, but a big push during these last couple weeks for it took it to the point where we're now comfortable to include it in the library.
There was some discussion about formatting in our forum, which culminated in this post, which has some rough guidelines (pasting at the end of this message for reference).
I also did some testing and verified that we can safely add revert reasons to all of OpenZeppelin's contracts, without them going over the gas limit for a block. The situation may differ for setups with particularly large contracts, but most users should be unaffected. Nonetheless, I opened an issue on the Solidity repo suggesting they provide a way to remove these strings, so that they can be stripped for production builds, if desired.
Our goal is to have all
require
statements also include a human-readable revert reason, unique across all of OpenZeppelin. Contributions are welcome! Please also update the tests with theshouldFail.reverting.withMessage
test helper, so that we can both be sure of the actual revert reason, and prevent regression errors by having these messages change.Rough guidelines:
The text was updated successfully, but these errors were encountered: