1.2.4 • Published 3 years ago

q-lib-react-native v1.2.4

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
3 years ago

JavaScript TON Client Bindings

Community links:

Chat on Telegram

This repository contains JavaScript TON Client binding packages:

  • @tonclient/core – common binding independent from JavaScript platform you use.
  • @tonclient/lib-node – bridge to NodeJs including NodeJs binary addon.
  • @tonclient/lib-web – bridge to browser including WASM module.
  • @tonclient/lib-react-native – bridge to mobile react-native platform including static libraries for iOS and Android.

Installation

Install core package

npm i --save @tonclient/core

Install bridge package (depends on target JS platform)

The bridge package will download precompiled binaries from TON Labs cloud storage. If you want to rebuild binary from sources see build binaries(#build binaries) section.

NodeJs:

npm i --save @tonclient/lib-node

Web:

npm i --save @tonclient/lib-web

React Native:

npm i --save @tonclient/lib-react-native

Setup library

You must initialize the library before the first use. The best place to do it is an initialization code of your application.

You need to attach the chosen binary module to the TonClient class.

NodeJs:

const {TonClient} = require("@tonclient/core");
const {libNode} = require("@tonclient/lib-node");

// Application initialization

TonClient.useBinaryLibrary(libNode)

Web:

import {TonClient} from "@tonclient/core";
import {libWeb} from "@tonclient/lib-web";

// Application initialization

TonClient.useBinaryLibrary(libWeb);

React Native:

import {TonClient} from "@tonclient/core";
import {libReactNative} from "@tonclient/lib-react-native";

// Application initialization

TonClient.useBinaryLibrary(libReactNative);

Use library

All library functions are incorporated into TonClient class. Each client module is represented as a property of the TonClient object.

To start use library you must create an instance of the TonClient class:

const client = new TonClient();
const keys = await client.crypto.generate_random_sign_keys();

You can pass a configuration object in TonClient constructor:

const client = new TonClient({
    network: { 
        server_address: 'net.ton.dev' 
    } 
});

You can find reference guide to TonClient here: TON-SDK API Documentation

Build bridge binaries

You can build binaries from sources.

If you install a bridge package from the npmjs you can build it with the following commands (e.g. for nodejs):

cd node_modules/@tonclient/lib-node/build
cargo run

Build binaries

If you checkout this repository you can build binaries for all bridges.

cd packages/lib-node/build
cargo run
cd ../../../lib-web/build
cargo run
cd ../../../lib-react-native/android/build
cargo run
cd ../../ios/build
cargo run

Also the archives will be created to be published on the TON Labs cloud storage. Archives will be placed into the following folders:

  • packages/lib-node/publish
  • packages/lib-web/publish
  • packages/lib-react-native/ios/publish
  • packages/lib-react-native/android/publish

Copyright 2018-2020 TON DEV SOLUTIONS LTD.

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago