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

Fix issue signing using WC for some wallets #528

Merged
merged 3 commits into from
May 5, 2022
Merged

Conversation

anxolin
Copy link
Contributor

@anxolin anxolin commented May 5, 2022

Summary

This PR fixes the issue with 1inch wallet. Resullt of the review #496

Short description

This PR fixes the issue where, when trading, the user was prompted to sign only a hash instead of the JSON with all the order details.

This was happening to 1inch wallet, and possibly other wallets too.

Before, in 1inch wallet
IMG_5904

After, in 1inch wallet
IMG_5905

Short technical description

Uses a new version of the smart contracts which allows us to use eth_signTypedData instead of eth_signTypedData_v4 for signing.

Longer explanation

The issue was making the signing method to default to ETHSIGN instead of using EIP-712

This is because the wallet was not understanding the signing method we provide with the request. And the app tries to downgrade to v3 and ETHSIGN if this is the case.

The actual problem is that by upgrading web3-react, a new wallet-connect version came with it. This version was using a different wallet connect provider (@walletconnect/ethereum-provider instead of @walletconnect/web3-provider).

This shouldn't be a big deal, because they generate the same signing request. However, at some point for the old version, wallet connect was replacing the signing method name from eth_signTypedData_v4 to just eth_signTypedData.

Apparently 1inch wallet understand the latter but not the former.

Note for the reviewers

Please excuse me for adding all the new org changes for the NPM package.

Allow me this in this case. I can point out to the only 2 changes, please see the comments in the code.

To Test

  1. Sign an order with 1inch wallet in IOS.
  2. Verify you see the JSON details with all the order fields

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2022

CLA Assistant Lite:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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


You can retrigger the CLA Action by commenting recheckcla in this Pull Request

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2022

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

@anxolin anxolin marked this pull request as ready for review May 5, 2022 12:47
@anxolin anxolin requested review from alfetopito and a team May 5, 2022 12:47
@anxolin anxolin changed the title Use cowprotocol NPM package and allow to sign using default signer Fix issue signing using WC for some wallets May 5, 2022
@@ -137,16 +137,19 @@ async function _signPayload(
payload: any,
signFn: typeof _signOrder | typeof _signOrderCancellation,
signer: Signer,
signingMethod: 'v4' | 'int_v4' | 'v3' | 'eth_sign' = 'v4'
signingMethod: 'default' | 'v4' | 'int_v4' | 'v3' | 'eth_sign' = 'v4'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now allow to specify the "default" version. In this case, will be same as v4, at least now. In the future who knows :)

Setting to default is what makes us to send the RPC call with eth_signTypedData instead of eth_signTypedData_v4

): Promise<SigningResult> {
const signingScheme = signingMethod === 'eth_sign' ? SigningScheme.ETHSIGN : SigningScheme.EIP712
let signature: Signature | null = null

let _signer
try {
switch (signingMethod) {
case 'default':
_signer = new TypedDataVersionedSigner(signer)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use the default, we don't specify the version. Will use eth_signTypedData

Co-authored-by: dave <[email protected]>
@anxolin
Copy link
Contributor Author

anxolin commented May 5, 2022

I'll merge to consolidate in staging so we can start testing there asap

please, postmerge reviews are needed

@anxolin anxolin merged commit 1a7b9d4 into release/1.14 May 5, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2022
@elena-zh
Copy link

elena-zh commented May 5, 2022

I can see the JSON with all the order details when signing orders using 1Inch, but the this fix does not resolve issues with an intermediate step (opening AppStore) when signing all types of transactions using this wallet.

@alfetopito alfetopito deleted the fix-1inch branch May 5, 2022 14:05
Copy link
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants