@@ -54,7 +54,7 @@ contract DropERC721 is
54
54
//////////////////////////////////////////////////////////////*/
55
55
56
56
bytes32 private constant MODULE_TYPE = bytes32 ("DropERC721 " );
57
- uint256 private constant VERSION = 2 ;
57
+ uint256 private constant VERSION = 3 ;
58
58
59
59
/// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted.
60
60
bytes32 private constant TRANSFER_ROLE = keccak256 ("TRANSFER_ROLE " );
@@ -117,7 +117,7 @@ contract DropERC721 is
117
117
* @dev Mapping from 'Largest tokenId of a batch of 'delayed-reveal' tokens with
118
118
* the same baseURI' to encrypted base URI for the respective batch of tokens.
119
119
**/
120
- mapping (uint256 => bytes ) public encryptedBaseURI ;
120
+ mapping (uint256 => bytes ) public encryptedData ;
121
121
122
122
/// @dev Mapping from address => total number of NFTs a wallet has claimed.
123
123
mapping (address => uint256 ) public walletClaimCount;
@@ -193,7 +193,7 @@ contract DropERC721 is
193
193
function tokenURI (uint256 _tokenId ) public view override returns (string memory ) {
194
194
for (uint256 i = 0 ; i < baseURIIndices.length ; i += 1 ) {
195
195
if (_tokenId < baseURIIndices[i]) {
196
- if (encryptedBaseURI [baseURIIndices[i]].length != 0 ) {
196
+ if (encryptedData [baseURIIndices[i]].length != 0 ) {
197
197
return string (abi.encodePacked (baseURI[baseURIIndices[i]], "0 " ));
198
198
} else {
199
199
return string (abi.encodePacked (baseURI[baseURIIndices[i]], _tokenId.toString ()));
@@ -238,7 +238,7 @@ contract DropERC721 is
238
238
function lazyMint (
239
239
uint256 _amount ,
240
240
string calldata _baseURIForTokens ,
241
- bytes calldata _encryptedBaseURI
241
+ bytes calldata _data
242
242
) external onlyRole (MINTER_ROLE) {
243
243
uint256 startId = nextTokenIdToMint;
244
244
uint256 baseURIIndex = startId + _amount;
@@ -247,11 +247,15 @@ contract DropERC721 is
247
247
baseURI[baseURIIndex] = _baseURIForTokens;
248
248
baseURIIndices.push (baseURIIndex);
249
249
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
+ }
252
256
}
253
257
254
- emit TokensLazyMinted (startId, startId + _amount - 1 , _baseURIForTokens, _encryptedBaseURI );
258
+ emit TokensLazyMinted (startId, startId + _amount - 1 , _baseURIForTokens, _data );
255
259
}
256
260
257
261
/// @dev Lets an account with `MINTER_ROLE` reveal the URI for a batch of 'delayed-reveal' NFTs.
@@ -263,13 +267,17 @@ contract DropERC721 is
263
267
require (index < baseURIIndices.length , "invalid index. " );
264
268
265
269
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
+
267
273
require (encryptedURI.length != 0 , "nothing to reveal. " );
268
274
269
275
revealedURI = string (encryptDecrypt (encryptedURI, _key));
270
276
277
+ require (keccak256 (abi.encodePacked (revealedURI, _key, block .chainid )) == provenanceHash, "Incorrect key " );
278
+
271
279
baseURI[_index] = revealedURI;
272
- delete encryptedBaseURI [_index];
280
+ delete encryptedData [_index];
273
281
274
282
emit NFTRevealed (_index, revealedURI);
275
283
0 commit comments