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

Bug: MetaMask mobile wallet-connect v2 support #1783

Closed
1 task done
L03TJ3 opened this issue Jun 22, 2023 · 35 comments
Closed
1 task done

Bug: MetaMask mobile wallet-connect v2 support #1783

L03TJ3 opened this issue Jun 22, 2023 · 35 comments
Assignees
Labels
bug Something isn't working

Comments

@L03TJ3
Copy link

L03TJ3 commented Jun 22, 2023

Current Behavior

MetaMask mobile has released v7 which now should support v2
this unfortunately is not compatible with onboard wallet-connect

  1. they don't support multi-chain connection
  2. there is an unsupported method used (not figured out yet which one)

Expected Behavior

WalletConnect v2 should also work with metamask mobile

Steps To Reproduce

Try wc2 on onboard-demo

What package is effected by this issue?

@web3-onboard/walletconnect

Is this a build or a runtime issue?

Runtime

Package Version

Latest

Node Version

what is used on demo

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Anything else?

No response

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.
@L03TJ3 L03TJ3 added the bug Something isn't working label Jun 22, 2023
@L03TJ3 L03TJ3 changed the title Bug: MetaMask mobile support Bug: MetaMask mobile wallet-connect v2 support Jun 22, 2023
@taylorjdawson
Copy link
Contributor

@L03TJ3 Hey thanks for raising this, we'll take a look and see if we can repro and get back to you

@L03TJ3
Copy link
Author

L03TJ3 commented Jun 26, 2023

@taylorjdawson hey thanks for looking into it

found anything yet, what can we expect?

@sajwanAshish
Copy link

sajwanAshish commented Jun 27, 2023

when can we expect the walletConnect v2 migration update ? @taylorjdawson

@0xleeaki
Copy link
Contributor

0xleeaki commented Jun 28, 2023

+1, same issue for me. Any update yet @taylorjdawson

@sirpy
Copy link

sirpy commented Jun 28, 2023

@taylorjdawson any updates?

@mattfixme
Copy link

same issue for me

@0xleeaki
Copy link
Contributor

Upgrade onboard version.

"@web3-onboard/core": "^2.20.2",
"@web3-onboard/walletconnect": "^2.3.9",

Config wallet connect module.

const walletConnect = walletConnectModule({
  version: 2,
  projectId: import.meta.env.VITE_WALLET_CONNECT_ID,
  requiredChains: [],
});
const getConnectedWalletInfo = (wallet: WalletState | null) => {
  if (!wallet) {
    return {
      account: undefined,
      label: undefined,
      chainId: undefined,
    };
  }

  const account = wallet.accounts.filter((a) => isAddress(a.address))?.[0];
  if (!account) {
    return {
      account: undefined,
      label: undefined,
      chainId: undefined,
    };
  }

  return {
    account: getAddress(account.address),
    label: wallet.label,
    chainId: +wallet.chains[0].id,
  };
};

Hope this help!

@mattfixme
Copy link

Upgrade onboard version.

"@web3-onboard/core": "^2.20.2",
"@web3-onboard/walletconnect": "^2.3.9",

Config wallet connect module.

const walletConnect = walletConnectModule({
  version: 2,
  projectId: import.meta.env.VITE_WALLET_CONNECT_ID,
  requiredChains: [],
});
const getConnectedWalletInfo = (wallet: WalletState | null) => {
  if (!wallet) {
    return {
      account: undefined,
      label: undefined,
      chainId: undefined,
    };
  }

  const account = wallet.accounts.filter((a) => isAddress(a.address))?.[0];
  if (!account) {
    return {
      account: undefined,
      label: undefined,
      chainId: undefined,
    };
  }

  return {
    account: getAddress(account.address),
    label: wallet.label,
    chainId: +wallet.chains[0].id,
  };
};

Hope this help!

Unfortunately, not work for me😭

@0xleeaki
Copy link
Contributor

try
"@web3-onboard/react": "^2.8.8",

@mattfixme
Copy link

no, not work for me

@L03TJ3
Copy link
Author

L03TJ3 commented Jun 29, 2023

@0xleeaki
Okay we got a step closer and it is with above suggestion possible to connect
Problems I run into:
It only works on initial connected chain.
Switching chain on dapp side and doing a request does not pop-up in wallet
Switching chain from within metamask wallet triggers on dapp

event.ts:98 Uncaught Error: invalid address (argument="address", value="0", code=INVALID_ARGUMENT, version=address/5.7.0)

@Adamj1232
Copy link
Member

@L03TJ3 @mattfixme can you give the pre-release, alpha version of @web3-onboard/walletconnect a try at version 2.4.0-alpha.2 when you have a moment? If all good I can push a release today.

@andriimoonmana
Copy link

andriimoonmana commented Jun 29, 2023

there is an unsupported method used (not figured out yet which one)

@L03TJ3
I got err creating new session: Error: User rejected methods when connecting with MetaMask as well. Found a way to fix it:
You need to fill optional explore field in appMetadata, it will fix this issue.

appMetadata: {
        name: "App Name",
        icon: "icon URL",
        logo: "logo URL",
        description: "App Description",
        explore: "App URL"
      }

All of these fields should be filled
explore field is optional so this is confusing, same as an error message that points to rejected methods

@mattfixme
Copy link

there is an unsupported method used (not figured out yet which one)

@L03TJ3 I got err creating new session: Error: User rejected methods when connecting with MetaMask as well. Found a way to fix it: You need to fill optional explore field in appMetadata, it will fix this issue.

appMetadata: {
        name: "App Name",
        icon: "icon URL",
        logo: "logo URL",
        description: "Add Description",
        explore: "game URL"
      }

