-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reservations #7
Reservations #7
Conversation
733ca1a
to
21bf80d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I hope we can come up with a cleaner design.
|
||
grant.checkReservationValidity(timestamp); | ||
|
||
address signer = ECDSA.recover(keccak256(abi.encode(timestamp, nullifierHash)), signature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the OpenZeppelin version has additional restrictions on the signature, which are not necessary for our application. It also doesn't hurt, as long as we take care of this at the signer side (otherwise ~50% of signatures will be rejected).
SummarySince the beginning users could "reserve" their grants instead of claiming in case they are not verified yet. However, the redemption of those reservations was not yet supported on the contract. This PR implements this redemption process. ReservationsDue to cost considerations the reservation happens fully off-chain. A backend service acting as a "timestamping" service signs the current timestamp and the user's nullifier and stores it in the db. At time of redemption, this signature is submitted on-chain together with the same parameters as a normal claim. DesignThe previous (audited) version of the contracts did not include the possibility of accessing the nullifiers map publicly. However, this is an issue because at the time of redemption one also needs to know whether the same grant might have been also claimed as the "current grant". Intended behaviour
|
assertEq(token.balanceOf(user), grant.getAmount(20)); | ||
} | ||
|
||
/// @notice Tests that the user is able to claim tokens if the World ID proof is valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy-pasta comment needs to be updated :)
// No future grants can be claimed. | ||
if (grantId >= this.getCurrentId()) revert InvalidGrant(); | ||
|
||
// Only grants 20 and above can be reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Only grants 21 and above can be reserved
No description provided.