walletconnect-monorepo icon indicating copy to clipboard operation
walletconnect-monorepo copied to clipboard

`SignClient.init` throws a `SignClient.init is not a function` error.

Open lucadonnoh opened this issue 2 years ago • 3 comments

Describe the bug Follow up of #1129. SignClient.init throws a SignClient.init is not a function error.

Versions

  • "@walletconnect/qrcode-modal": "^1.7.8",
  • "@walletconnect/sign-client": "^2.0.0-beta.101",

To Reproduce

  1. Follow this guide and copy&paste the code in a js file
  2. create a node module and install the dependencies
  3. run the code

Expected behavior The QR pops up and it is possible to connect.

Screenshots immagine

Additional context One solution is replacing SignClient.init with (SignClient.SignClient).init, but I had two different instances where 1. the QR pops up but it gives an error when scanning and 2. the QR doesn't pop up and I get a (node:2960) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 register_error listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit error.

lucadonnoh avatar Jun 17 '22 19:06 lucadonnoh

Same here, any update on this bug?

Proadik avatar Sep 08 '22 15:09 Proadik

Could you try on latest rc please https://www.npmjs.com/package/@walletconnect/sign-client

xzilja avatar Sep 08 '22 16:09 xzilja

Could you try on latest rc please https://www.npmjs.com/package/@walletconnect/sign-client

yes, I am using this version(2.0.0-rc.2), but error still appears

Proadik avatar Sep 08 '22 16:09 Proadik

I have the same issue here. Does anyone have a solution ?

DatHG avatar Nov 08 '22 12:11 DatHG

Hi everyone,

This one is a bit of a mystery to me and there's not really enough context here yet unfortunately. Please share how exactly you're importing the client or (even better) please provide a minimal reproduction of the issue.

Both the following default import and named import syntax work without issues when I try either:

// named import syntax
import { SignClient } from "@walletconnect/sign-client";

// default import syntax, `Client` here simply maps back to the `SignClient` class shown above
import Client from '@walletconnect/sign-client'

See also our wallet and dapp examples for reference:

  • Relevant wallet import: https://github.com/WalletConnect/web-examples/blob/main/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts#L1
  • Relevant dapp import: https://github.com/WalletConnect/web-examples/blob/main/dapps/react-dapp-v2/src/contexts/ClientContext.tsx#L1

Regarding the MaxListenersExceededWarning raised by OP: this was a default EventEmitter warning that was sometimes triggered temporarily during client init. It's been fixed in the meantime.

bkrem avatar Nov 11 '22 15:11 bkrem