rainbowkit icon indicating copy to clipboard operation
rainbowkit copied to clipboard

Connecting on mobile v2

Open weber77 opened this issue 1 year ago • 16 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

RainbowKit Version

^2.1.2

wagmi Version

^2.10.2

Current Behavior

when I connect on mobile it opens in metamask but does prompt for connection

https://github.com/rainbow-me/rainbowkit/assets/44323398/5a22f4cd-3be0-46e1-b898-5588e05059eb

Expected Behavior

https://github.com/coder/coder/assets/44323398/04f86d3c-45fe-4358-a213-29f7639652ca

Steps To Reproduce

  1. follow link on a mobile browser:
  2. click connect wallet
  3. select metamask or walletconnect
  4. it opens in metamask but does prompt to confirm

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

CodeSandBox

weber77 avatar Jun 18 '24 20:06 weber77

@weber77 Seems to be a WalletConnect issue. Can you check if you've added your preview link to the "Allowed Domains" section in the WalletConnect dashboard ?

image

0xmkh avatar Jun 19 '24 11:06 0xmkh

@weber77 Seems to be a WalletConnect issue. Can you check if you've added your preview link to the "Allowed Domains" section in the WalletConnect dashboard ?

image

Hey @weber77 It's working after allow domain. But new issue. When i click button that call metamask action, No action at metamask. Need another configuration?

sniper365 avatar Jun 21 '24 19:06 sniper365

same with me no action at MM

HemangVora avatar Jun 21 '24 20:06 HemangVora

@sniper365 Are you saying that whenever you try to connect with MetaMask it doesn't do anything or it's not prompting you to connect to the dApp ? Are you able to show any console errors ?

0xmkh avatar Jun 22 '24 01:06 0xmkh

@magiziz First. MetaMask doesn't do anything when I call action after connect.

sniper365 avatar Jun 23 '24 18:06 sniper365

@sniper365 Can you share a minimal reproducible example ?

0xmkh avatar Jun 24 '24 15:06 0xmkh

@magiziz https://github.com/weber77/wagmi-mobile-test

weber77 avatar Jun 24 '24 15:06 weber77

@weber77 Seems to work for me since i use my own projectId. What happens if you use the projectId below ? https://github.com/rainbow-me/rainbowkit/blob/cdcaa25d66b522119852502f71c8efc02b1abdd9/packages/rainbowkit/src/wallets/getWalletConnectConnector.ts#L95

Don't use that in production, i'm just trying to see if you have configured everything in WalletConnect dashboard.

Also are you using any VPN's ?

0xmkh avatar Jun 25 '24 14:06 0xmkh

Yes, I configured projectId correctly and verified on the walletconnect Yes, I use VPN. that would have some issue?

sniper365 avatar Jun 25 '24 14:06 sniper365

@weber77 Seems to work for me since i use my own projectId. What happens if you use the projectId below ? https://github.com/rainbow-me/rainbowkit/blob/cdcaa25d66b522119852502f71c8efc02b1abdd9/packages/rainbowkit/src/wallets/getWalletConnectConnector.ts#L95

Don't use that in production, i'm just trying to see if you have configured everything in WalletConnect dashboard.

Also are you using any VPN's ?

I used it but it still doesn't work. Here's the repo

https://github.com/rainbow-me/rainbowkit/assets/44323398/17ce0a57-5504-4503-85ff-aadd6711bec7

weber77 avatar Jun 25 '24 15:06 weber77

@magiziz @ I followed wagmi ssr guide The issue is not on wallet connect. On the desktop, third party api hook shows correctly the balance, But on the mobile it doesn't work.

e.g const { availableBalance, availableWithdraw } = useWithdraw(); It's working on desktop but not on the mobile. any further configuration, you think?

sniper365 avatar Jun 25 '24 15:06 sniper365

@sniper365 The reason this might be a WalletConnect issue is because you're not being deep linked correctly into the MetaMask app and we use WalletConnect to initiate the deep links.

You also mentioned that you use VPN ? Can you describe more where the VPN is pointed at ?

Also can you show the console errors you get once trying to connect with MetaMask ?

0xmkh avatar Jun 25 '24 15:06 0xmkh

VPN location is Germany

sniper365 avatar Jun 25 '24 15:06 sniper365

@sniper365 Are you able to fully turn off your VPN and try again ? Make sure to first disconnect in MetaMask and try again using this project id 21fef48091f12692cad574a6f7753643.

Also it would be helpful if you can share any console errors you get on mobile. You can use any android simulators for that.

0xmkh avatar Jun 27 '24 10:06 0xmkh

Everything seem to work just find when using default configs. Without configuring urls

export const rainbowConfig = getDefaultConfig({
    appName: 'PaalX Sniper🎯',
    projectId: PROJECT_ID,
    chains: [mainnet],
    ssr: false, // If your dApp uses server side rendering (SSR)
});

If you absolutely want to choose your own set of wallets, you can use wagmi/connectors

import { connectorsForWallets, getDefaultConfig } from "@rainbow-me/rainbowkit";

import { mainnet } from "wagmi/chains";

import { createConfig, http } from "wagmi";
import { PROJECT_ID } from "@/utils/env";
import { metaMask, walletConnect } from "wagmi/connectors";
import {
    walletConnectWallet,
    metaMaskWallet,
    phantomWallet,

} from "@rainbow-me/rainbowkit/wallets";

const connectors = connectorsForWallets([
    {
        groupName: "Recommended",
        wallets: [metaMaskWallet, walletConnectWallet],
    },
], { projectId: PROJECT_ID, walletConnectParameters: {}, appName: "xxx", appDescription: "", appUrl: "", appIcon: "" });

const wagmiWallets = [walletConnect({
    projectId: PROJECT_ID, metadata: {
        name: 'xxxx',
        description: "xxxx",
        url: "https://xxxx.ai/",
        icons: [""]
    }
}), metaMask()]

function isMobileDevice() {
    return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}
export const wagmiConfig = createConfig({
    connectors: isMobileDevice() ? wagmiWallets : connectors,
    chains: [mainnet],
    transports: {
        [mainnet.id]: http(''),
    },
});

In main.tsx

  <WagmiProvider config={wagmiConfig}> // replace with "rainbowConfig" if you want to use defaults
      <QueryClientProvider client={queryClient}>
        <App />
      </QueryClientProvider>
    </WagmiProvider>

weber77 avatar Jun 27 '24 11:06 weber77

@weber77 Are you saying everything seems to work with getDefaultConfig ? If so that's great.

Here is another alternative to your wagmi/connectors approach:

const connectors = connectorsForWallets(
  [
    {
      groupName: "Recommended",
      wallets: [metaMaskWallet, walletConnectWallet],
    },
  ],
  {
    projectId: "...",
    appName: "...",
    // Add your own WalletConnect parameters
    walletConnectParameters: {
      metadata: {
        name: "xxxx",
        description: "xxxx",
        url: "https://xxxx.ai/",
        icons: [""],
      },
    },
  }
);

0xmkh avatar Jun 27 '24 20:06 0xmkh

Closing this issue for now. Feel free to re open this issue if you're still stuck.

0xmkh avatar Jul 02 '24 18:07 0xmkh