@@ -42,7 +42,7 @@ contract DropERC1155 is
4242 //////////////////////////////////////////////////////////////*/
4343
4444 bytes32 private constant MODULE_TYPE = bytes32 ("DropERC1155 " );
45- uint256 private constant VERSION = 1 ;
45+ uint256 private constant VERSION = 2 ;
4646
4747 // Token name
4848 string public name;
@@ -73,14 +73,14 @@ contract DropERC1155 is
7373 /// @dev The address that receives all platform fees from all sales.
7474 address private platformFeeRecipient;
7575
76+ /// @dev The % of primary sales collected as platform fees.
77+ uint16 private platformFeeBps;
78+
7679 /// @dev The recipient of who gets the royalty.
7780 address private royaltyRecipient;
7881
7982 /// @dev The (default) address that receives all royalty value.
80- uint128 private royaltyBps;
81-
82- /// @dev The % of primary sales collected as platform fees.
83- uint128 private platformFeeBps;
83+ uint16 private royaltyBps;
8484
8585 /// @dev Contract level metadata.
8686 string public contractURI;
@@ -149,11 +149,11 @@ contract DropERC1155 is
149149 name = _name;
150150 symbol = _symbol;
151151 royaltyRecipient = _royaltyRecipient;
152- royaltyBps = _royaltyBps;
152+ royaltyBps = uint16 ( _royaltyBps) ;
153153 platformFeeRecipient = _platformFeeRecipient;
154154 primarySaleRecipient = _saleRecipient;
155155 contractURI = _contractURI;
156- platformFeeBps = _platformFeeBps;
156+ platformFeeBps = uint16 ( _platformFeeBps) ;
157157 _owner = _defaultAdmin;
158158
159159 _setupRole (DEFAULT_ADMIN_ROLE, _defaultAdmin);
@@ -257,10 +257,14 @@ contract DropERC1155 is
257257 // Get the active claim condition index.
258258 uint256 activeConditionId = getActiveClaimConditionId (_tokenId);
259259
260- // Verify claim validity. If not valid, revert.
261- verifyClaim (activeConditionId, _msgSender (), _tokenId, _quantity, _currency, _pricePerToken);
260+ /**
261+ * We make allowlist checks (i.e. verifyClaimMerkleProof) before verifying the claim's general
262+ * validity (i.e. verifyClaim) because we give precedence to the check of allow list quantity
263+ * restriction over the check of the general claim condition's quantityLimitPerTransaction
264+ * restriction.
265+ */
262266
263- // Verify inclusion in allowlist
267+ // Verify inclusion in allowlist.
264268 (bool validMerkleProof , uint256 merkleProofIndex ) = verifyClaimMerkleProof (
265269 activeConditionId,
266270 _msgSender (),
@@ -270,8 +274,23 @@ contract DropERC1155 is
270274 _proofMaxQuantityPerTransaction
271275 );
272276
277+ // Verify claim validity. If not valid, revert.
278+ bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 ;
279+ verifyClaim (
280+ activeConditionId,
281+ _msgSender (),
282+ _tokenId,
283+ _quantity,
284+ _currency,
285+ _pricePerToken,
286+ toVerifyMaxQuantityPerTransaction
287+ );
288+
273289 if (validMerkleProof && _proofMaxQuantityPerTransaction > 0 ) {
274- // Mark the claimer's use of their position in the allowlist.
290+ /**
291+ * Mark the claimer's use of their position in the allowlist. A spot in an allowlist
292+ * can be used only once.
293+ */
275294 claimCondition[_tokenId].limitMerkleProofClaim[activeConditionId].set (merkleProofIndex);
276295 }
277296
@@ -317,8 +336,11 @@ contract DropERC1155 is
317336 "startTimestamp must be in ascending order. "
318337 );
319338
339+ uint256 supplyClaimedAlready = condition.phases[newStartIndex + i].supplyClaimed;
340+ require (supplyClaimedAlready < _phases[i].maxClaimableSupply, "max supply claimed already " );
341+
320342 condition.phases[newStartIndex + i] = _phases[i];
321- condition.phases[newStartIndex + i].supplyClaimed = 0 ;
343+ condition.phases[newStartIndex + i].supplyClaimed = supplyClaimedAlready ;
322344
323345 lastConditionStartTimestamp = _phases[i].startTimestamp;
324346 }
@@ -402,16 +424,19 @@ contract DropERC1155 is
402424 uint256 _tokenId ,
403425 uint256 _quantity ,
404426 address _currency ,
405- uint256 _pricePerToken
427+ uint256 _pricePerToken ,
428+ bool verifyMaxQuantityPerTransaction
406429 ) public view {
407430 ClaimCondition memory currentClaimPhase = claimCondition[_tokenId].phases[_conditionId];
408431
409432 require (
410433 _currency == currentClaimPhase.currency && _pricePerToken == currentClaimPhase.pricePerToken,
411434 "invalid currency or price specified. "
412435 );
436+ // If we're checking for an allowlist quantity restriction, ignore the general quantity restriction.
413437 require (
414- _quantity > 0 && _quantity <= currentClaimPhase.quantityLimitPerTransaction,
438+ _quantity > 0 &&
439+ (! verifyMaxQuantityPerTransaction || _quantity <= currentClaimPhase.quantityLimitPerTransaction),
415440 "invalid quantity claimed. "
416441 );
417442 require (
@@ -569,7 +594,7 @@ contract DropERC1155 is
569594 require (_royaltyBps <= MAX_BPS, "exceed royalty bps " );
570595
571596 royaltyRecipient = _royaltyRecipient;
572- royaltyBps = uint128 (_royaltyBps);
597+ royaltyBps = uint16 (_royaltyBps);
573598
574599 emit DefaultRoyalty (_royaltyRecipient, _royaltyBps);
575600 }
@@ -594,7 +619,7 @@ contract DropERC1155 is
594619 {
595620 require (_platformFeeBps <= MAX_BPS, "bps <= 10000. " );
596621
597- platformFeeBps = uint64 (_platformFeeBps);
622+ platformFeeBps = uint16 (_platformFeeBps);
598623 platformFeeRecipient = _platformFeeRecipient;
599624
600625 emit PlatformFeeInfoUpdated (_platformFeeRecipient, _platformFeeBps);
0 commit comments