Skip to content

Commit 7f2ba05

Browse files
authored
cannot claim with signature with wrong recipient (#88)
* cannot claim with signature with wrong recipient * test that shows cannot claim with wrong signer
1 parent f56959f commit 7f2ba05

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/ZoraTokenCommunityClaim.t.sol

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,41 @@ contract ZoraTokenCommunityClaimTest is Test {
454454
claim.claimWithSignature(signer, recipient, deadline, signature);
455455
}
456456

457+
function testCannotClaimWithWrongClaimTo() public {
458+
uint256 privateKey = 0x1234;
459+
address signer = vm.addr(privateKey);
460+
address recipient = makeAddr("recipient");
461+
address wrongRecipient = makeAddr("wrongRecipient");
462+
uint96 amount = 100 * 1e18;
463+
464+
// Set allocation
465+
address[] memory accounts = new address[](1);
466+
uint96[] memory amounts = new uint96[](1);
467+
accounts[0] = signer;
468+
amounts[0] = amount;
469+
470+
bytes32[] memory compactAllocations = toCompactAllocations(accounts, amounts);
471+
472+
vm.prank(allocationSetter);
473+
claim.setAllocations(compactAllocations);
474+
475+
vm.prank(admin);
476+
claim.completeAllocationSetup(claimStart, originalTokenHolder);
477+
478+
// Warp to claim period
479+
vm.warp(claimStart + 1);
480+
481+
// Create signature
482+
uint256 deadline = block.timestamp + 1 days;
483+
bytes32 digest = _getSignatureDigest(signer, recipient, deadline);
484+
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
485+
bytes memory signature = abi.encodePacked(r, s, v);
486+
487+
// Claim with signature
488+
vm.expectRevert(IZoraTokenCommunityClaim.InvalidSignature.selector);
489+
claim.claimWithSignature(signer, wrongRecipient, deadline, signature);
490+
}
491+
457492
function testSmartWalletClaim() public {
458493
uint256 ownerPrivateKey = 0x1234;
459494
address owner = vm.addr(ownerPrivateKey);

0 commit comments

Comments
 (0)