Skip to content

Commit d810a5d

Browse files
committed
refactor: use leaf directly as hasClaimed key in airdrop
The leaf already encodes msg.sender in its preimage, making the extra keccak256(abi.encode(msg.sender, leaf)) wrapper redundant.
1 parent f0e9619 commit d810a5d

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

claim_contracts/src/ClaimableAirdrop.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ contract ClaimableAirdrop is
3030
/// @notice Merkle root of the claimants.
3131
bytes32 public claimMerkleRoot;
3232

33-
/// @notice Mapping tracking claimed leaves per address.
34-
/// @dev Key is keccak256(abi.encode(claimer, leaf)), value is true if claimed.
33+
/// @notice Mapping tracking claimed leaves.
34+
/// @dev Key is the Merkle leaf itself.
3535
mapping(bytes32 => bool) public hasClaimed;
3636

3737
/// @notice Event emitted when a claimant claims the tokens.
@@ -163,8 +163,7 @@ contract ClaimableAirdrop is
163163
)
164164
);
165165

166-
bytes32 claimKey = keccak256(abi.encode(msg.sender, leaf));
167-
require(!hasClaimed[claimKey], "Stage already claimed");
166+
require(!hasClaimed[leaf], "Stage already claimed");
168167

169168
bool verifies = MerkleProof.verify(
170169
merkleProof,
@@ -173,7 +172,7 @@ contract ClaimableAirdrop is
173172
);
174173
require(verifies, "Invalid Merkle proof");
175174

176-
hasClaimed[claimKey] = true;
175+
hasClaimed[leaf] = true;
177176
}
178177

179178
/// @notice Update the Merkle root.

0 commit comments

Comments
 (0)