-
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
Add SafeCast for all possible uintX types #3159
Comments
Hello @k06a and thanks for the suggestion The casting contract contains a lot of code repetition. Ideally, we would have generics (c++ templates) supported by solidity ... but we don't live in that world. So we wait for requests, and we add them one at a time, which we probably both agree is not the right way to do. IMO, these contracts should be generated procedurally, just like I did in this repo a few years ago (https://github.com/Amxx/SolStruct). @frangio would you be open to that idea? |
Yes as long as they are all tested. What would that look like? Do we write a script and then commit the resulting Solidity file to the repository? If we add all of the 32 functions we may want to review the documentation approach. Having virtually the same docstring for all 32 functions just adds noise. |
Just took a look at SolStruct. I wouldn't follow this approach, it's too custom. I think either we use solpp or we just write a simple JavaScript program to generate the code (without using templates). |
Yes, I would have gone for a JS generator. SolStruct was just an example of procedural generation. |
🧐 Motivation
These methods are required when optimizing and tightly packing storage variables. We often use
uint40
oruint48
for time anduint216
/uint208
for the rest slot value,uint112
oruint96
(presented) for storing token amounts etcThe text was updated successfully, but these errors were encountered: