coinbase / coinbase-wallet-sdk

An open protocol that lets users connect their mobile wallets to your DApp
https://coinbase.github.io/coinbase-wallet-sdk/
MIT License
1.5k stars 576 forks source link

Bug: signTypedData using Coinbase Wallet not working #1451

Open ceduarte25 opened 4 days ago

ceduarte25 commented 4 days ago

Describe the bug

I am doing signing of EIP 712 message using Metamask and Coinbase wallet. I connected both using wagmi connectors as well. The signTypedData is working fine when I am on Metamask so I was expecting it will work on Coinbase as well. But when I am trying to sign on Coinbase, its given me this error:

UnknownRpcError: An unknown RPC error occurred.
Details: hashFuncMap[method] is not a function

Steps

Link to Minimal Reproducible Example

https://stackblitz.com/edit/new-wagmi-hys7ma?file=src%2Fwagmi.ts,src%2FApp.tsx,src%2Fmain.tsx

Steps To Reproduce

  1. Click connect with metamask
  2. Click sign once connected, the metamask popup will show up with correct message data
  3. Disconnect with metamask and connect with coinbase
  4. Click sign once connected again, it will show the error

Expected behavior

It should work and show the signing message just like the metamask.

Version

No response

Additional info

No response

Desktop

No response

Smartphone

No response

ceduarte25 commented 4 days ago

I am using the latest wagmi version to integrate coinbase wallet. Open the issue here https://github.com/wevm/wagmi/issues/4414 and they mentioned that

This is likely a Coinbase Wallet SDK bug

hieronymus777 commented 1 day ago

Thanks for reporting this issue.

When we used the reproducible steps, we noticed that making this change to the sample:

App.tsx
...
-   const { signTypedData } = useSignTypedData();
+   const { signTypedData, data } = useSignTypedData();

...
+  <div>Signature:{data}</div>
...

Results in

To clarify - was that just an issue in the reproduction steps or was that the source of the original bug as well?

ceduarte25 commented 1 day ago

Thanks for the reply @hieronymus777

However, this doesn't work on my side.

App.tsx
...
-   const { signTypedData } = useSignTypedData();
+   const { signTypedData, data } = useSignTypedData();

...
+  <div>Signature:{data}</div>
...

And also to clarify, this is the source of original bug, wagmi dev said it has something to do with this https://github.com/coinbase/coinbase-wallet-sdk/blob/8891097da975f8a1a51c144dc210b563f2f147ff/packages/wallet-sdk/src/sign/walletlink/WalletLinkSigner.ts#L445