near / wallet-selector

This is a wallet selector modal that allows users to interact with NEAR dApps with a selection of available wallets.
https://near.github.io/wallet-selector/
Apache License 2.0
152 stars 155 forks source link

WalletConnect: Unable to sign transaction after a recent update from wallet-selector #454

Closed andy-verida closed 2 years ago

andy-verida commented 2 years ago

Describe the bug Unable to sign transaction after a recent update from wallet-selector, more specifically that the changes of PR https://github.com/near/wallet-selector/pull/441

Some changes I made to adapt to the new version of wallet-selector

And:

To Reproduce Steps to reproduce the behavior:

  1. Go to website 'https://near.github.io/wallet-selector/'
  2. Click on 'Log In' button
  3. Choose 'WalletConnect'
  4. Scan the QR code
  5. Approve request and logged in
  6. Type in a new message
  7. Add a donation
  8. Click on 'Sign'
  9. On wallet app: Approve request
  10. See an error 'Failed to add message'

More on debugging:

  1. Clone repo 'https://github.com/near/wallet-selector'
  2. Build and run it locally
  3. Can reproduce the same issue with steps above

Expected behavior Expect success sign message with a donation

Screenshots Here's a record of the issue run locally with sourcemap: https://www.loom.com/share/577e67abb88a44888fe3f8191b8fb03f

Device (please complete the following information):

Additional context An old issue https://github.com/near/wallet-selector/issues/373 that I got instructions and made it's working, but now it's broken.

kujtimprenkuSQA commented 2 years ago

Hey, @andy-verida thank you for raising this issue.

I have tried earlier to signIn, signOut, signAndSendTransaction with Wallet Connect and it worked for me this is what I did:

You can either use the published version of Wallet Selector: https://near.github.io/wallet-selector/ Or in locally switch to main branch run git pull remove dist and node_modules and then run this command to make a fresh build for all packages:

yarn && yarn build:modal-ui && yarn build:all && yarn nx serve react

Earlier I updated the WalletConnect dependencies in the Web Examples you can find the Wallet Example here:

https://github.com/kujtimprenkuSQA/web-examples/ And checkout to this branch SQC-170/bridge-wallet-poc-update-deps

Then go to /wallets/react-wallet-v2 Run this: cp .env.local.example .env.local Update your WalletConnect projectID in .env.local

In the end run:

yarn && yarn dev

kujtimprenkuSQA commented 2 years ago

UPDATE:

After some more investigation, the issue seems to be the mismatch of near-api-js version between the dApp and WalletSelector or even the Wallet itself.

To avoid running into this issue we will need to set near-api-js as a peer dependency for the wallet-connect package too, there's already a PR https://github.com/near/wallet-selector/pull/455 in progress about this and as soon as it's merged we can prepare a patch release for this bug.

In the meantime just to let you know we usenear-api-js version v^0.44.2 in the wallet selector use this version in your projects until we make the release, we will let you know when we do.

andy-verida commented 2 years ago

@kujtimprenkuSQA thanks for your help, and sorry for my late reply.

the issue seems related to one of WalletConnect npm dependencies, I still haven't tracked it down.

Today I tried the latest version of WalletConnect 2.0.0-rc.3 and can now sign a donation transaction. https://github.com/WalletConnect/walletconnect-monorepo/releases/tag/2.0.0-rc.3

One remaining issue is the multiple transaction options, It doesn't work and just shows an error on the NEAR Guest book app. Could you please try it sometime?

Screen Shot 2022-09-19 at 20 09 34
kujtimprenkuSQA commented 2 years ago

Thank you for mentioning the issue for sending multiple transactions with WalletConnect, we have noticed it too and fixed it, I believe very soon we will have a release with these fixes.

The issue has been fixed here: https://github.com/near/wallet-selector/pull/463

andy-verida commented 2 years ago

Super! Thanks @kujtimprenkuSQA.

kujtimprenkuSQA commented 2 years ago

Hey, @andy-verida we have published a new versionv7.0.3: https://www.npmjs.com/org/near-wallet-selector Release Notes: https://github.com/near/wallet-selector/releases/tag/v7.0.3

andy-verida commented 2 years ago

Hey, @kujtimprenkuSQA that's great! thanks for letting me know.

chezhe commented 2 years ago

Hi, I saw after 7.0.x, WC_METHODS changed into only get signedTransaction from wallet client, rather than sign and send transaction on wallet client. But I didn't figure out how to sign a transaction with a given public key, KeyPair class in near-api-js didn't support sign with a given public key, so I got an error like this when tx broadcasting:

Transaction is not signed with the given public key
chezhe commented 2 years ago

@kujtimprenkuSQA Now you can use our mobile wallet test WalletConnect 2.0 https://xoth.app/