useChainId and useNetwork returning the wrong chainId and wrong network after switching networks with useSwitchNetwork when using web3auth

Describe the bug

useChainId and useNetwork returning the wrong chainId and wrong network after switching networks with useSwitchNetwork when using web3auth wagmi connector.

To Reproduce

Steps to reproduce the behavior:

  1. clone web3auth-pnp-examples(GitHub - Web3Auth/web3auth-pnp-examples) repository
  2. Go to ‘web-modal-sdk/wagmi-examples/wagmi-modal-example’
  3. See bug bug gif

Code

  const { chain } = useNetwork()
  const { chains, error, pendingChainId, switchNetwork, status } =
    useSwitchNetwork()

  return (
    <div>
      {chain && <div>Using {chain.name}</div>}

      {chains.map((x) => (
        <button
          disabled={!switchNetwork || x.id === chain?.id}
          key={x.id}
          onClick={() => switchNetwork?.(x.id)}
        >
          Switch to {x.name}
          {status === 'loading' && x.id === pendingChainId && '…'}
        </button>
      ))}

      <div>{error && (error?.message ?? 'Failed to switch')}</div>
    </div>
  )

Expected behavior

After clicking the Switch to Ethereum button, the chain data should be Ethereum, and Using Goerli should be changed to Using Ethereum on the screen.
(The chain data obtained through useNetwork() should be the changed network data).

Screenshots

Note

If I use other connectors (provided by rainbowkit), it works fine, but if I use web3auth-wagmi-connector, it works abnormally.

Device Info (please complete the following information):

  • Device: macbook
  • OS: mac os
  • Browser: chrome
  • Version
    @web3auth/base”: “^7.2.0”,
    @web3auth/ethereum-provider”: “^7.2.0”,
    @web3auth/modal”: “^7.2.0”,
    @web3auth/openlogin-adapter”: “^7.2.0”,
    @web3auth/torus-wallet-connector-plugin”: “^7.2.0”,
    @web3auth/web3auth-wagmi-connector”: “^5.0.1”,

@hks0284 Welcome Aboard!

Your issue has been forwarded to our Dev team and we will get back with further updates.

When I use the PnP modal SDK wagmi example and try to switch chains, I also get this error “An error occurred when attempting to switch chain. Details: Expected null or array with at least one valid string HTTPS URL ‘blockExplorerUrl’”