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 metadata uri #15

Merged
merged 87 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7e8117f
feat: copy capped minter for v2 template
marcomariscal Dec 3, 2024
d8da7d0
feat: copy capped minter factory tests for v2
marcomariscal Dec 3, 2024
12b292d
feat: inherit from AccessControl and update accordingly
marcomariscal Dec 3, 2024
b597f72
feat: update tests to handle new auth functionality
marcomariscal Dec 3, 2024
2030897
feat: add minter role
marcomariscal Dec 3, 2024
f9ed313
feat: test admin can't mint by default
marcomariscal Dec 3, 2024
7483d1f
fix: name
marcomariscal Dec 3, 2024
59bccb4
feat: basic pause functionality
marcomariscal Dec 3, 2024
f5bb1a8
feat: pause/unpause tests
marcomariscal Dec 3, 2024
b85f60f
fix: assume cap is not zero
marcomariscal Dec 3, 2024
7eb43d0
fix: check for pauser role
marcomariscal Dec 3, 2024
29362c9
fix: separate role errors
marcomariscal Dec 4, 2024
b3e1cb4
feat: _revertIfNotPauser
marcomariscal Dec 4, 2024
a5c8e37
feat: close with tests
marcomariscal Dec 4, 2024
29a35e0
fix: use _revertIfNotPauser
marcomariscal Dec 4, 2024
85bf41a
chore: better comment for `close`
marcomariscal Dec 4, 2024
ab7a46d
feat: update with new time control params
marcomariscal Dec 4, 2024
01ee4e6
feat: time controls and tests
marcomariscal Dec 4, 2024
b309fb7
fix: clearer expiration checks
marcomariscal Dec 4, 2024
112421e
chore: comment
marcomariscal Dec 4, 2024
fe1dbb4
fix: should be able to mint at start and at expiry
marcomariscal Dec 4, 2024
9f8ea6e
feat: inherit from AccessControl and update accordingly
marcomariscal Dec 4, 2024
2aecdce
feat: update tests to handle new auth functionality
marcomariscal Dec 4, 2024
e293e2d
feat: add minter role
marcomariscal Dec 4, 2024
b7f4222
feat: test admin can't mint by default
marcomariscal Dec 4, 2024
726d0bf
fix: name
marcomariscal Dec 4, 2024
31d626f
fix: structure
marcomariscal Dec 4, 2024
fb88648
feat: basic pause functionality
marcomariscal Dec 3, 2024
946dc79
feat: pause/unpause tests
marcomariscal Dec 3, 2024
d9b3dba
fix: assume cap is not zero
marcomariscal Dec 3, 2024
1cfbef7
fix: check for pauser role
marcomariscal Dec 3, 2024
3379852
fix: separate role errors
marcomariscal Dec 4, 2024
004c789
feat: _revertIfNotPauser
marcomariscal Dec 4, 2024
4f29f5c
feat: close with tests
marcomariscal Dec 4, 2024
edf05f6
fix: use _revertIfNotPauser
marcomariscal Dec 4, 2024
bceb0f7
chore: better comment for `close`
marcomariscal Dec 4, 2024
870c7ba
feat: set uri
marcomariscal Dec 4, 2024
6251a0b
Merge branch 'feat/capped-minter-v2-close' into feat/capped-minter-v2…
marcomariscal Dec 4, 2024
e1258bc
Merge branch 'feat/capped-minter-v2-time-controls' into feat/capped-m…
marcomariscal Dec 5, 2024
1d93ac7
feat: metadata uri tests
marcomariscal Dec 5, 2024
05ae914
chore: comment
marcomariscal Dec 5, 2024
e680c31
chore: comment
marcomariscal Dec 10, 2024
6ee3fb1
feat: _grantMinterRole helper
marcomariscal Dec 10, 2024
72ef93c
fix: use _checkRole and remove unused unauth error
marcomariscal Dec 10, 2024
dd15cac
fix: assume cap
marcomariscal Dec 10, 2024
61e7247
fix: toml
marcomariscal Dec 10, 2024
1295f88
chore: format
marcomariscal Dec 10, 2024
54315f5
fix: import
marcomariscal Dec 10, 2024
2558249
fix: compile
marcomariscal Dec 10, 2024
857ebc6
chore: name
marcomariscal Dec 10, 2024
479ef77
fix: import
marcomariscal Dec 10, 2024
007784b
fix: remove unnecessary
marcomariscal Dec 10, 2024
bfbac0e
feat: _revertIfClosed
marcomariscal Dec 10, 2024
1b290b7
Merge branch 'feat/capped-minter-v2-close' into feat/capped-minter-v2…
marcomariscal Dec 10, 2024
8a5f057
Merge branch 'feat/capped-minter-v2-minter-role' into feat/capped-min…
marcomariscal Dec 10, 2024
493c1a6
feat: _formatAccessControlError
marcomariscal Dec 10, 2024
7d84ebe
Merge branch 'feat/capped-minter-v2-pause' into feat/capped-minter-v2…
marcomariscal Dec 10, 2024
6bb7d1a
fix: formatted error
marcomariscal Dec 10, 2024
e6a8718
Merge branch 'feat/capped-minter-v2-close' into feat/capped-minter-v2…
marcomariscal Dec 10, 2024
672c6bb
Merge branch 'feat/capped-minter-v2-time-controls' into feat/capped-m…
marcomariscal Dec 10, 2024
91ded16
fix: format helper formatting
marcomariscal Dec 11, 2024
fca3ffb
fix: remove assume cap greater than 0 in favor of bound
marcomariscal Dec 11, 2024
93e4af3
fix: remove unnecessary assumptions
marcomariscal Dec 11, 2024
225ba92
fix: use grant minter role
marcomariscal Dec 11, 2024
1942a64
fix: remove redundant balance check
marcomariscal Dec 11, 2024
77acf62
feat: refactor to set up capped minter in setup func
marcomariscal Dec 11, 2024
ecb275d
feat: testFuzz_CorrectlyPausesMintsWhenTogglingPause
marcomariscal Dec 11, 2024
43fa666
fix: move func
marcomariscal Dec 11, 2024
7da3772
Merge branch 'feat/capped-minter-v2-pause' into feat/capped-minter-v2…
marcomariscal Dec 12, 2024
57e1f4f
fix: only admin can close, fix mint to zero addr receiver, and format…
marcomariscal Dec 12, 2024
ef8ca96
fix: remove unnecessary revert if closed when unpausing
marcomariscal Dec 12, 2024
3fc7d3a
Update l2-contracts/src/ZkCappedMinterV2.sol
marcomariscal Dec 12, 2024
bb6854b
fix: test
marcomariscal Dec 12, 2024
0b17e88
fix: remove unnecessary pause from close
marcomariscal Dec 12, 2024
7631a29
fix: use global minter
marcomariscal Dec 12, 2024
b0da759
Merge branch 'feat/capped-minter-v2-close' into feat/capped-minter-v2…
marcomariscal Dec 12, 2024
ffc248a
fix: remove unnecessary cap bounds
marcomariscal Dec 12, 2024
d1a7306
fix: testFuzz_RevertIf_StartTimeAfterExpirationTime
marcomariscal Dec 12, 2024
70b49f0
fix: tests
marcomariscal Dec 12, 2024
4b8499f
fix: tests
marcomariscal Dec 12, 2024
14bcd88
fix: change to bytes 32
marcomariscal Dec 12, 2024
3cc8138
Merge branch 'feat/capped-minter-v2-time-controls' into feat/capped-m…
marcomariscal Dec 12, 2024
bcaad5a
fix: updates tests with new setup
marcomariscal Dec 12, 2024
63dcaff
Merge branch 'feat/capped-minter-v2' into feat/capped-minter-v2-metad…
marcomariscal Dec 17, 2024
76c6077
chore: remove unused
marcomariscal Dec 17, 2024
7b3032c
fix: remove unused
marcomariscal Dec 17, 2024
d6c83fa
fix: revert type
marcomariscal Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions l2-contracts/src/ZkCappedMinterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ contract ZkCappedMinterV2 is AccessControl, Pausable {
/// @notice The timestamp after which minting is no longer allowed (inclusive).
uint48 public immutable EXPIRATION_TIME;

/// @notice The metadata URI for this minter.
bytes32 public metadataURI;

/// @notice Emitted when the metadata URI is set.
event MetadataURISet(bytes32 uri);

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

Expand Down Expand Up @@ -122,4 +128,13 @@ contract ZkCappedMinterV2 is AccessControl, Pausable {
_checkRole(DEFAULT_ADMIN_ROLE, msg.sender);
closed = true;
}

/// @notice Sets the metadata URI for this contract
/// @param _uri The new metadata URI
/// @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
function setMetadataURI(bytes32 _uri) external {
_checkRole(DEFAULT_ADMIN_ROLE, msg.sender);
metadataURI = _uri;
emit MetadataURISet(_uri);
}
}
37 changes: 34 additions & 3 deletions l2-contracts/test/ZkCappedMinterV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ contract Mint is ZkCappedMinterV2Test {
address _receiver1,
address _receiver2,
uint256 _amount1,
uint256 _amount2,
uint256 _startTime,
uint256 _expirationTime
uint256 _amount2
) public {
_amount1 = bound(_amount1, 1, DEFAULT_CAP / 2);
_amount2 = bound(_amount2, 1, DEFAULT_CAP / 2);
Expand Down Expand Up @@ -337,3 +335,36 @@ contract Close is ZkCappedMinterV2Test {
cappedMinter.close();
}
}

