function claim(address account, uint256 amount, bytes32[] calldata merkleProof) external payable {
if (msg.value != FEE) {
revert MerkleAirdrop__InvalidFeeAmount();
}
bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount))));
if (!MerkleProof.verify(merkleProof, i_merkleRoot, leaf)) {
revert MerkleAirdrop__InvalidProof();
}
emit Claimed(account, amount);
i_airdropToken.safeTransfer(account, amount);
}
+ modifier validFee() {
+ require(msg.value == FEE, "MerkleAirdrop__InvalidFeeAmount");
+ _;
+ }
+ modifier validMerkleProof(address account, uint256 amount, bytes32[] calldata merkleProof) {
+ bytes32 leaf = keccak256(abi.encode(account, amount));
+ require(MerkleProof.verify(merkleProof, i_merkleRoot, leaf), "MerkleAirdrop__InvalidProof");
+ _;
+ }
+ function claim(address account, uint256 amount, bytes32[] calldata merkleProof) external payable validFee validMerkleProof(account, amount, merkleProof) {
- function claim(address account, uint256 amount, bytes32[] calldata merkleProof) external payable {
- if (msg.value != FEE) {
- revert MerkleAirdrop__InvalidFeeAmount();
- }
- bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount))));
- if (!MerkleProof.verify(merkleProof, i_merkleRoot, leaf)) {
- revert MerkleAirdrop__InvalidProof();
- }
emit Claimed(account, amount);
i_airdropToken.safeTransfer(account, amount);
}