All of these fields should be filled explore field is optional so this is confusing, same as an error message that points to rejected methods

not work for me
error

the codesandbox demo is here

@mattfixme
Copy link

@L03TJ3 @mattfixme can you give the pre-release, alpha version of @web3-onboard/walletconnect a try at version 2.4.0-alpha.2 when you have a moment? If all good I can push a release today.

not work

@L03TJ3
Copy link
Author

L03TJ3 commented Jun 29, 2023

@Adamj1232
Works.. sort of
Whats fixed:

  • Able to connect
  • Dapp doesn't break on invalid address when switching from within metamask

The only thing I encounter is that switching from dapp does not make sense with metamask
it works solely when switching from wallet-itself > dapp switches too > tx requests come in

but not sure if this is a mm thing to fix, or something you can do/change to make it work?

@Adamj1232
Copy link
Member

@mattfixme I removed Goerli as a required chain and was able to connect. Please see the walletconnect docs here for exposed config settings - https://docs.walletconnect.com/2.0/web/providers/ethereum#required-and-optional-chains

@Adamj1232
Copy link
Member

@L03TJ3 interesting, can you clarify the switching that is an issue?
Atm I think that is an issue with WC/MM handling. We try to avoid adding handling within specific libraries(walletconnect) for specific wallets (metamask). Maybe @finessevanes has some ideas?

@mattfixme
Copy link

@mattfixme I removed Goerli as a required chain and was able to connect. Please see the walletconnect docs here for exposed config settings - https://docs.walletconnect.com/2.0/web/providers/ethereum#required-and-optional-chains

thx, i will try

@L03TJ3
Copy link
Author

L03TJ3 commented Jun 29, 2023

@Adamj1232
Basically setChain initiated by the dapp does nothing with metamask wallet
Could be that its just something that a dapp should handle ('switch chain in wallet')
problem is that there is no way of knowing which wallet is connect with wallet-connect

is that something solvable by onboard?

@ganchoradkov
Copy link
Contributor

Hey guys, to give you an update on the issue, MM currently has a bug where they don't acknowledge requests that are for different chains than the wallet's current active one. We're working with their team to resolve this asap

@saisumit
Copy link

Can you please fix this asap... hung on production..

@Adamj1232
Copy link
Member

Hey guys, to give you an update on the issue, MM currently has a bug where they don't acknowledge requests that are for different chains than the wallet's current active one. We're working with their team to resolve this asap

A note to all around this issue: @ganchoradkov is part of the awesome WalletConnect team and they are helping resolve this issue. We will keep this issue updated as progress is made.

@Adamj1232
Copy link
Member

Adamj1232 commented Jul 10, 2023

@saisumit @L03TJ3 We have an alpha package available as of PR #1822 to help solve a part of the MM/WC issue
As a temp work around please add an explore URL to the onboard initialization's appMetaData object if you dont already have one.

MetaMask added a requirement that a URL is passed with WalletConnect support and the appMetaData.explorer is passed into walletConnect v2 initialization.
I will get a PR together to add the requirement to the TS object and all docs.
Thank you for the feedback and community support!
#1822 introduces a specific prop(dappUrl) for the walletConnect package along with deeper validation and error handling.
We also updated the WalletConnect package to the latest version to solve the chain issues

We are still working with the WC/MM teams handle multichain more smoothly

@Tsirov
Copy link

Tsirov commented Jul 11, 2023

@Adamj1232 For appMetaData .explore what url I need to put?

@Adamj1232
Copy link
Member

Adamj1232 commented Jul 11, 2023

@Adamj1232 For appMetaData .explore what url I need to put?

Your dapps URL or you can use version 2.4.2-alpha.1 of @web3-onboard/walletconnect and pass in a dappUrl prop as part of your init object to the module initialization.

@amitsharma101
Copy link

@ganchoradkov any update on the switching chain issue?

@Kirby-WalletConnect
Copy link

Confirmed some fixes related to this are expected to come in the next Metamask release (estimating early Aug - ~Aug 7), will update this as soon as I see it hit stores.

@ryespresso
Copy link

Setting appMetaData.explorer does not appear to resolve this issue.

@Adamj1232
Copy link
Member

@ryeshrimp there is a dappUrl property within the walletconnect init that is the main target that needs to be set for MM support. See - https://onboard.blocknative.com/docs/wallets/walletconnect#usage

@YaminZheng
Copy link

为什么有时候可以切换。有时候没反应?有人解决了这个问题吗?

@Adamj1232
Copy link
Member

@YaminZheng could you please use english here for readability of the team and community?
Will look into this issue this week

@Adamj1232
Copy link
Member

Hi @L03TJ3 I am currently looking into with the support of the WalletConnect team (@ganchoradkov @finessevanes).
From my testing this seems to be a MetaMask issue as other wallets connected through WalletConnect are behaving normally.
When I switch chains through the app nothing happens in either the wallet or the app (as the app listens for response on the chainsChanged event from WC to update). - I think the is the biggest problem for dapps is not be able to change the chain prior to sending a transaction.
When I change the chain within the MetaMask app there isn’t an event that reflects this through the WC connector.
If I send a transaction with a setChain call proceeding the transaction call the chain update is sent to the MetaMask wallet and seen within the wallet.
When performing the same steps with Trust the mobile Trust wallet updates along with the app.

@Adamj1232
Copy link
Member

PR in the works to fix this issue #1926

@Adamj1232
Copy link
Member

A fix for this issue has been release with the latest version of @web3-onboard/walletconnect - Please upgrade to the latest stable version. Thank you for reporting and please feel free to continue the conversation here if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests