@@ -62,6 +62,8 @@ contract DropERC721 is
62
62
bytes32 private transferRole;
63
63
/// @dev Only MINTER_ROLE holders can sign off on `MintRequest`s and lazy mint tokens.
64
64
bytes32 private minterRole;
65
+ /// @dev Only METADATA_ROLE holders can reveal the URI for a batch of delayed reveal NFTs, and update or freeze batch metadata.
66
+ bytes32 private metadataRole;
65
67
66
68
/// @dev Max bps in the thirdweb system.
67
69
uint256 private constant MAX_BPS = 10_000 ;
@@ -93,6 +95,7 @@ contract DropERC721 is
93
95
) external initializer {
94
96
bytes32 _transferRole = keccak256 ("TRANSFER_ROLE " );
95
97
bytes32 _minterRole = keccak256 ("MINTER_ROLE " );
98
+ bytes32 _metadataRole = keccak256 ("METADATA_ROLE " );
96
99
97
100
// Initialize inherited contracts, most base-like -> most derived.
98
101
__ERC2771Context_init (_trustedForwarders);
@@ -105,13 +108,16 @@ contract DropERC721 is
105
108
_setupRole (_minterRole, _defaultAdmin);
106
109
_setupRole (_transferRole, _defaultAdmin);
107
110
_setupRole (_transferRole, address (0 ));
111
+ _setupRole (_metadataRole, _defaultAdmin);
112
+ _setRoleAdmin (_metadataRole, _metadataRole);
108
113
109
114
_setupPlatformFeeInfo (_platformFeeRecipient, _platformFeeBps);
110
115
_setupDefaultRoyaltyInfo (_royaltyRecipient, _royaltyBps);
111
116
_setupPrimarySaleRecipient (_saleRecipient);
112
117
113
118
transferRole = _transferRole;
114
119
minterRole = _minterRole;
120
+ metadataRole = _metadataRole;
115
121
}
116
122
117
123
/*///////////////////////////////////////////////////////////////
@@ -176,10 +182,12 @@ contract DropERC721 is
176
182
return super .lazyMint (_amount, _baseURIForTokens, _data);
177
183
}
178
184
179
- /// @dev Lets an account with `MINTER_ROLE` reveal the URI for a batch of 'delayed-reveal' NFTs.
185
+ /// @dev Lets an account with `METADATA_ROLE` reveal the URI for a batch of 'delayed-reveal' NFTs.
186
+ /// @param _index the ID of a token with the desired batch.
187
+ /// @param _key the key to decrypt the batch's URI.
180
188
function reveal (uint256 _index , bytes calldata _key )
181
189
external
182
- onlyRole (minterRole )
190
+ onlyRole (metadataRole )
183
191
returns (string memory revealedURI )
184
192
{
185
193
uint256 batchId = getBatchIdAtIndex (_index);
@@ -191,6 +199,29 @@ contract DropERC721 is
191
199
emit TokenURIRevealed (_index, revealedURI);
192
200
}
193
201
202
+ /**
203
+ * @notice Updates the base URI for a batch of tokens. Can only be called if the batch has been revealed/is not encrypted.
204
+ *
205
+ * @param _index Index of the desired batch in batchIds array
206
+ * @param _uri the new base URI for the batch.
207
+ */
208
+ function updateBatchBaseURI (uint256 _index , string calldata _uri ) external onlyRole (metadataRole) {
209
+ require (! isEncryptedBatch (getBatchIdAtIndex (_index)), "Encrypted batch " );
210
+ uint256 batchId = getBatchIdAtIndex (_index);
211
+ _setBaseURI (batchId, _uri);
212
+ }
213
+
214
+ /**
215
+ * @notice Freezes the base URI for a batch of tokens.
216
+ *
217
+ * @param _index Index of the desired batch in batchIds array.
218
+ */
219
+ function freezeBatchBaseURI (uint256 _index ) external onlyRole (metadataRole) {
220
+ require (! isEncryptedBatch (getBatchIdAtIndex (_index)), "Encrypted batch " );
221
+ uint256 batchId = getBatchIdAtIndex (_index);
222
+ _freezeBaseURI (batchId);
223
+ }
224
+
194
225
/*///////////////////////////////////////////////////////////////
195
226
Setter functions
196
227
//////////////////////////////////////////////////////////////*/
@@ -302,9 +333,7 @@ contract DropERC721 is
302
333
* Returns the total amount of tokens minted in the contract.
303
334
*/
304
335
function totalMinted () external view returns (uint256 ) {
305
- unchecked {
306
- return _currentIndex - _startTokenId ();
307
- }
336
+ return _totalMinted ();
308
337
}
309
338
310
339
/// @dev The tokenId of the next NFT that will be minted / lazy minted.
0 commit comments