@@ -88,17 +88,15 @@ abstract contract DropSinglePhase is IDropSinglePhase {
8888 // Mint the relevant NFTs to claimer.
8989 uint256 startTokenId = transferTokensOnClaim (_receiver, _quantity);
9090
91- emit TokensClaimed (claimCondition, _dropMsgSender (), _receiver, _quantity, startTokenId );
91+ emit TokensClaimed (_dropMsgSender (), _receiver, startTokenId, _quantity );
9292
9393 _afterClaim (_receiver, _quantity, _currency, _pricePerToken, _allowlistProof, _data);
9494 }
9595
9696 /// @dev Lets a contract admin set claim conditions.
97- function setClaimConditions (
98- ClaimCondition calldata _condition ,
99- bool _resetClaimEligibility ,
100- bytes memory
101- ) external virtual override {
97+ function setClaimConditions (ClaimCondition calldata _condition , bool _resetClaimEligibility ) external override {
98+ require (_canSetClaimConditions (), "Not authorized " );
99+
102100 bytes32 targetConditionId = conditionId;
103101 uint256 supplyClaimedAlready = claimCondition.supplyClaimed;
104102
@@ -110,10 +108,10 @@ abstract contract DropSinglePhase is IDropSinglePhase {
110108 require (supplyClaimedAlready <= _condition.maxClaimableSupply, "max supply claimed already " );
111109
112110 claimCondition = ClaimCondition ({
113- startTimestamp: block . timestamp ,
111+ startTimestamp: _condition.startTimestamp ,
114112 maxClaimableSupply: _condition.maxClaimableSupply,
115113 supplyClaimed: supplyClaimedAlready,
116- quantityLimitPerTransaction: _condition.supplyClaimed ,
114+ quantityLimitPerTransaction: _condition.quantityLimitPerTransaction ,
117115 waitTimeInSecondsBetweenClaims: _condition.waitTimeInSecondsBetweenClaims,
118116 merkleRoot: _condition.merkleRoot,
119117 pricePerToken: _condition.pricePerToken,
@@ -150,12 +148,8 @@ abstract contract DropSinglePhase is IDropSinglePhase {
150148 "exceed max claimable supply. "
151149 );
152150
153- uint256 timestampOfLastClaim = lastClaimTimestamp[conditionId][_claimer];
154- require (
155- timestampOfLastClaim == 0 ||
156- block .timestamp >= timestampOfLastClaim + currentClaimPhase.waitTimeInSecondsBetweenClaims,
157- "cannot claim. "
158- );
151+ (uint256 lastClaimedAt , uint256 nextValidClaimTimestamp ) = getClaimTimestamp (_claimer);
152+ require (lastClaimedAt == 0 || block .timestamp >= nextValidClaimTimestamp, "cannot claim. " );
159153 }
160154
161155 /// @dev Checks whether a claimer meets the claim condition's allowlist criteria.
@@ -181,6 +175,23 @@ abstract contract DropSinglePhase is IDropSinglePhase {
181175 }
182176 }
183177
178+ /// @dev Returns the timestamp for when a claimer is eligible for claiming NFTs again.
179+ function getClaimTimestamp (address _claimer )
180+ public
181+ view
182+ returns (uint256 lastClaimedAt , uint256 nextValidClaimTimestamp )
183+ {
184+ lastClaimedAt = lastClaimTimestamp[conditionId][_claimer];
185+
186+ unchecked {
187+ nextValidClaimTimestamp = lastClaimedAt + claimCondition.waitTimeInSecondsBetweenClaims;
188+
189+ if (nextValidClaimTimestamp < lastClaimedAt) {
190+ nextValidClaimTimestamp = type (uint256 ).max;
191+ }
192+ }
193+ }
194+
184195 /*////////////////////////////////////////////////////////////////////
185196 Optional hooks that can be implemented in the derived contract
186197 ///////////////////////////////////////////////////////////////////*/
@@ -210,10 +221,6 @@ abstract contract DropSinglePhase is IDropSinglePhase {
210221 bytes memory _data
211222 ) internal virtual {}
212223
213- /*///////////////////////////////////////////////////////////////
214- Virtual functions: to be implemented in derived contract
215- //////////////////////////////////////////////////////////////*/
216-
217224 /// @dev Collects and distributes the primary sale value of NFTs being claimed.
218225 function collectPriceOnClaim (
219226 uint256 _quantityToClaim ,
@@ -226,4 +233,6 @@ abstract contract DropSinglePhase is IDropSinglePhase {
226233 internal
227234 virtual
228235 returns (uint256 startTokenId );
236+
237+ function _canSetClaimConditions () internal virtual returns (bool );
229238}
0 commit comments