contract SetMetadataURI is ZkCappedMinterV2Test {
function testFuzz_InitialMetadataURIIsEmpty(address _admin, uint256 _cap, uint48 _startTime, uint48 _expirationTime)
public
{
(_startTime, _expirationTime) = _boundToValidTimeControls(_startTime, _expirationTime);

ZkCappedMinterV2 cappedMinter = _createCappedMinter(_admin, _cap, _startTime, _expirationTime);
assertEq(cappedMinter.metadataURI(), bytes32(0));
}

function testFuzz_AdminCanSetMetadataURI(bytes32 _uri) public {
vm.prank(cappedMinterAdmin);
cappedMinter.setMetadataURI(_uri);

assertEq(cappedMinter.metadataURI(), _uri);
}

function testFuzz_EmitsMetadataURISetEvent(bytes32 _uri) public {
vm.prank(cappedMinterAdmin);
vm.expectEmit();
emit ZkCappedMinterV2.MetadataURISet(_uri);
cappedMinter.setMetadataURI(_uri);
}

function testFuzz_RevertIf_NonAdminSetsMetadataURI(address _nonAdmin, bytes32 _uri) public {
vm.assume(cappedMinterAdmin != _nonAdmin);

vm.prank(_nonAdmin);
vm.expectRevert(_formatAccessControlError(_nonAdmin, DEFAULT_ADMIN_ROLE));
cappedMinter.setMetadataURI(_uri);
}
}
Loading