A proof of concept eth wallet built with React Native (using Expo as long as we can!)
In order to use web3.js, we need a few node.js modules (which aren't by default available in the React Native environment).
Hence, we use rn-cli.config.js
(loaded via babel.config.ts
) and globals.ts
to make web3.js pick up modules from node-libs-react-native
and vm-browserify
.
We also use a random bytes implementation taken from this repo, so that we don't need to use react-native-crypto
(which uses native libraries, and thus can't be used within Expo).
A postinstall script removes duplicated of bitcore-lib
installed in nested node_modules
packages, lest it complains about multiple versions being found.
We set the global.self
reference to global
itself, so that brorand
(required by eth-lightwallet
) can resolve self
and self.crypto
, using the aforementioned getRandomBytes()
implementation that we're using.
At the moment, we can't really catch errors raised by the web3.js library, so when you're debugging it's RSOD-fest! Also, it looks like some types of errors completely break React Native's bridge, so you have no other choice but to reload the app. He. Example: try loading a wrong ws address. It will stop responding to UI actions. Neat!