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

Using wallet-address-validator with React Native #59

Open
dbhalling opened this issue Feb 4, 2019 · 0 comments
Open

Using wallet-address-validator with React Native #59

dbhalling opened this issue Feb 4, 2019 · 0 comments

Comments

@dbhalling
Copy link

I was trying to use wallet-address-validator with React Native. Below is the solution I found. If you know a better solution that would be great. I thought other people might be interested in this issue.

Here are the steps to install wallet-address-validator with React Native and Expo

  1. yarn add wallet-address-validator

  2. npm install -g browserify

  3. Create a file wav-in.js that imports the wallet-address-validator module and simply exports it:

    var WAValidator = require('wallet-address-validator');
    module.exports = WAValidator;

  4. Then in the terminal in the project

    browserify cwav-in.js -o wav.js

  5. This will result in an error if you put in the test code below from Wallet-Address-validator in App.js

var WAValidator = require('wallet-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if(valid)
console.log('This is a valid address');
else
console.log('Address INVALID');

  1. You will however, get an error along the lines “… is not a function”

  2. On line 3837 of wav.js change “var WAValidator = require('wallet-address-validator');” to “WAValidator = require('wallet-address-validator');”

  3. On the very last line in of wav.js add “module.exports = WAValidator;”

everything should be working now

You can find a basic React Native with wallet-address-validator app at https://github.com/dbhalling/WAValidatorRN

This medium article is on point https://hackernoon.com/using-core-node-js-modules-in-react-native-apps-64acd4d07140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant