Giter Site home page Giter Site logo

vvvictorlee / eosjs-react-native Goto Github PK

View Code? Open in Web Editor NEW

This project forked from goevacom/eosjs-react-native

0.0 1.0 0.0 85 KB

This is a simple react-native project in which the steps to configure eosjs on react-native are shown.

Home Page: http://eva.coop/

License: MIT License

JavaScript 98.44% Shell 1.56%

eosjs-react-native's Introduction

eosjs-react-native

This is a simple react-native project in which the steps to configure eosjs on react-native are shown. Since the node dependencies in the eosjs package are not 100% compatible with react-native (per example, elliptic curve cryptography and true secure random number generation), the hacky solution in this example is to browserify the library to emulate it as a browser component in react-native. At Eva, we needed a library to sign transaction and push them onto the EOS blockchain in our react-native app, hence we found this way until a more suitable complete library is written.

Authors

@raphgodro

Dependencies

This would not have been possible without the work of these two libraries

New react-native project

In order to install this repository as a base for a new react-native app client do the following:

First, install the project.

git clone https://github.com/EvaCoop/eosjs-react-native/
cd eosjs-react-native
npm install
react-native eject
sh hack_to_browser.sh
react-native link

You need to do a little tweak now in the library isomorphic-fetch file fetch-npm-browserify.js

vi ./node_modules/isomorphic-fetch/fetch-npm-browserify.js

Add a line before the module.exports line.

var self = this;

Now you can try running the project, make sure the good HTTP address is set to your local RPC API Node in EOS_example.js.

react-native run-ios //or - react-native run-android

Existing react-native project

The following steps describe how to integrate eosjs in an existing react-native project.

Your project needs to be created from react-native init and not the create-react-native-app cli. It has to be independent from Expo and configurable with Xcode and Android Studio. Browserifying doesn't work with react-native Expo projects.

First, install rn-nodeify

npm install rn-nodeify

Then Install eosjs, securerandom rn

npm i --save eosjs
npm i --save react-native-securerandom

Following this, enable the crypto module in �./shim.js Change // require('crypto') to -> require('crypto')

You need to do a little tweak now in the library isomorphic-fetch file fetch-npm-browserify.js

vi ./node_modules/isomorphic-fetch/fetch-npm-browserify.js

Add a line before the module.exports line.

var self = this;

You then need to activate the browserifying using the rn-nodeify script. It is written in a sh script in the repo.

sh hack_to_browser.sh

Then

react-native link

Now you can try running the project, make sure the good HTTP address is set to your local RPC API Node in EOS_example.js.

react-native run-ios //or - react-native run-android

Roadmap and contribution

Contribution would be really appreciated. One day this library could properly map eosjs into a react-native package we can use the node package manager npm to install directly in a react-native project without the manual tweaking.

eosjs-react-native's People

Contributors

raphaelgodro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.