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

feat: capped minter v2 minter role #4

Open
wants to merge 44 commits into
base: feat/capped-minter-v2
Choose a base branch
from

Conversation

marcomariscal
Copy link

Description

Add AccessControl to ZkCappedMinterV2

  • Inherit from OpenZeppelin AccessControl
  • Add minter role (separate from admin role)
  • Admin can grant/revoke minter role but cannot mint by default
  • Only addresses with minter role can mint tokens

Kept all testing functionality the same as V1, but updated according to these changes. Also, included one more test for testFuzz_RevertIf_AdminMintsByDefault

@marcomariscal marcomariscal linked an issue Dec 3, 2024 that may be closed by this pull request
4 tasks
@marcomariscal marcomariscal force-pushed the feat/capped-minter-v2-minter-role branch from 7483d1f to f417601 Compare December 4, 2024 17:46
@marcomariscal marcomariscal force-pushed the feat/capped-minter-v2-minter-role branch from bbaec92 to 31d626f Compare December 4, 2024 23:17
Copy link
Collaborator

@alexkeating alexkeating left a comment

Choose a reason for hiding this comment

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

Looks good some small comments

/// @notice Error for when the cap is exceeded.
error ZkCappedMinterV2__CapExceeded(address minter, uint256 amount);

/// @notice Error for when the caller is not the admin.
/// @notice Error for when the account is unauthorized.
error ZkCappedMinterV2__Unauthorized(address account);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

sounds good; see this reply for more context:

#4 (comment)

vm.prank(_cappedMinterAdmin);
cappedMinter.grantRole(MINTER_ROLE, _minter);
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be good to put this in a helper

Copy link
Author

Choose a reason for hiding this comment

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

function _revertIfUnauthorized() internal view {
if (msg.sender != ADMIN) {
if (!hasRole(MINTER_ROLE, msg.sender)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same in the upstream prs

Copy link
Author

Choose a reason for hiding this comment

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

72ef93c

also removed the Unauthorized error since we are using _checkRole; this version of oz uses string reverts, so the test checks accordingly.

will update in the subsequent pr's.

@marcomariscal marcomariscal force-pushed the feat/capped-minter-v2-minter-role branch from 725dc00 to 1295f88 Compare December 10, 2024 01:00
@marcomariscal marcomariscal force-pushed the feat/capped-minter-v2-minter-role branch from 89702f0 to af16880 Compare December 10, 2024 19:17
@marcomariscal marcomariscal force-pushed the feat/capped-minter-v2-minter-role branch from af16880 to 007784b Compare December 10, 2024 19:18
@@ -8,10 +9,10 @@
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
"@murky/=lib/murky/",
"src/=src/",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this necessary?

@@ -1,5 +1,6 @@
[profile.default]
evm_version = "paris"
fs_permissions = [{ access = "read", path = "./zkout" }]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, why was this added?

@marcomariscal marcomariscal force-pushed the feat/capped-minter-v2-minter-role branch from 12e615f to d0798f7 Compare December 12, 2024 17:43
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.

Access Control Implementation: Add minter role to capped minter v2
2 participants