11// SPDX-License-Identifier: Apache-2.0
22pragma solidity ^ 0.8.0 ;
33
4- import "../interface/IDrop.sol " ;
5- import "../../lib/MerkleProof.sol " ;
6- import "./ExecutionContext.sol " ;
7- import "@openzeppelin/contracts-upgradeable/utils/structs/BitMapsUpgradeable.sol " ;
4+ import "./interface/IDrop.sol " ;
5+ import "../lib/MerkleProof.sol " ;
6+ import "../lib/TWBitMaps.sol " ;
87
9- abstract contract Drop is IDrop , ExecutionContext {
10- using BitMapsUpgradeable for BitMapsUpgradeable .BitMap;
8+ abstract contract Drop is IDrop {
9+ using TWBitMaps for TWBitMaps .BitMap;
1110
1211 /*///////////////////////////////////////////////////////////////
1312 State variables
@@ -44,7 +43,7 @@ abstract contract Drop is IDrop, ExecutionContext {
4443 // Verify inclusion in allowlist.
4544 (bool validMerkleProof , uint256 merkleProofIndex ) = verifyClaimMerkleProof (
4645 activeConditionId,
47- _msgSender (),
46+ _dropMsgSender (),
4847 _quantity,
4948 _allowlistProof
5049 );
@@ -54,7 +53,7 @@ abstract contract Drop is IDrop, ExecutionContext {
5453
5554 verifyClaim (
5655 activeConditionId,
57- _msgSender (),
56+ _dropMsgSender (),
5857 _quantity,
5958 _currency,
6059 _pricePerToken,
@@ -74,25 +73,27 @@ abstract contract Drop is IDrop, ExecutionContext {
7473 // claimCondition.supplyClaimed += _quantity;
7574 // lastClaimTimestamp[activeConditionId][_msgSender()] = block.timestamp;
7675 claimCondition.conditions[activeConditionId].supplyClaimed += _quantity;
77- claimCondition.lastClaimTimestamp[activeConditionId][_msgSender ()] = block .timestamp ;
76+ claimCondition.lastClaimTimestamp[activeConditionId][_dropMsgSender ()] = block .timestamp ;
7877
7978 // If there's a price, collect price.
8079 collectPriceOnClaim (_quantity, _currency, _pricePerToken);
8180
8281 // Mint the relevant NFTs to claimer.
8382 uint256 startTokenId = transferTokensOnClaim (_receiver, _quantity);
8483
85- emit TokensClaimed (activeConditionId, _msgSender (), _receiver, startTokenId, _quantity);
84+ emit TokensClaimed (activeConditionId, _dropMsgSender (), _receiver, startTokenId, _quantity);
8685
8786 _afterClaim (_receiver, _quantity, _currency, _pricePerToken, _allowlistProof, _data);
8887 }
8988
9089 /// @dev Lets a contract admin set claim conditions.
91- function setClaimConditions (
92- ClaimCondition[] calldata _conditions ,
93- bool _resetClaimEligibility ,
94- bytes memory
95- ) external virtual override {
90+ function setClaimConditions (ClaimCondition[] calldata _conditions , bool _resetClaimEligibility )
91+ external
92+ virtual
93+ override
94+ {
95+ require (_canSetClaimConditions (), "Not authorized " );
96+
9697 uint256 existingStartIndex = claimCondition.currentStartId;
9798 uint256 existingPhaseCount = claimCondition.count;
9899
@@ -179,13 +180,6 @@ abstract contract Drop is IDrop, ExecutionContext {
179180 "exceed max claimable supply. "
180181 );
181182
182- // uint256 timestampOfLastClaim = lastClaimTimestamp[conditionId][_claimer];
183- // uint256 timestampOfLastClaim = claimCondition.lastClaimTimestamp[_conditionId][_claimer];
184- // require(
185- // timestampOfLastClaim == 0 ||
186- // block.timestamp >= timestampOfLastClaim + currentClaimPhase.waitTimeInSecondsBetweenClaims,
187- // "cannot claim."
188- // );
189183 (uint256 lastClaimTimestamp , uint256 nextValidClaimTimestamp ) = getClaimTimestamp (_conditionId, _claimer);
190184 require (lastClaimTimestamp == 0 || block .timestamp >= nextValidClaimTimestamp, "cannot claim. " );
191185 }
@@ -206,7 +200,6 @@ abstract contract Drop is IDrop, ExecutionContext {
206200 keccak256 (abi.encodePacked (_claimer, _allowlistProof.maxQuantityInAllowlist))
207201 );
208202 require (validMerkleProof, "not in whitelist. " );
209- // require(!usedAllowlistSpot[conditionId].get(merkleProofIndex), "proof claimed.");
210203 require (! claimCondition.usedAllowlistSpot[_conditionId].get (merkleProofIndex), "proof claimed. " );
211204 require (
212205 _allowlistProof.maxQuantityInAllowlist == 0 || _quantity <= _allowlistProof.maxQuantityInAllowlist,
@@ -250,9 +243,14 @@ abstract contract Drop is IDrop, ExecutionContext {
250243 }
251244 }
252245
253- /*///////////////////////////////////////////////////////////////
254- Virtual functions: to be implemented in derived contract
255- //////////////////////////////////////////////////////////////*/
246+ /*////////////////////////////////////////////////////////////////////
247+ Optional hooks that can be implemented in the derived contract
248+ ///////////////////////////////////////////////////////////////////*/
249+
250+ /// @dev Exposes the ability to override the msg sender.
251+ function _dropMsgSender () internal virtual returns (address ) {
252+ return msg .sender ;
253+ }
256254
257255 /// @dev Runs before every `claim` function call.
258256 function _beforeClaim (
@@ -274,6 +272,10 @@ abstract contract Drop is IDrop, ExecutionContext {
274272 bytes memory _data
275273 ) internal virtual {}
276274
275+ /*///////////////////////////////////////////////////////////////
276+ Virtual functions: to be implemented in derived contract
277+ //////////////////////////////////////////////////////////////*/
278+
277279 /// @dev Collects and distributes the primary sale value of NFTs being claimed.
278280 function collectPriceOnClaim (
279281 uint256 _quantityToClaim ,
@@ -286,4 +288,7 @@ abstract contract Drop is IDrop, ExecutionContext {
286288 internal
287289 virtual
288290 returns (uint256 startTokenId );
291+
292+ /// @dev Determine what wallet can update claim conditions
293+ function _canSetClaimConditions () internal virtual returns (bool );
289294}
0 commit comments