-
Notifications
You must be signed in to change notification settings - Fork 2k
vm.signTypedData or vm.generateEIP712Digest #3330
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
Comments
I had a similar problem, but I was able to work it around with
It has an advantage over a VM built-in of not enforcing any particular signing convention, it's very elastic and thus future-proof. |
hmm - yes this does get closer to solving the problem, but I think there is still a use case for true EIP712 digest generation. This would still be easy to generate false positives against. |
By far the best solution would be to have support for EIP-721 in Solidity, it could then do the magic static typing like it does with I mean, don't mind my opinion too much, I'm not a Foundry developer, so it's not up to me to make any decisions, I'm just a user who wants to have Foundry robust. |
There's no easy way in solidity to have a generic EIP-712 cheat since the data being signed over varies with each implementation. Instead, you should write your own helper contracts based on your specific contract. See https://book.getfoundry.sh/tutorials/testing-eip712 for an example of how to do this |
There is an open proposal to add this as a core feature to solidity: ethereum/solidity#14157 I think it makes a lot of sense because the work to implement correct hashes is labor-intensive and error-prone. Mostly, because you have to generate a lot of typehashes. With nested structs, the labor and the error proneness increase exponentially. Javascript libraries have this included, so currently the best guess to test your typehashes is to include some JS into your repo. Either way, it would be awesome to be able to test this natively in foundry. It would even help a lot to have a library that generates the type hashes. As a step. |
Hello, I'd like to reopen this issue. I am building safe-utils in order to automate the proposal of Safe transactions through Foundry, and one common use case is Safe signers who use Ledger wallets. It seems that I cannot simply Update: I opened a specific issue #10281 |
Component
Forge
Describe the feature you would like
For EIP712 testing, it would be great to have a EIP712 digest generator that creates a 32 byte digest based the types, domain, and values following the algorithm defined in the EIP712 spec, or even a fully built
signedTypedData
cheatcode.I've had a lot of headache recently with EIP712 foundry tests passing when they shouldn't have because there was no way to test if a contract is computing a digest properly.
I am not sure what cheatcodes would look like in solidity, but I imagine passing a it:
Transaction(Person from,Person to,Asset tx)Asset(address token,uint256 amount)Person(address wallet,string name)
abi.encodePacked()
values of the structThis could be a possible interface
Additional context
No response
The text was updated successfully, but these errors were encountered: