README
react-native-elastos-mainchain
Getting started
$ npm install react-native-elastos-mainchain --save
Mostly automatic installation
$ react-native link react-native-elastos-mainchain
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-elastos-mainchain
and addRNElastosMainchain.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNElastosMainchain.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)
Android
TODO
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import org.elastos.mainchain.reactnative.RNElastosMainchainPackage;
to the imports at the top of the file - Add
new RNElastosMainchainPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-elastos-mainchain' project(':react-native-elastos-mainchain').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-elastos-mainchain/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-elastos-mainchain')
Additional configurations
As the react-native-elastos-mainchain package refers to the https://github.com/elastos/Elastos.ORG.Wallet.Lib.C library, some additional configurations are required:
- Open the Xcode project located under the ios/ folder in your react-native project
- Click the name of the project and select the target with the same name
- Click "Build settings" and add "$(SRCROOT)/../node_modules/react-native-elastos-mainchain/Elastos.ORG.Wallet.Lib.C/src" to Header Search Paths
- Similarly add "$(SRCROOT)/../node_modules/react-native-elastos-mainchain/Elastos.ORG.Wallet.Lib.C/build/ios/src" to Library Search Paths
- Go to Build Phases/ Link Binary with Libraries and drag&drop the node_modules/react-native-elastos-mainchain/Elastos.ORG.Wallet.Lib.C/build/ios/src/libElastos.Wallet.Utility.dylib file
Usage
import RNElastosMainchain from 'react-native-elastos-mainchain';
// Generate a new mnemonic (defaults to English)
RNElastosMainchain.generateMnemonic((err, mnemonic) => {
console.log(mnemonic)
});