@@ -62,6 +62,8 @@ contract DropERC721 is
6262 bytes32 private transferRole;
6363 /// @dev Only MINTER_ROLE holders can sign off on `MintRequest`s and lazy mint tokens.
6464 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;
6567
6668 /// @dev Max bps in the thirdweb system.
6769 uint256 private constant MAX_BPS = 10_000 ;
@@ -93,6 +95,7 @@ contract DropERC721 is
9395 ) external initializer {
9496 bytes32 _transferRole = keccak256 ("TRANSFER_ROLE " );
9597 bytes32 _minterRole = keccak256 ("MINTER_ROLE " );
98+ bytes32 _metadataRole = keccak256 ("METADATA_ROLE " );
9699
97100 // Initialize inherited contracts, most base-like -> most derived.
98101 __ERC2771Context_init (_trustedForwarders);
@@ -105,13 +108,16 @@ contract DropERC721 is
105108 _setupRole (_minterRole, _defaultAdmin);
106109 _setupRole (_transferRole, _defaultAdmin);
107110 _setupRole (_transferRole, address (0 ));
111+ _setupRole (_metadataRole, _defaultAdmin);
112+ _setRoleAdmin (_metadataRole, _metadataRole);
108113
109114 _setupPlatformFeeInfo (_platformFeeRecipient, _platformFeeBps);
110115 _setupDefaultRoyaltyInfo (_royaltyRecipient, _royaltyBps);
111116 _setupPrimarySaleRecipient (_saleRecipient);
112117
113118 transferRole = _transferRole;
114119 minterRole = _minterRole;
120+ metadataRole = _metadataRole;
115121 }
116122
117123 /*///////////////////////////////////////////////////////////////
@@ -176,10 +182,12 @@ contract DropERC721 is
176182 return super .lazyMint (_amount, _baseURIForTokens, _data);
177183 }
178184
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.
180188 function reveal (uint256 _index , bytes calldata _key )
181189 external
182- onlyRole (minterRole )
190+ onlyRole (metadataRole )
183191 returns (string memory revealedURI )
184192 {
185193 uint256 batchId = getBatchIdAtIndex (_index);
@@ -191,6 +199,29 @@ contract DropERC721 is
191199 emit TokenURIRevealed (_index, revealedURI);
192200 }
193201
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+
194225 /*///////////////////////////////////////////////////////////////
195226 Setter functions
196227 //////////////////////////////////////////////////////////////*/
@@ -302,9 +333,7 @@ contract DropERC721 is
302333 * Returns the total amount of tokens minted in the contract.
303334 */
304335 function totalMinted () external view returns (uint256 ) {
305- unchecked {
306- return _currentIndex - _startTokenId ();
307- }
336+ return _totalMinted ();
308337 }
309338
310339 /// @dev The tokenId of the next NFT that will be minted / lazy minted.
0 commit comments