Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make has claimed public #10

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Dropper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract Dropper {
error ExpirationRecipientIsZero();

mapping(uint256 => DropData) public drops;
mapping(uint256 => mapping(address => bool)) private _claimed;
mapping(uint256 => mapping(address => bool)) public hasClaimed;

/// @notice The number of drops created on this contract
uint256 public numDrops;
Expand Down Expand Up @@ -214,13 +214,13 @@ contract Dropper {
DropData storage drop = drops[dropId];

if (drop.expirationTimestamp <= block.timestamp || block.timestamp < drop.startTimestamp) revert DropNotLive();
if (_claimed[dropId][msg.sender]) revert DropAlreadyClaimed();
if (hasClaimed[dropId][msg.sender]) revert DropAlreadyClaimed();
if (drop.claimedTokens + amount > drop.totalTokens) revert InsufficientTokensRemaining();

bytes32 leaf = keccak256(abi.encodePacked(msg.sender, amount));
if (!MerkleProof.verifyCalldata(merkleProof, drop.merkleRoot, leaf)) revert InvalidMerkleProof();

_claimed[dropId][msg.sender] = true;
hasClaimed[dropId][msg.sender] = true;
drop.claimedTokens += amount;

address tokenAddress = drop.tokenAddress;
Expand Down
1 change: 1 addition & 0 deletions test/Dropper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ contract DropperTest is PRBTest, StdCheats {
dropper.claim(dropId, amount, proof);

assertEq(token.balanceOf(member), amount);
assertTrue(dropper.hasClaimed(dropId, member));
}

// All have claimed
Expand Down