Skip to content

Commit

Permalink
L1
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbir committed Oct 22, 2024
1 parent dd05a84 commit 92e6378
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/MerkleAirdrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "./@openzeppelin/utils/Address.sol";

error MerkleAirdrop__AlreadyClaimed();
error MerkleAirdrop__InvalidProof();
error MerkleAirdrop__SameRoot();

contract MerkleAirdrop is Ownable2Step {
bytes32 public merkleRoot;
Expand All @@ -24,6 +25,10 @@ contract MerkleAirdrop is Ownable2Step {
}

function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
if (_merkleRoot == merkleRoot) {
revert MerkleAirdrop__SameRoot();
}

merkleRoot = _merkleRoot;
emit MerkleAirdrop__MerkleRootSet(_merkleRoot);
}
Expand Down
15 changes: 15 additions & 0 deletions test/TestMerkleAirdrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ contract TestMerkleAirdrop is Test {
assertEq(balanceAfter - balanceBefore, claims[i].amount);
}
}

function test_SetMerkleRoot() external {
vm.startPrank(deployer);
merkleAirdrop.transferOwnership(owner);
vm.stopPrank();

vm.startPrank(owner);
merkleAirdrop.acceptOwnership();

vm.expectRevert(MerkleAirdrop__SameRoot.selector);
merkleAirdrop.setMerkleRoot(root);

merkleAirdrop.setMerkleRoot(bytes32(uint256(42)));
vm.stopPrank();
}
}

struct Claim {
Expand Down

0 comments on commit 92e6378

Please sign in to comment.