Skip to content
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

Merged
merged 7 commits into from
Jun 18, 2022
Merged

Conversation

sept-en
Copy link
Contributor

@sept-en sept-en commented May 31, 2022

Fixes sdk-docs#75

Copy link
Contributor

@austinabell austinabell left a 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.

Comment on lines 218 to 220
self.total_supply
.checked_sub(refund_amount)
.unwrap_or_else(|| env::panic_str("Total supply overflow"));
Copy link
Contributor

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

Copy link
Contributor Author

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.

@sept-en sept-en requested a review from itegulov as a code owner June 15, 2022 21:38
@sept-en sept-en requested a review from austinabell June 15, 2022 21:40
@austinabell austinabell merged commit 1a39f1e into near:master Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NEP-141: unchecked addition and subtraction operations
2 participants