Skip to content

Migrate ERC20 contracts to Open Zeppelin 5 - #308

Closed
drinkcoffee wants to merge 2 commits into
mainfrom
peter-oz5-erc20
Closed

Migrate ERC20 contracts to Open Zeppelin 5#308
drinkcoffee wants to merge 2 commits into
mainfrom
peter-oz5-erc20

Conversation

@drinkcoffee

Copy link
Copy Markdown
Contributor

Migrate ERC 20 contracts to use Open Zeppelin.
Move MintingAccessControl contracts from contracts/access to contracts/token/utils

@drinkcoffee
drinkcoffee requested a review from a team as a code ownerJune 8, 2026 04:12

import {AccessControlEnumerable} from "openzeppelin-contracts-4/access/AccessControlEnumerable.sol";

abstract contract MintingAccessControlOz4 is AccessControlEnumerable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new contracts/token/utils/ directory has no README.md. The repo convention (e.g. contracts/multicall/, contracts/token/erc721/), and prior review feedback on past PRs, is to add a directory README describing the contents, threat model, and audit references. Consider adding one for token/utils/.

import {ERC20Capped} from "openzeppelin-contracts-4/token/ERC20/extensions/ERC20Capped.sol";
import {AccessControl, IAccessControl} from "openzeppelin-contracts-4/access/AccessControl.sol";
import {MintingAccessControl} from "../../../access/MintingAccessControl.sol";
import {ERC20Permit, ERC20} from "openzeppelin-contracts-5/token/ERC20/extensions/ERC20Permit.sol";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that these presets are on OZ5: the audit / threat-model status table in contracts/token/erc20/README.md (which references the earlier OZ4 commits b7adf0d7 / aa6c1d4) is stale for this contract. That README is not part of this PR -- consider updating it to record the OZ5 migration, or to note the migrated code is not yet audited against OZ5.

@@ -66,10 +66,8 @@ contract ImmutableERC20MinterBurnerPermit is ERC20Capped, ERC20Burnable, ERC20Pe
super.renounceRole(role, account);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking doc nit from the OZ5 migration: the NatSpec for this renounceRole override (@param account -- "The account to renounce the role from") is now slightly misleading. In OZ5, AccessControl.renounceRole renames the second parameter to callerConfirmation and enforces callerConfirmation == msg.sender (reverting with AccessControlBadConfirmation). Behaviour is unchanged vs OZ4, but consider renaming the param / updating the doc to make the self-only requirement explicit.

function _mint(address account, uint256 amount) internal override(ERC20, ERC20Capped) {
ERC20Capped._mint(account, amount);
}
/// @inheritdoc ERC20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: @inheritdoc ERC20 here, while the body delegates to ERC20Capped._update. This matches OZ's own convention (OZ tags ERC20Capped._update with @inheritdoc ERC20), so it is acceptable, but @inheritdoc ERC20Capped would more precisely describe the delegation target. Non-blocking.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drinkcoffee@lfportal