@@ -54,7 +54,7 @@ contract DropERC721 is
5454 //////////////////////////////////////////////////////////////*/
5555
5656 bytes32 private constant MODULE_TYPE = bytes32 ("DropERC721 " );
57- uint256 private constant VERSION = 2 ;
57+ uint256 private constant VERSION = 3 ;
5858
5959 /// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted.
6060 bytes32 private constant TRANSFER_ROLE = keccak256 ("TRANSFER_ROLE " );
@@ -117,7 +117,7 @@ contract DropERC721 is
117117 * @dev Mapping from 'Largest tokenId of a batch of 'delayed-reveal' tokens with
118118 * the same baseURI' to encrypted base URI for the respective batch of tokens.
119119 **/
120- mapping (uint256 => bytes ) public encryptedBaseURI ;
120+ mapping (uint256 => bytes ) public encryptedData ;
121121
122122 /// @dev Mapping from address => total number of NFTs a wallet has claimed.
123123 mapping (address => uint256 ) public walletClaimCount;
@@ -193,7 +193,7 @@ contract DropERC721 is
193193 function tokenURI (uint256 _tokenId ) public view override returns (string memory ) {
194194 for (uint256 i = 0 ; i < baseURIIndices.length ; i += 1 ) {
195195 if (_tokenId < baseURIIndices[i]) {
196- if (encryptedBaseURI [baseURIIndices[i]].length != 0 ) {
196+ if (encryptedData [baseURIIndices[i]].length != 0 ) {
197197 return string (abi.encodePacked (baseURI[baseURIIndices[i]], "0 " ));
198198 } else {
199199 return string (abi.encodePacked (baseURI[baseURIIndices[i]], _tokenId.toString ()));
@@ -238,7 +238,7 @@ contract DropERC721 is
238238 function lazyMint (
239239 uint256 _amount ,
240240 string calldata _baseURIForTokens ,
241- bytes calldata _encryptedBaseURI
241+ bytes calldata _data
242242 ) external onlyRole (MINTER_ROLE) {
243243 uint256 startId = nextTokenIdToMint;
244244 uint256 baseURIIndex = startId + _amount;
@@ -247,11 +247,15 @@ contract DropERC721 is
247247 baseURI[baseURIIndex] = _baseURIForTokens;
248248 baseURIIndices.push (baseURIIndex);
249249
250- if (_encryptedBaseURI.length != 0 ) {
251- encryptedBaseURI[baseURIIndex] = _encryptedBaseURI;
250+ if (_data.length > 0 ) {
251+ (bytes memory encryptedURI , bytes32 provenanceHash ) = abi.decode (_data, (bytes , bytes32 ));
252+
253+ if (encryptedURI.length != 0 && provenanceHash != "" ) {
254+ encryptedData[baseURIIndex] = _data;
255+ }
252256 }
253257
254- emit TokensLazyMinted (startId, startId + _amount - 1 , _baseURIForTokens, _encryptedBaseURI );
258+ emit TokensLazyMinted (startId, startId + _amount - 1 , _baseURIForTokens, _data );
255259 }
256260
257261 /// @dev Lets an account with `MINTER_ROLE` reveal the URI for a batch of 'delayed-reveal' NFTs.
@@ -263,13 +267,17 @@ contract DropERC721 is
263267 require (index < baseURIIndices.length , "invalid index. " );
264268
265269 uint256 _index = baseURIIndices[index];
266- bytes memory encryptedURI = encryptedBaseURI[_index];
270+ bytes memory data = encryptedData[_index];
271+ (bytes memory encryptedURI , bytes32 provenanceHash ) = abi.decode (data, (bytes , bytes32 ));
272+
267273 require (encryptedURI.length != 0 , "nothing to reveal. " );
268274
269275 revealedURI = string (encryptDecrypt (encryptedURI, _key));
270276
277+ require (keccak256 (abi.encodePacked (revealedURI, _key, block .chainid )) == provenanceHash, "Incorrect key " );
278+
271279 baseURI[_index] = revealedURI;
272- delete encryptedBaseURI [_index];
280+ delete encryptedData [_index];
273281
274282 emit NFTRevealed (_index, revealedURI);
275283
0 commit comments