Skip to content

WalletConnectV2 Connector Build Issue #1117

@cbonaco1

Description

@cbonaco1

First want to mention that my team and I ❤️ useDApp. nice work!

Describe the bug
We ran into issues using the @usedapp/wallet-connect-v2-connector package while upgrading to WalletConnect v2. We included the connector as a dependency, but saw the below build error:

10:27:40.718 | Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/node_modules/@web3modal/standalone/dist/index.es.js from /opt/buildhome/repo/node_modules/@usedapp/wallet-connect-v2-connector/dist/cjs/src/index.js not supported.
10:27:40.718 | Instead change the require of index.es.js in /opt/buildhome/repo/node_modules/@usedapp/wallet-connect-v2-connector/dist/cjs/src/index.js to a dynamic import() which is available in all CommonJS modules.
10:27:40.718 | at Object.<anonymous> (/opt/buildhome/repo/node_modules/@usedapp/wallet-connect-v2-connector/dist/cjs/src/index.js:45:20)

Looking into this, I did see @web3modal/standalone is a dependency of the walletConnectv2 connector, which according to npm is deprecated. should this possibly use @walletconnect/modal instead?

To Reproduce
Here is our useDApp config:

const config: Config = {
  readOnlyChainId: currentChainId,
  readOnlyUrls: {
    [currentChainId]: `https://${
      currentChainId === Mainnet.chainId ? 'mainnet' : 'goerli'
    }.infura.io/v3/${process.env.NEXT_PUBLIC_INFURA_ID ?? ''}`,
  },
  refresh: 'never',
  connectors: {
    metamask: new MetamaskConnector(),
    walletConnect: new WalletConnectV2Connector({
      projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID || '',
      chains: currentChainId === Mainnet.chainId ? [Mainnet] : [Goerli],
    }),
  },
};

Then from our own modal, onClick of the WalletConnect button, we have just the following:

activateBrowserWallet({ type: 'walletConnect' });

Software versions

Any guidance here is appreciated 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions