[Archive] Clicking the metamask icon under "connect with wallet" opens up the coinbase wallet extension

:classical_building: Archived Content from Web3Auth Community

This topic was originally posted by fred on 5/3/2023.
This content has been migrated from our previous community forum to preserve valuable discussions.


Please provide the following details too when asking for help in this category:
After opening the modal, clicking on “connect with wallet” → “metamask” opens up the coinbase wallet extension, it may be beneficial to note that i have both the metamask extension and the coinbase wallet extension

Please provide the Web3Auth initialization and login code snippet below:

const web3auth = new Web3Auth({
      clientId: web3AuthApiKey,
      chainConfig: {
        chainNamespace: CHAIN_NAMESPACES.EIP155,
        chainId,
        rpcTarget: web3JsonRpcUrl,
        blockExplorer: blockExplorerBaseUrl,
      },
      uiConfig: {
        theme: 'dark',
        loginMethodsOrder: ['google', 'facebook', 'twitter', 'github', 'discord'],
        defaultLanguage: 'en',
        appLogo: 'assets/favicon-256.png',
      },
      web3AuthNetwork,
    });
const openloginAdapter = new OpenloginAdapter({
  loginSettings: {
    mfaLevel: 'default',
  },
  adapterSettings: {
    whiteLabel: {
      name: 'Dinari Bridge',
      logoLight: 'https://web3auth.io/community/images/w3a-L-Favicon-1.svg',
      logoDark: 'assets/favicon-256.png',
      defaultLanguage: 'en',
    },
  },
});
web3auth.configureAdapter(openloginAdapter);

// coinbase adapter
const coinbaseAdapter = new CoinbaseAdapter({
  clientId: web3AuthApiKey,
  sessionTime: 3600, // 1 hour in seconds
  web3AuthNetwork,
  chainConfig: {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId,
    rpcTarget: web3JsonRpcUrl,
    blockExplorer: blockExplorerBaseUrl,
  },
});
web3auth.configureAdapter(coinbaseAdapter);

// metamask adapter
const metamaskAdapter = new MetamaskAdapter({
  clientId: web3AuthApiKey,
  sessionTime: 3600, // 1 hour in seconds
  web3AuthNetwork,
  chainConfig: {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId,
    rpcTarget: web3JsonRpcUrl,
    blockExplorer: blockExplorerBaseUrl,
  },
});

// it will add/update  the metamask adapter in to web3auth class
web3auth.configureAdapter(metamaskAdapter);

update for anyone who was still encountering this issue:
I believe that it is related to this javascript - Whenever i click on connect metamask button why it connects the coinbase wallet? - Stack Overflow.

I added the code below for when a user has both metamask and coinbase wallet

web3auth.on(ADAPTER_EVENTS.CONNECTING, (data) => {
      const ethereum = window.ethereum;
      if (!ethereum?.providers) {
        return;
      }
  if (data.adapter === 'coinbase') {
    const provider = ethereum.providers.find((provider) => provider.isCoinbaseWallet);
    if (provider) {
      (ethereum as any).setSelectedProvider(provider);
    }
  } else if (data.adapter === 'metamask') {
    const provider = ethereum.providers.find((provider) => provider.isMetaMask);
    if (provider) {
      (ethereum as any).setSelectedProvider(provider);
    }
  }
});

Hey @fred, thanks for letting us know about the issue. We’ll make sure to fix it in an upcoming release.