Skip to content
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

[IMPROVEMENT] Support signTypedData_v4 and use signTypedData_v3 by default in WalletConnect #3350

Merged

Conversation

sssemil
Copy link
Contributor

@sssemil sssemil commented Oct 28, 2021

Description
Change the default signTypedData version used in WalletConnect to v3 and add support for the v4 version.

@sssemil sssemil requested a review from a team as a code owner October 28, 2021 07:59
@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2021

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@sssemil
Copy link
Contributor Author

sssemil commented Oct 28, 2021

I have read the CLA Document and I hereby sign the CLA

@Muradm373
Copy link

Waited this change for long time

@sssemil
Copy link
Contributor Author

sssemil commented Oct 29, 2021

Hey @sethkfman is this good? :)

@sethkfman
Copy link
Contributor

@sssemil Is there a specific dapp you are using to test? We just need to confirm the functionality with QA.

@midgerate
Copy link

@sethkfman you can use snapshot. I can create a version which you can test.

@midgerate
Copy link

@sethkfman

Click this https://bafybeidi4gxba5q7qpl4kr7u4zuks3hfkywkbyhoptf4m6j5s2aky7qw2a.on.fleek.co/#/midgerate.eth/proposal/0x1ccddbe103253ffc71b0ba1759b2ee5902d5717777ddba39159548b4b76a6016

and try to vote with walletconnect + metamask and it will work (FYI, there seems to be a problem with loader so just wait a bit)

Then go to https://bafybeidi4gxba5q7qpl4kr7u4zuks3hfkywkbyhoptf4m6j5s2aky7qw2a.on.fleek.co/#/midgerate.eth/proposal/0xf11b762089e0cbe7307b052390da68ce3a67d61c16f3e615f9d1d062f731520b

and try to vote - This will get stuck because this proposal uses arrays and requires v4 to work correctly.

Then try to use the QA metamask (which I believe includes this fix) and see if it works with the second proposal.

I can help with testing if you tell me how to get the QA build of metamask mobile.

@midgerate
Copy link

@sethkfman is there anything I could help to speed this up?

@sethkfman
Copy link
Contributor

@midgerate & @sssemil In order to maintain backward compatibility the check for payload.method === 'eth_signTypedData' should be removed from v4 (line 212) and added to v3 (line 239). Would you like me to make the change?

@sssemil
Copy link
Contributor Author

sssemil commented Nov 8, 2021

@sethkfman done. Sorry, was away for a week, I don't have a dapp that I can provide for testing.

@sssemil sssemil changed the title Use signTypedData_v4 by default in WalletConnect Use signTypedData_v4 and use signTypedData_v3 by default in WalletConnect Nov 8, 2021
@sssemil sssemil changed the title Use signTypedData_v4 and use signTypedData_v3 by default in WalletConnect Support signTypedData_v4 and use signTypedData_v3 by default in WalletConnect Nov 8, 2021
@midgerate
Copy link

@sethkfman @sssemil I am not sure if this would work with walletconnect, walletconnect only sends signTypedData as method and we should be using v4 as default. isn't v4 compatible with v1 and v3?

@midgerate
Copy link

midgerate commented Nov 9, 2021

@sethkfman done. Sorry, was away for a week, I don't have a dapp that I can provide for testing.

@sssemil I already gave an link to the dapp which can be used to test

@sssemil
Copy link
Contributor Author

sssemil commented Nov 10, 2021

@midgerate you can send custom calls I think, with this - https://docs.walletconnect.com/1.0/client-api#send-custom-request , right?

@midgerate
Copy link

@sssemil I see, cool. I could use that. @sethkfman if you can share the QA build I can test it with snapshot.org and let you know if it works.

@sssemil
Copy link
Contributor Author

sssemil commented Nov 10, 2021

@sethkfman @sssemil I am not sure if this would work with walletconnect, walletconnect only sends signTypedData as method and we should be using v4 as default. isn't v4 compatible with v1 and v3?

v4 has breaking changes, I don't think it works with v3 or older. I would agree that we should use v4 by default. Metamask docs are confusing on the defaults question as well - https://docs.metamask.io/guide/signing-data.html#sign-typed-data-v4 saying that both v3 and v4 are the latest version, and not saying which one is the default one. What makes this even more confusing is that for example if you write tests in hardhat, the default will be v4, and one may end up debugging a weird invalid signature bug for a long time, as I was unfortunate enough to do.

@midgerate
Copy link

@sssemil I can create a PR in the walletConnect repo to also implement v4 method. So it does not matter how we implement backward compatibility in metamask wallet, as long as this PR is merged.

@sssemil
Copy link
Contributor Author

sssemil commented Nov 11, 2021

@sssemil I can create a PR in the walletConnect repo to also implement v4 method. So it does not matter how we implement backward compatibility in metamask wallet, as long as this PR is merged.

sure, why not :)

@sethkfman
Copy link
Contributor

To keep backwards compatibility with our current integrations we should keep payload.method === 'eth_signTypedData' || payload.method === 'eth_signTypedData_v3'. Once wallet connect makes v4 there standard then we can update the logic. I think the PR is acceptable, currently.

@midgerate
Copy link

@sethkfman great! I hope it gets merged soon.

@sssemil
Copy link
Contributor Author

sssemil commented Nov 15, 2021

@sethkfman anything I can do to get this approved?

@sethkfman sethkfman added next release No QA Needed Apply this label when your PR does not need any QA effort. labels Nov 16, 2021
@sethkfman sethkfman changed the title Support signTypedData_v4 and use signTypedData_v3 by default in WalletConnect [IMPROVEMENT] Support signTypedData_v4 and use signTypedData_v3 by default in WalletConnect Nov 16, 2021
Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sethkfman sethkfman merged commit 8248d3e into MetaMask:develop Nov 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
next release No QA Needed Apply this label when your PR does not need any QA effort.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants