Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this library support React Native? #111

Open
salman-kryptomind opened this issue Nov 12, 2021 · 2 comments
Open

Does this library support React Native? #111

salman-kryptomind opened this issue Nov 12, 2021 · 2 comments
Labels
js-sdk JS Dash SDK related

Comments

@salman-kryptomind
Copy link

I'm trying to create Dash Wallet App with React Native but I'm getting following error

Error: Unable to resolve module fs from /Users/kryptomind/Desktop/Development/RN-Projects/DashWalletMobileApps-KM/node_modules/bls-signatures/blsjs.js: fs could not be found within the project or in these directories:
node_modules

The only thing seems to causing error is "fs" module which is not supported in react-native.

Expected Behavior

It's not working correctly while generating mnemonic.

Current Behavior

Getting following error
Error: Unable to resolve module fs from /Users/kryptomind/Desktop/Development/RN-Projects/DashWalletMobileApps-KM/node_modules/bls-signatures/blsjs.js: fs could not be found within the project or in these directories:
node_modules

Possible Solution

Steps to Reproduce (for bugs)

  1. Create a react-native project ( npx react-native init AwesomeTSProject --template react-native-template-typescript )
  2. Install rn-nodefy in react-native project and hack the Node so you can use node core module ( https://www.npmjs.com/package/rn-nodeify )
  3. npm install dash
  4. Generate Mnemonic using following code
    import Dash from 'dash';
    const client = new Dash.Client({
    network: 'testnet',
    wallet: {
    mnemonic: null,
    },
    });
    const mnemonic = client.wallet?.exportWallet();

Context

I'm not able to use dash sdk since It was the main ingredient to create dash wallet and add functionalities like send/receive and get transactions.

Your Environment

  • Version used: 3.21.2
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Node : v14.18.1, React-Native: 0.66.1
  • Operating System and version (desktop, server, or mobile): Android/IOS
@antouhou
Copy link
Collaborator

This comes from the WASM loader in the emscripten-generated WASM. The loader tries to understand whether the environment is nodejs or the browser, and tries to load WASM file through FS if run on nodejs or through fetch if run in the browser. I'm not familiar with options to load WASM in react-native, but I heard there indeed were some problems with it in react-native, so I don't know what would be the best way to solve this

@salman-kryptomind
Copy link
Author

Noted. Do i have use react-native specific WASM file in order to use this library?

@shumkov shumkov transferred this issue from dashevo/js-dash-sdk Dec 15, 2021
@shumkov shumkov added the js-sdk JS Dash SDK related label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js-sdk JS Dash SDK related
Projects
None yet
Development

No branches or pull requests

3 participants