Skip to content

Commit 0fdde7f

Browse files
nkrishangKrishang Nadgauda
andauthored
Drop bug fix: replace MerkleProofindex with type casted address of claimer (#254)
* forge updates * Drop: use type casted claimer address instead of merkleProofIndex Co-authored-by: Krishang Nadgauda <[email protected]>
1 parent 192a5cc commit 0fdde7f

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

contracts/drop/DropERC1155.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ contract DropERC1155 is
275275
*/
276276

277277
// Verify inclusion in allowlist.
278-
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof(
278+
(bool validMerkleProof, ) = verifyClaimMerkleProof(
279279
activeConditionId,
280280
_msgSender(),
281281
_tokenId,
@@ -304,7 +304,7 @@ contract DropERC1155 is
304304
* Mark the claimer's use of their position in the allowlist. A spot in an allowlist
305305
* can be used only once.
306306
*/
307-
claimCondition[_tokenId].limitMerkleProofClaim[activeConditionId].set(merkleProofIndex);
307+
claimCondition[_tokenId].limitMerkleProofClaim[activeConditionId].set(uint256(uint160(_msgSender())));
308308
}
309309

310310
// If there's a price, collect price.
@@ -490,7 +490,7 @@ contract DropERC1155 is
490490
);
491491
require(validMerkleProof, "not in whitelist.");
492492
require(
493-
!claimCondition[_tokenId].limitMerkleProofClaim[_conditionId].get(merkleProofIndex),
493+
!claimCondition[_tokenId].limitMerkleProofClaim[_conditionId].get(uint256(uint160(_claimer))),
494494
"proof claimed."
495495
);
496496
require(

contracts/drop/DropERC20.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ contract DropERC20 is
194194
*/
195195

196196
// Verify inclusion in allowlist.
197-
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof(
197+
(bool validMerkleProof, ) = verifyClaimMerkleProof(
198198
activeConditionId,
199199
_msgSender(),
200200
_quantity,
@@ -221,7 +221,7 @@ contract DropERC20 is
221221
* Mark the claimer's use of their position in the allowlist. A spot in an allowlist
222222
* can be used only once.
223223
*/
224-
claimCondition.limitMerkleProofClaim[activeConditionId].set(merkleProofIndex);
224+
claimCondition.limitMerkleProofClaim[activeConditionId].set(uint256(uint160(_msgSender())));
225225
}
226226

227227
// If there's a price, collect price.
@@ -396,7 +396,10 @@ contract DropERC20 is
396396
keccak256(abi.encodePacked(_claimer, _proofMaxQuantityPerTransaction))
397397
);
398398
require(validMerkleProof, "not in whitelist.");
399-
require(!claimCondition.limitMerkleProofClaim[_conditionId].get(merkleProofIndex), "proof claimed.");
399+
require(
400+
!claimCondition.limitMerkleProofClaim[_conditionId].get(uint256(uint160(_claimer))),
401+
"proof claimed."
402+
);
400403
require(
401404
_proofMaxQuantityPerTransaction == 0 || _quantity <= _proofMaxQuantityPerTransaction,
402405
"invalid quantity proof."

contracts/drop/DropERC721.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ contract DropERC721 is
347347
*/
348348

349349
// Verify inclusion in allowlist.
350-
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof(
350+
(bool validMerkleProof, ) = verifyClaimMerkleProof(
351351
activeConditionId,
352352
_msgSender(),
353353
_quantity,
@@ -374,7 +374,7 @@ contract DropERC721 is
374374
* Mark the claimer's use of their position in the allowlist. A spot in an allowlist
375375
* can be used only once.
376376
*/
377-
claimCondition.limitMerkleProofClaim[activeConditionId].set(merkleProofIndex);
377+
claimCondition.limitMerkleProofClaim[activeConditionId].set(uint256(uint160(_msgSender())));
378378
}
379379

380380
// If there's a price, collect price.
@@ -549,7 +549,10 @@ contract DropERC721 is
549549
keccak256(abi.encodePacked(_claimer, _proofMaxQuantityPerTransaction))
550550
);
551551
require(validMerkleProof, "not in whitelist.");
552-
require(!claimCondition.limitMerkleProofClaim[_conditionId].get(merkleProofIndex), "proof claimed.");
552+
require(
553+
!claimCondition.limitMerkleProofClaim[_conditionId].get(uint256(uint160(_claimer))),
554+
"proof claimed."
555+
);
553556
require(
554557
_proofMaxQuantityPerTransaction == 0 || _quantity <= _proofMaxQuantityPerTransaction,
555558
"invalid quantity proof."

contracts/extension/DropSinglePhase.sol

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
5959
*/
6060

6161
// Verify inclusion in allowlist.
62-
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof(
63-
_dropMsgSender(),
64-
_quantity,
65-
_allowlistProof
66-
);
62+
(bool validMerkleProof, ) = verifyClaimMerkleProof(_dropMsgSender(), _quantity, _allowlistProof);
6763

6864
// Verify claim validity. If not valid, revert.
6965
// when there's allowlist present --> verifyClaimMerkleProof will verify the maxQuantityInAllowlist value with hashed leaf in the allowlist
@@ -78,7 +74,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
7874
* Mark the claimer's use of their position in the allowlist. A spot in an allowlist
7975
* can be used only once.
8076
*/
81-
usedAllowlistSpot[activeConditionId].set(merkleProofIndex);
77+
usedAllowlistSpot[activeConditionId].set(uint256(uint160(_dropMsgSender())));
8278
}
8379

8480
// Update contract state.
@@ -182,7 +178,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
182178
revert("not in allowlist");
183179
}
184180

185-
if (usedAllowlistSpot[conditionId].get(merkleProofIndex)) {
181+
if (usedAllowlistSpot[conditionId].get(uint256(uint160(_claimer)))) {
186182
revert("proof claimed");
187183
}
188184

contracts/extension/DropSinglePhase1155.sol

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ abstract contract DropSinglePhase1155 is IDropSinglePhase1155 {
5757
*/
5858

5959
// Verify inclusion in allowlist.
60-
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof(
61-
_tokenId,
62-
_dropMsgSender(),
63-
_quantity,
64-
_allowlistProof
65-
);
60+
(bool validMerkleProof, ) = verifyClaimMerkleProof(_tokenId, _dropMsgSender(), _quantity, _allowlistProof);
6661

6762
// Verify claim validity. If not valid, revert.
6863
// when there's allowlist present --> verifyClaimMerkleProof will verify the maxQuantityInAllowlist value with hashed leaf in the allowlist
@@ -84,7 +79,7 @@ abstract contract DropSinglePhase1155 is IDropSinglePhase1155 {
8479
* Mark the claimer's use of their position in the allowlist. A spot in an allowlist
8580
* can be used only once.
8681
*/
87-
usedAllowlistSpot[activeConditionId].set(merkleProofIndex);
82+
usedAllowlistSpot[activeConditionId].set(uint256(uint160(_dropMsgSender())));
8883
}
8984

9085
// Update contract state.
@@ -199,7 +194,7 @@ abstract contract DropSinglePhase1155 is IDropSinglePhase1155 {
199194
revert("not in allowlist");
200195
}
201196

202-
if (usedAllowlistSpot[conditionId[_tokenId]].get(merkleProofIndex)) {
197+
if (usedAllowlistSpot[conditionId[_tokenId]].get(uint256(uint160(_claimer)))) {
203198
revert("proof claimed");
204199
}
205200

0 commit comments

Comments
 (0)