-
Notifications
You must be signed in to change notification settings - Fork 254
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
NEP141: safe maths fixes #830
Conversation
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.
Do you mind having all errors be some constant (or just based on a function) which indicates the overflow. I would assume the compiler can optimize away the duplicates, but also makes the code cleaner.
self.total_supply | ||
.checked_sub(refund_amount) | ||
.unwrap_or_else(|| env::panic_str("Total supply overflow")); |
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.
this isn't subtracting from self.total_supply
, so this is a bug
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.
Good catch, fixed in 261efd0.
Please note this actually also means that this part is not enough covered with the unit tests.
Fixes sdk-docs#75