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

Coinbase Wallet enableMobileWalletLinking showing Coinbase Wallet open app website #3801

Closed
1 task done
marcusmolchany opened this issue Apr 5, 2024 · 4 comments
Closed
1 task done

Comments

@marcusmolchany
Copy link

Describe the bug

I am trying to use wagmi in a react-native-webview to login to my Expo app using Coinbase Wallet mobile. The webview shows the npm create wagmin@latest site on a next app from vercel. I've included the option enableMobileWalletLinking: true, because we do not want our login page to open up inside of Coinbase Wallet's dapp browser, instead we want to Wallet Link to connect, sign a message, and then stay within our Expo app.

Currently, when we choose Coinbase Wallet as our connection option, we get redirected to Coinbase Wallet, are shown the connect sheet in the Coinbase Wallet app, and then when we return to our app showing the webview, the webview has changed to show a Coinbase Wallet website that forwards us to the iOS App Store.

screenshot
IMG_19ACE33CC395-1

Link to Minimal Reproducible Example

https://stackblitz.com/edit/new-wagmi-wiqtks?file=src%2Fwagmi.ts

Steps To Reproduce

Wagmi Version

2.5.19

Viem Version

2.9.9

TypeScript Version

5.4.4

Check existing issues

Anything else?

No response

@imaksp
Copy link

imaksp commented Apr 19, 2024

Hi, this could possibly be fixed by forcefully upgrading to 3.9.3 version of cb sdk (wagmi is using 3.9.1 fixed version), but not creating PR as draft PR which upgrades it directly to v4 already exists here:
#3784

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@jxom jxom reopened this Apr 26, 2024
@marcusmolchany
Copy link
Author

For anyone experiencing this issue, we got around temporarily by doing:

const coinbaseRedirectUrls = Object.freeze([
  "https://go.cb-w.com/",
  "https://v3eo.app.link/",
]);

export const isCoinbaseRedirectUrl = (url: string): boolean =>
  coinbaseRedirectUrls.some((coinbaseRedirectUrl) =>
    url.startsWith(coinbaseRedirectUrl)
  );

// in our component render function
  return(
        <WebView
          ref={webviewRef}
          source={{ uri: /* your login url */ }}
          onMessage={(event) => {
            // handle postMessage back to react-native-webview
            // with `event.nativeEvent.data)`
          }}
          onNavigationStateChange={(event) => {
            // note: handle coinbase wallet redirect
            if (isCoinbaseRedirectUrl(event.url)) {
              console.log("handling coinbase redirect url", event.url);
              // note: prevent react-native-webview from loading
              // the coinbase redirect url
              webviewRef?.current?.stopLoading();
              // note: use expo Linking to open the coinbase redirect url
              // which will deeplink into the coinbase wallet app
              Linking.openURL(event.url);
              return;
            }
          }}
        />
  );

@tmm
Copy link
Member

tmm commented May 21, 2024

Wagmi now uses the v4 of the CB SDK so this should no longer be an issue.

@tmm tmm closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
Copy link
Contributor

github-actions bot commented Jun 5, 2024

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Wagmi version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants