-
Notifications
You must be signed in to change notification settings - Fork 342
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
Thoughts on creating a "StdConstants" contract? #267
Comments
Hmm, what's the rationale for it? I would lean towards keeping constants in Currently all |
Well, simply being able to inherit from Good point re convention, I didn't consider that. I guess, I don't have a strong opinion here. Copy-pasting the constants that I need is not a big chore, not at all, so I'm happy to close this as not planned if you can't think of any easy solution that would at the same not break the contract independence convention and would make it possible to re-use the constants in |
There are a few constants from |
I want to bump this issue, but I think that This will simplify composition because the user won't need to complicate their inheritance tree just to access a few constants. It will enable massive constants deduplication in forge-std itself without introducing artificial dependencies between components. E.g. |
I do like the idea of having them as free constants. The main blocker there is forge-std currently supports as early as solidity 0.6.2, but I believe free functions (and presumably free constants) were not introduced until 0.7.x. I think we could add them as it's own file with it's own pragma, and because nothing in forge-std inherits or imports it, it shouldn't break the codebase of anyone on older versions, though I would want to confirm to be sure solidity doesn't end up compiling it for some reason cc @klkvr for other thoughts or considerations |
if it would be just a standalone file not imported by any of forge-std components it should be OK another approach could be to add |
That's true, I am equally supportive of a library, which does have the nice side effect of free namespacing of the constants. My nit there would be to name it |
I agree that a library should be as flexible and non-intrusive as free constants. It will be usable in all kinds of functions, including library functions and free functions, and should be even usable in initialization of all kinds of constants. I especially like that it will contain the namespace avoiding pollution. Writing something like |
Would you be open to a PR that separated the constants defined in
CommonBase
in a separate contractStdConstants
, whichCommonBase
would then inherit from?The text was updated successfully, but these errors were encountered: