feat: supports EIP-712 and EIP-1271 signatures to claim airdrop #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry for the massive PR @andreivladbrg. It was very complicated than I thought, both writing source code and then testing it. Now its ready for your review. I will recommend to read the PR description first.
This should be merged after the following PR:
Changelog
Source code
view
to read only functionsSignatureHash
library to keep signature hashes. This is a better approach as it keeps the campaign related constants separate from the signature related constants.Tests
users.recipient
usingcreateUserAndKey
function as we need private key to create signatures.Base
test contract and Integration base contractgetIndexInMerkleTree
andgetMerkleProof
functions replacing hardcoded use ofINDEX1
andindex1Proof
to avoid manual errorsclaimViaSig
and ignored what is already being thoroughly tested throughclaim
andclaimTo
. This is also why I didn't write fuzz tests for it.Types.sol
for details.Some notes
tests/utils/Utilities.sol
contain signature utilities but note that it uses solidity whereas the correct approach is to useeth_signTypedData_v4
so its not being tested. I will wait for foundry to release the new cheatcode for that. Nevertheless, using approach below, I have verified that signature are correctly generated.To generate EIP-712 signature, run the following in your browser:
Load your address:
Define "TypedData":
Call "eth_signTypedData_v4":
It will then show you something like this:
Once you sign it, it will then display the signature in the console.
Some reference: