connectkit icon indicating copy to clipboard operation
connectkit copied to clipboard

[BUG] Connector Deeplinks are not working

Open eduardopelitti opened this issue 2 months ago • 0 comments

Describe the bug

When using a connector that requires Deeplinks to trigger connection requests to desktop apps, it always shows the QR code.

To reproduce

Choose any connector that requires deeplinks to work (e.g.: Zerion), but in our case we patched the library to support the Bloom Wallet, a desktop wallet.

Expected behavior

When choosing a connector that requires deeplinks to work, it should open the deeplink.

Screenshots

Screenshot 2024-04-29 at 12 45 46 Screenshot 2024-04-29 at 12 45 49

Environment details

Browser: Brave, Safari, Chrome.

Additional context

The issue appears to be in the following file:

https://github.com/family/connectkit/blob/main/packages/connectkit/src/components/Common/ConnectorList/index.tsx, in these lines:

let deeplink =
    !wallet.isInstalled && isMobile
      ? wallet.getWalletConnectDeeplink?.(uri ?? '')
      : undefined;

  const redirectToMoreWallets = isMobile && isWalletConnectConnector(wallet.id);
  if (redirectToMoreWallets) deeplink = undefined; // mobile redirects to more wallets page

  return (
    <ConnectorButton
      type="button"
      as={deeplink ? 'a' : undefined}
      href={deeplink ? deeplink : undefined}
      disabled={context.route !== routes.CONNECTORS}
      onClick={
        deeplink
          ? undefined
          : () => {
              if (redirectToMoreWallets) {
                context.setRoute(routes.MOBILECONNECTORS);
              } else {
                context.setRoute(routes.CONNECT);
                context.setConnector({ id: wallet.id });
              }
            }
      }
    >

Notice that the logic conditions for deeplink will never be met on a real scenario:

    let deeplink =
    !wallet.isInstalled && isMobile
      ? wallet.getWalletConnectDeeplink?.(uri ?? '')
      : undefined;
     

So a user with the installed library and using the dApp from desktop, will never use the deeplink, necessary to open the connection request in the Wallet.

Changing these conditions to just wallet.isInstalled makes the deep links work properly, but I'm not sure how it affects the rest of the cases that you're handling there.

We can work on a PR to solve this, but would need some additional guidance.


Additional context from the original issue:

https://github.com/family/connectkit/pull/353#issuecomment-2083229149

Special thanks to @MarkNerdi from the Bloom team for helping out and pointing us in the right direction.

eduardopelitti avatar Apr 30 '24 20:04 eduardopelitti