-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Add ERC20 Permit (EIP-2612) #2237
Conversation
Previous discussion about EIP712 in #1810. |
The Uniswap tests might be a good starting place to write the tests for this. We can also look into using |
abi.encode( | ||
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), | ||
keccak256(bytes(name())), | ||
keccak256(bytes("1")), // Version |
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.
It seems we should use pure internal method version()
or permitVersion()
for this.
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.
Are you suggesting an internal setter for users to set their own version field? I'm actually not sure what all the use cases for version
are, if you have insights on this that'd be extremely helpful.
That said we do need to provide a way for either the version or domain separator to be queried, as noted here.
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.
I believe version makes sense when behaviour changes without address change (upgradablity?). So I mean version method could be overrided by user, or maybe should be even abstract.
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.
I see. It'd be great to have some examples to show in the docs.
Regarding implementation, we could have a setter and a getter, where the setter also calls _updateDomainSeparator
and not increase gas costs of permit
that way.
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.
@k06a In this case though the semantics of the signature are defined by the EIP, so I don't see a reason for version
to change.
This comment has been minimized.
This comment has been minimized.
While we still have to work on the tests for this feature, it's kind of on hold because the ERC is in Draft status. |
Stumbled upon this while working on my eth-permit library Might be useful for your unit tests |
@dmihal Looks like it will be useful, thank you! |
With a few modifications, I successfully used the |
@gorgos the new version of eth-permit should work correctly. And feel free to add PRs to https://github.com/dmihal/eth-permit 🙂 |
Is anyone familiar with the finalization status of this EIP? If there are any plans to move it to Final? |
@spalladino @mverzilli The code is ready for review. I still need to review the documentation a little bit. If you have any opinions on that front let me know. |
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!
Co-authored-by: Santiago Palladino <spalladino@gmail.com>
Fixes #2206
This adds support for the ERC20 Permit extension, tentatively called ERC2612 and based on the discussion in ethereum/EIPs#2612. The EIP is still in draft status,
we'll need to monitor it for any changes, and will likely not want to publish this code until it is more mature / finalizedso it will go in the drafts directory.This implementation accounts for
ChainID
changing (i.e. a hard fork) while at the same time being as gas efficient as possible.The code and documentation is ready, but the tests are not,
To do
ERC20Permit
vsERC2612Permit
orERC2612