@@ -219,25 +219,23 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl
219
219
/// @param nftMetadataURI OPTIONAL. The URI of the desired metadata for the newly minted NFT.
220
220
/// @param nftMetadataHash OPTIONAL. A bytes32 hash of the NFT's metadata.
221
221
/// This metadata is accessible via the NFT's tokenURI.
222
- /// @param dedup Set to true to enable checking for duplicate metadata hashes.
223
- /// If a duplicate is found, the function will return the existing token ID instead of minting a new one.
222
+ /// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
224
223
/// @return tokenId The token ID of the minted NFT with the given metadata hash.
225
- /// @return deduped true if dedup is enabled and the metadata hash is already used, false otherwise.
226
224
function mint (
227
225
address to ,
228
226
string calldata nftMetadataURI ,
229
227
bytes32 nftMetadataHash ,
230
- bool dedup
231
- ) public virtual returns (uint256 tokenId , bool deduped ) {
228
+ bool allowDuplicates
229
+ ) public virtual returns (uint256 tokenId ) {
232
230
if (! _getSPGNFTStorage ()._publicMinting && ! hasRole (SPGNFTLib.MINTER_ROLE, msg .sender )) {
233
231
revert Errors.SPGNFT__MintingDenied ();
234
232
}
235
- ( tokenId, deduped) = _mintToken ({
233
+ tokenId = _mintToken ({
236
234
to: to,
237
235
payer: msg .sender ,
238
236
nftMetadataURI: nftMetadataURI,
239
237
nftMetadataHash: nftMetadataHash,
240
- dedup: dedup
238
+ allowDuplicates: allowDuplicates
241
239
});
242
240
}
243
241
@@ -247,23 +245,21 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl
247
245
/// @param nftMetadataURI OPTIONAL. The URI of the desired metadata for the newly minted NFT.
248
246
/// @param nftMetadataHash OPTIONAL. A bytes32 hash of the NFT's metadata.
249
247
/// This metadata is accessible via the NFT's tokenURI.
250
- /// @param dedup Set to true to enable checking for duplicate metadata hashes.
251
- /// If a duplicate is found, the function will return the existing token ID instead of minting a new one.
248
+ /// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
252
249
/// @return tokenId The token ID of the minted NFT with the given metadata hash.
253
- /// @return deduped true if dedup is enabled and the metadata hash is already used, false otherwise.
254
250
function mintByPeriphery (
255
251
address to ,
256
252
address payer ,
257
253
string calldata nftMetadataURI ,
258
254
bytes32 nftMetadataHash ,
259
- bool dedup
260
- ) public virtual onlyPeriphery returns (uint256 tokenId , bool deduped ) {
261
- ( tokenId, deduped) = _mintToken ({
255
+ bool allowDuplicates
256
+ ) public virtual onlyPeriphery returns (uint256 tokenId ) {
257
+ tokenId = _mintToken ({
262
258
to: to,
263
259
payer: payer,
264
260
nftMetadataURI: nftMetadataURI,
265
261
nftMetadataHash: nftMetadataHash,
266
- dedup: dedup
262
+ allowDuplicates: allowDuplicates
267
263
});
268
264
}
269
265
@@ -287,24 +283,26 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl
287
283
/// @param nftMetadataURI OPTIONAL. The URI of the desired metadata for the newly minted NFT.
288
284
/// @param nftMetadataHash OPTIONAL. A bytes32 hash of the NFT's metadata.
289
285
/// This metadata is accessible via the NFT's tokenURI.
290
- /// @param dedup Set to true to enable checking for duplicate metadata hashes.
291
- /// If a duplicate is found, the function will return the existing token ID instead of minting a new one.
286
+ /// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
292
287
/// @return tokenId The token ID of the minted NFT with the given metadata hash.
293
- /// @return deduped true if dedup is enabled and the metadata hash is already used, false otherwise.
294
288
function _mintToken (
295
289
address to ,
296
290
address payer ,
297
291
string calldata nftMetadataURI ,
298
292
bytes32 nftMetadataHash ,
299
- bool dedup
300
- ) internal returns (uint256 tokenId , bool deduped ) {
293
+ bool allowDuplicates
294
+ ) internal returns (uint256 tokenId ) {
301
295
SPGNFTStorage storage $ = _getSPGNFTStorage ();
302
296
if (! $._mintOpen) revert Errors.SPGNFT__MintingClosed ();
303
297
if ($._totalSupply + 1 > $._maxSupply) revert Errors.SPGNFT__MaxSupplyReached ();
304
298
305
299
tokenId = $._nftMetadataHashToTokenId[nftMetadataHash];
306
- if (dedup && tokenId != 0 ) {
307
- return (tokenId, true );
300
+ if (! allowDuplicates && tokenId != 0 ) {
301
+ revert Errors.SPGNFT__DuplicatedNFTMetadataHash ({
302
+ spgNftContract: address (this ),
303
+ tokenId: tokenId,
304
+ nftMetadataHash: nftMetadataHash
305
+ });
308
306
}
309
307
310
308
if ($._mintFeeToken != address (0 ) && $._mintFee > 0 ) {
@@ -320,8 +318,6 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl
320
318
_mint (to, tokenId);
321
319
322
320
if (bytes (nftMetadataURI).length > 0 ) _setTokenURI (tokenId, nftMetadataURI);
323
-
324
- return (tokenId, false );
325
321
}
326
322
327
323
/// @dev Base URI for computing tokenURI.
0 commit comments