zerodevapp / zerodev-wagmi

8 stars 6 forks source link

Problem with programmatically network switching if the AA wallet was produced with Metamask #13

Open Antonionni opened 11 months ago

Antonionni commented 11 months ago

Hi Zerodev team, I found a problem with programmatically switching the network if the AA wallet was produced with Metamask.

I created connectors using RainbowKit + wagmi and wrapped metaMaskWallet in a function enhanceConnectorWithAA to produced Wagmi connector.

const { chains, publicClient, webSocketPublicClient } = configureChains(
    [polygonMumbai, sepolia],
    [publicProvider()],
)

const connectors = connectorsForWallets([
  {
    groupName: 'EOA Wrapped with AA',
    wallets: [
      enhanceWalletWithAAConnector(
        metaMaskWallet({ chains, projectId: projectId1 }),
        { projectId: projectId1, projectIds: [projectId1, projectId2] }
      ),
    ],
  },
]);

Further in the code I use the useSwitchNetwork hook to change the network. const { chains, isLoading, switchNetwork } = useSwitchNetwork()

When calling the switchNetwork function, I saw that this function is null.

I would like to note that when I use googleWallet as a connector, everything works fine.

Package versions in package.json:

 "@zerodev/sdk": "^4.4.0",
 "@zerodev/wagmi": "^4.4.0",
 "@rainbow-me/rainbowkit": "^1.3.0",
 "wagmi": "^1.4.10",