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

Fix ERC20._update #3921

Merged
merged 23 commits into from
Jan 10, 2023
Merged

Fix ERC20._update #3921

merged 23 commits into from
Jan 10, 2023

Conversation

JulissaDantes
Copy link
Contributor

@JulissaDantes JulissaDantes commented Jan 3, 2023

There is a risk with the current implementation of the _update function of altering the tokens total supply when sending the zero address as the from and to parameters.

If someone does _update(address(0), address(0), amount), this will go into
if (from == address(0)) { ... }
that will increase the total supply and mint tokens to address(0), then because of the else it will not go into
else if (to == address(0)) { ... }
so the total supply amount would remain unbalanced.

PR Checklist

  • Tests
  • Documentation
  • Changelog entry

@Amxx
Copy link
Collaborator

Amxx commented Jan 3, 2023

ERC20Snapshot should also be updated. Should that be done in a separate PR?

@JulissaDantes
Copy link
Contributor Author

ERC20Snapshot should also be updated. Should that be done in a separate PR?

It will be done here.

@Amxx
Copy link
Collaborator

Amxx commented Jan 4, 2023

We should merge master into next-5.0.

This will enable hardhat-exposed, removing the needs for mocks.

CHANGELOG.md Outdated Show resolved Hide resolved
test/token/ERC20/ERC20.test.js Outdated Show resolved Hide resolved
test/token/ERC20/ERC20.test.js Outdated Show resolved Hide resolved
JulissaDantes and others added 2 commits January 5, 2023 10:32
Co-authored-by: Francisco <frangio.1@gmail.com>
Co-authored-by: Francisco <frangio.1@gmail.com>
test/token/ERC20/ERC20.test.js Show resolved Hide resolved
test/token/ERC20/ERC20.test.js Show resolved Hide resolved
test/token/ERC20/ERC20.test.js Outdated Show resolved Hide resolved
@frangio
Copy link
Contributor

frangio commented Jan 7, 2023

Really confused by why the linter is still failing. It doesn't show any errors locally.

@Amxx
Copy link
Collaborator

Amxx commented Jan 9, 2023

Really confused by why the linter is still failing. It doesn't show any errors locally.

same here

}

if (to == address(0)) {
_totalSupply -= amount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding unchecked here is the only pending item for this PR.

@frangio
Copy link
Contributor

frangio commented Jan 9, 2023

I was somehow able to fix linting by running the latest version of Prettier with the new configuration.

@Amxx
Copy link
Collaborator

Amxx commented Jan 10, 2023

I was somehow able to fix linting by running the latest version of Prettier with the new configuration.

is it possible that github action has a cache with the old version ?

@frangio
Copy link
Contributor

frangio commented Jan 10, 2023

I tried deleting the caches and it didn't make a difference.

@Amxx
Copy link
Collaborator

Amxx commented Jan 10, 2023

Note that linting of the mocks is irrelevant as they will be deleted when we merge master.

@frangio frangio changed the title Update ERC20 _update function Fix ERC20._update Jan 10, 2023
@frangio frangio merged commit d210847 into OpenZeppelin:next-v5.0 Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants