-
Notifications
You must be signed in to change notification settings - Fork 366
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
feat: Add StdConstants library #654
Conversation
Edit: It's much worse, it breaks on anything below 0.8.16 which explicitly introduced assignment of library constants to other constants. I guess that the only way forward is to introduce the library and not use it internally until we drastically increase the minimum compiler version. |
2bd69c0
to
842610a
Compare
Hi @CodeSandwich, thanks for your PR Why is inheriting the Given the described limitations I would prefer not duplicating these constants Appreciate the clarifying fix on |
It's discussed in #267. Inheritance is a barrier when accessing these constants, it excludes usage in libraries and free functions, which are excellent ways to create helpers and utilities for tests and scripts. Free constants are another option, but they tend to pollute namespaces and they don't work with Solidity older than 0.7.4. Expressing constants as free functions could work, but they would be clunky they wouldn't work with Solidity older than 0.7.1. |
So what's the verdict, shall we move forward or shall we close this PR? @zerosnacks @mds1 |
I can see the use of this, it being implemented as stated in #267 (comment) and the overhead of maintaining duplicate constant definitions in Base and Constants seems limited and OK. I would prefer renaming |
842610a
to
f96d69b
Compare
Thanks, that's great news. I pushed the renaming to |
f96d69b
to
2a7cd91
Compare
Regarding the failing CI, this should be fixed by pulling from |
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.
Thanks! All LGTM
Duplicating seems reasonable. |
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.
lgtm!
Fixes #267. Gathers up all constants used throughout forge-std in a single library so they are easier to access.
The refactoring around the constants is minimal, it's mostly replacements of arbitrary values with references to the new library. No changes are visible from the outside, the 3 constants removed fromStdUtil
were private. Many more refactorings, like dropping other private constants that are used more than once or are variations abouttype(uintXXX).max
, may be done in separate PRs.