@@ -580,11 +580,10 @@ contract GamePasses is
580
580
}
581
581
582
582
_updateAndCheckTotalMinted (mintTokenId, mintAmount);
583
- mintConfig.mintedPerWallet[ mintTo] += mintAmount;
583
+ _updateAndCheckMaxPerWallet (mintTokenId, mintTo, mintAmount) ;
584
584
585
585
_burn (burnFrom, burnTokenId, burnAmount);
586
586
587
- _checkMaxPerWallet (mintTokenId, mintTo, mintAmount);
588
587
_mint (mintTo, mintTokenId, mintAmount, "" );
589
588
}
590
589
@@ -638,8 +637,7 @@ contract GamePasses is
638
637
}
639
638
640
639
_updateAndCheckTotalMinted (mintTokenIds[i], mintAmounts[i]);
641
- _checkMaxPerWallet (mintTokenIds[i], mintTo, mintAmounts[i]);
642
- mintConfig.mintedPerWallet[mintTo] += mintAmounts[i];
640
+ _updateAndCheckMaxPerWallet (mintTokenIds[i], mintTo, mintAmounts[i]);
643
641
}
644
642
645
643
_burnBatch (burnFrom, burnTokenIds, burnAmounts);
@@ -705,11 +703,9 @@ contract GamePasses is
705
703
verifyBurnAndMintSignature (request, signature);
706
704
707
705
_updateAndCheckTotalMinted (mintId, mintAmount);
708
- mintConfig.mintedPerWallet[ caller] += mintAmount;
706
+ _updateAndCheckMaxPerWallet (mintId, caller, mintAmount) ;
709
707
710
708
_burn (caller, burnId, burnAmount);
711
-
712
- _checkMaxPerWallet (mintId, caller, mintAmount);
713
709
_mint (caller, mintId, mintAmount, "" );
714
710
}
715
711
@@ -1269,11 +1265,9 @@ contract GamePasses is
1269
1265
1270
1266
verifySignature (request, signature);
1271
1267
1272
- _checkMaxPerWallet (request.tokenId, request.caller, request.amount);
1268
+ _updateAndCheckMaxPerWallet (request.tokenId, request.caller, request.amount);
1273
1269
_updateAndCheckTotalMinted (request.tokenId, request.amount);
1274
1270
1275
- config.mintedPerWallet[request.caller] += request.amount;
1276
-
1277
1271
address treasury = config.treasuryWallet;
1278
1272
if (treasury == address (0 )) {
1279
1273
treasury = _coreStorage ().defaultTreasuryWallet;
@@ -1305,11 +1299,9 @@ contract GamePasses is
1305
1299
revert TokenNotConfigured (request.tokenIds[i]);
1306
1300
}
1307
1301
1308
- _checkMaxPerWallet (request.tokenIds[i], request.caller, request.amounts[i]);
1302
+ _updateAndCheckMaxPerWallet (request.tokenIds[i], request.caller, request.amounts[i]);
1309
1303
_updateAndCheckTotalMinted (request.tokenIds[i], request.amounts[i]);
1310
1304
1311
- config.mintedPerWallet[request.caller] += request.amounts[i];
1312
-
1313
1305
address treasury = config.treasuryWallet;
1314
1306
if (treasury == address (0 )) {
1315
1307
treasury = _coreStorage ().defaultTreasuryWallet;
@@ -1388,14 +1380,16 @@ contract GamePasses is
1388
1380
* - Current wallet balance + amount would exceed max per wallet
1389
1381
* @dev Skips check if maxPerWallet is type(uint256).max (unlimited)
1390
1382
*/
1391
- function _checkMaxPerWallet (uint256 tokenId , address to , uint256 amount ) private view {
1383
+ function _updateAndCheckMaxPerWallet (uint256 tokenId , address to , uint256 amount ) private {
1392
1384
TokenConfig storage config = _tokenStorage ().tokenConfigs[tokenId];
1393
1385
1386
+ config.mintedPerWallet[to] += amount;
1387
+
1394
1388
if (config.maxPerWallet == 0 ) {
1395
1389
revert ExceedsMaxPerWallet (tokenId, to, amount, 0 );
1396
1390
}
1397
1391
1398
- if (config.maxPerWallet != type (uint256 ).max && config.mintedPerWallet[to] + amount > config.maxPerWallet) {
1392
+ if (config.maxPerWallet != type (uint256 ).max && config.mintedPerWallet[to] > config.maxPerWallet) {
1399
1393
revert ExceedsMaxPerWallet (tokenId, to, amount, config.maxPerWallet);
1400
1394
}
1401
1395
}
0 commit comments