bcnmy / biconomy-client-sdk

Biconomy SDK is a plug & play toolkit for dApps to build transaction legos that enable a highly customised one-click experience for their users
MIT License
76 stars 78 forks source link

Getting TypeError while importing Smart Account in React app #83

Closed livingrockrises closed 1 year ago

livingrockrises commented 1 year ago

Describe the bug

The app starts failing after write import SmartAccount from "@biconomy/smart-account"

Screenshot 2022-11-27 at 12 03 26 AM

[TypeError: Class extends value undefined is not a constructor or null]

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/bcnmy/biconomy-sdk-starter-kit
  2. Check js/src/App.js or typescript/src/App.tsx
  3. import SmartAccount and create an instance new SmartAccount(provider, options)
  4. yarn start
  5. Front end fails to load with above error
at ./node_modules/messaging-sdk/node_modules/ws/lib/receiver.js (receiver.js:27:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/messaging-sdk/node_modules/ws/lib/websocket.js (websocket.js:15:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/messaging-sdk/node_modules/ws/index.js (index.js:3:1)
    at options.factory (react refresh:6:1)

Expected behavior Smart Account should get initialised properly

Screenshots attached above

Desktop (please complete the following information):

Additional context Import fails for js file

livingrockrises commented 1 year ago

I am checking this https://tinyurl.com/2s3fvk7y there is possibly a circular dependency?

livingrockrises commented 1 year ago

for js this below import works but still facing above issue

const SmartAccount = require("@biconomy/smart-account").default;

AmanRaj1608 commented 1 year ago

This might come when you have not configured the ws lib in webpack properly.

For react applications can add stream-browserify in webpack file For Next.js applications add stream-browserify in next.config.js

"stream": require.resolve("stream-browserify"),
livingrockrises commented 1 year ago

something like this what's done in gasless playground?

https://github.com/bcnmy/gasless-playground/pull/1/files

github-actions[bot] commented 1 year ago

This issue has been inactive for 30 days. It will be closed due to inactivity. If this issue is still relevant, please comment to keep it open. Alternatively, you can create a new issue with updated information.