Skip to content

Commit

Permalink
feat: record zkid
Browse files Browse the repository at this point in the history
  • Loading branch information
ququzone committed Feb 10, 2025
1 parent aa5fa87 commit 12dfd77
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/VerifyingClaimer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract VerifingClaimer is Ownable {
error ZeroAddress();
error ClaimEnded();
error ClaimedAccount(address account);
error ClaimedProof();
error ClaimedZkId(bytes32 zkId);
error InvalidRewardProof();
error InvalidValidator(address validator);

Expand All @@ -28,7 +28,7 @@ contract VerifingClaimer is Ownable {
uint256 public immutable endTimestamp;
address public validator;
mapping(address => bool) public claimedAccount;
mapping(bytes32 => bool) public claimedProof;
mapping(bytes32 => bool) public claimedZkId;

constructor(address _vault, address _validator, bytes32 _root, uint256 _endTimestamp) Ownable(msg.sender) {
if (_endTimestamp < block.timestamp) {
Expand All @@ -54,6 +54,7 @@ contract VerifingClaimer is Ownable {
address _account,
bool _doubleCheck,
uint256 _amount,
bytes32 _zkId,
bytes calldata signature,
bytes32[] calldata _rewardProof
) external {
Expand All @@ -63,6 +64,9 @@ contract VerifingClaimer is Ownable {
if (claimedAccount[_account]) {
revert ClaimedAccount(_account);
}
if (claimedZkId[_zkId]) {
revert ClaimedZkId(_zkId);
}
bytes32 node = keccak256(abi.encodePacked(_account, _doubleCheck, _amount));
if (_doubleCheck) {
address _validator = node.recover(signature);
Expand All @@ -75,6 +79,7 @@ contract VerifingClaimer is Ownable {
}

claimedAccount[_account] = true;
claimedZkId[_zkId] = true;
vault.claim(_account, _amount);
emit Claim(_account, _amount);
}
Expand Down

0 comments on commit 12dfd77

Please sign in to comment.