Unhandled Rejection (TypeError): Object(...) is not a function, Wagmi, React

79 views Asked by At

While it was working fine, I suddenly started getting this error. It is caused by some function in wagmi library: 'wagmi/connectors/walletConnect'. I did not change anything here, have been developing for a couple days then this happend. It is a very specific error so I don't expect anyone to know what the problem is but If anyone have any idea what could be wrong and how I can trace the problem here it would be great. I looked into the source of error but It is just library's modules that takes the parameters and calls other functions and apis.

enter image description here enter image description here

import { configureChains, createConfig } from 'wagmi';
import { walletConnectProvider, EIP6963Connector } from '@web3modal/wagmi1';
import { createWeb3Modal } from '@web3modal/wagmi1/dist/esm/exports/react';
import { publicProvider } from 'wagmi/providers/public';
import { alchemyProvider } from 'wagmi/providers/alchemy';

import { MetaMaskConnector } from 'wagmi/connectors/metaMask';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet';

import { ALCHEMY_API_KEY, WEB3_MODAL_PROJECT_ID } from '../config-global';
import { selectedChain } from './chain';

export const getWagmiConfig = () => {
  try {
    const projectId = WEB3_MODAL_PROJECT_ID;

    const { chains, publicClient } = configureChains(
      [selectedChain],
      [
        alchemyProvider({ apiKey: ALCHEMY_API_KEY }),
        walletConnectProvider({ projectId }),
        publicProvider(),
      ],
    );

    const metadata = {
      name: 'NFT',
      description: ' NFT Web3 Modal',
      url: '',
      icons: [''],
    };

    const wagmiConfig = createConfig({
      connectors: [
        new MetaMaskConnector({
          chains,
          options: {
            shimDisconnect: false,
            shimChainChangedDisconnect: true,
          },
        }),
        new WalletConnectConnector({
          chains,
          options: { projectId, showQrModal: false, metadata },
        }),
        new EIP6963Connector({ chains }),
        new InjectedConnector({ chains, options: { shimDisconnect: true } }),
        new CoinbaseWalletConnector({ chains, options: { appName: metadata.name } }),
      ],
      publicClient,
    });

    createWeb3Modal({
      wagmiConfig,
      projectId,
      chains,
      themeVariables: {
        '--w3m-z-index': 1500,
      },
    });

    return wagmiConfig;
  } catch (err) {}
};

0

There are 0 answers