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

Unable to select chain when connecting from WalletConnectV2 #4924

Closed
miroosama opened this issue Jun 30, 2023 · 9 comments
Closed

Unable to select chain when connecting from WalletConnectV2 #4924

miroosama opened this issue Jun 30, 2023 · 9 comments

Comments

@miroosama
Copy link

miroosama commented Jun 30, 2023

I am currently implementing @walletconnect/modal-react-native with the latest version of Rainbow.

During connection I am having issues selecting the chain I would like to use.

I am initializing walletconnectv2 with

  namespaces: {
    eip155: {
      methods: [
        "eth_sendTransaction",
        "eth_sign",
        "personal_sign",
        "eth_signTypedData",
        "eth_signTypedData_v4",
      ],
      chains: ['eip155:1', 'eip155:137'],
      events: ['chainChanged', 'accountsChanged'],
      rpcMap: {},
    },
  },
};

However, when I attempt to connect I am unable to choose which chain I would like to connect with despite both namespaces declared showing up:

Screen Shot 2023-06-29 at 9 41 35 PM

If i attempt a subsequent request I am defaulted to the chain my Rainbow app is already on.

Additionally, because wallet_switchEthereumChain is unsupported:

Screen Shot 2023-06-29 at 9 44 21 PM

I am unable to initialize a WalletConnect session that allows other wallets to use wallet_switchEthereumChain without disrupting the ability to connect with Rainbow.

@devceline
Copy link

Hey there! I'm from the WalletConnect team, taking a look

@devceline
Copy link

I'd recommend setting wallet_switchEthereumChain as optional

@zer0stars
Copy link

I'd recommend setting wallet_switchEthereumChain as optional

We have also tried this, but it does not seem to fix the chain selection, is the expectation that after both chains are requested, the chainId is taken from the header of that individual request?

@lotinasa
Copy link

lotinasa commented Jul 5, 2023

I'm facing the similar issue on Android Rainbow. It connects to the first network from the wagmi chains list (optimism in this case), but I'm unable to switch network in Rainbow Android app. It doesn't offer Switch Network option at all, I have only Switch Wallet and Disconnect options.

I've configured wagmi (v0.12.18) like this:

const { chains, provider } = configureChains(
    [optimism, arbitrum],
    [
        infuraProvider({ apiKey: process.env.REACT_APP_INFURA_PROJECT_ID }),
        publicProvider(),
    ]
);

const connectors = connectorsForWallets([
    {
        groupName: 'Recommended',
        wallets: [
            metaMaskWallet({ projectId, chains }),
            walletConnectWallet({ projectId, chains }),
            injectedWallet({ chains }),
            rainbowWallet({ projectId, chains }),
        ],
    },
]);

The same thing with wagmi v1.3.5.

rainbow_connect
rainbow_options

@miroosama
Copy link
Author

miroosama commented Jul 13, 2023

I'd recommend setting wallet_switchEthereumChain as optional

hmm, it appears initializing the mobile eip155 provider with @walletconnect/modal-react-native does not utilize optional methods?

@dingcxx
Copy link

dingcxx commented Jul 24, 2023

I have a similar problem

so I change the sessionParams to this :

export const MethodName = {
    addNet: 'wallet_addEthereumChain',
    switchNet: 'wallet_switchEthereumChain',
    sign: 'eth_sign',
    getChain: 'eth_chainId',
    sendTransaction: 'eth_sendTransaction',
    // signTransaction: 'eth_signTransaction',
    // signTypedData: 'eth_signTypedData',
    personalSign: 'personal_sign',
}

export const SUPPORT_NETs = [BSC, ETH, Goerli, TESTNET_BSC, zkSync_testnet, zkSync_mainnet]

    const OPTION_CHAINS = SUPPORT_NETs.filter((value) => value.networkId !== 1).map(
        (value) => `eip155:${value.networkId}`,
    )

    const OPTION_METHODS = [...Object.values(MethodName)]
    const REQUIRED_METHODS = ['eth_sendTransaction', 'personal_sign']
    const REQUIRED_EVENTS = ['chainChanged', 'accountsChanged']
    const sessionParams = {
        namespaces: {
            eip155: {
                methods: REQUIRED_METHODS,
                chains: ['eip155:1'],
                events: REQUIRED_EVENTS,
                rpcMap:{},
            },
        },
        optionalNamespaces: {
            eip155: {
                methods: OPTION_METHODS,
                chains: OPTION_CHAINS,
                events: REQUIRED_EVENTS,
                rpcMap: PRC_LISTs,
            },
        },
    }

rainbow wallet connected success

but when I request wallet_addEthereumChain receive error:

 {"context": "client"} Missing or invalid. request() method: wallet_addEthereumChain.

the session.namespaces maybe not include wallet_addEthereumChain , optionalNamespaces not useful.

@skylarbarrera
Copy link
Contributor

responded to @dingcxx here: #4960

seems to be some issues in the underlying wc util's package as well as some issues with our implementation since the switch over.

will circle back here once things are more clear

@jtrein
Copy link

jtrein commented Sep 4, 2023

I am getting this with Goerli and @wagmi/core latest

@skylarbarrera
Copy link
Contributor

hey everybody,

we rolled out support for optional namespaces a few weeks ago which should alleviate any network specific issues as well as remove connection errors based on unsupported RPC methods, etc

as for unsupported RPC methods, rainbow shows all of a users assets across all supported networks so we don't fully support wallet_switchEthereumChain & wallet_addEthereumChain on mobile.

with walletconnect v2 this shouldn't be a problem since the connection will support all of the networks concurrently as well

Closing this for now but please reach out if anything else isn't working as expect!

🌈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@jtrein @lotinasa @skylarbarrera @miroosama @devceline @zer0stars @dingcxx and others