@cybavo/react-native-wallet-service
TypeScript icon, indicating that this package has built-in type declarations

1.2.301 • Public • Published

@cybavo/react-native-wallet-service

React-native version of CYBAVO Wallet SDK. Learn more on our website: https://www.cybavo.com/wallet-app-sdk/

Institutional-grade security for your customers

Protect your customers’ wallets with the same robust technology we use to protect the most important cryptocurrency exchanges. CYBAVO Wallet App SDK allows you to develop your own cryptocurrency wallet, backed by CYBAVO private key protection technology.

Mobile SDK

Use CYBAVO Wallet App SDK to easily develop secure wallets for your users without having to code any cryptography on your side. Our SDK allows you to perform the most common operations, such as creating a wallet, querying balances and executing cryptocurrency payments.

Secure key management system

Key management is the most critical part of cryptocurrency storage. CYBAVO Wallet App SDK makes our robust private key storage system available to all of your users. Our unique encryption scheme and a shared responsibility model offers top notch protection for your customer’s keys.

CYBAVO Security Cloud

Cryptocurrency transactions performed by wallets developed with CYBAVO Wallet App SDK will be shielded by our Security Cloud, ensuring their integrity.

Complete solution for cryptocurrency wallets

Cost saving

Leverage your in-house developing team and develop mobile cryptocurrency apps without compromising on security.

Fast development

Quickly and easily develop cryptocurrency applications using mobile native languages, without having to worry about cryptographic code.

Full Node maintenance

Leverage CYBAVO Wallet App SDK infrastructure and avoid maintaining a full node for your application.

Feel free to contact us for product inquiries or mail us: info@cybavo.com

CYBAVO

A group of cybersecurity experts making crypto-currency wallet secure and usable for your daily business operation.

We provide VAULT, wallet, ledger service for cryptocurrency. Trusted by many exchanges and stable-coin ico teams, please feel free to contact us when your company or business need any help in cryptocurrency operation.

Getting started

$ npm install @cybavo/react-native-wallet-service --save

  1. Polyfill NodeJS modules for React-Native
    $ yarn add rn-nodeify
    $ rn-nodeify --install --hack
    
  2. unmark require('crypto') in shim.js

Mostly automatic installation

$ react-native link @cybavo/react-native-wallet-service

Manual installation

iOS

  1. Append this line in Podfile:
    pod 'CybavoWalletService', :path => "../node_modules/@cybavo/react-native-wallet-service/ios/CybavoWalletService.podspec"
    
  2. Go to ./ios, run pod install to install all dependencies.
  3. Open ./ios/{{your project}}.xcworkspace in XCode
  4. In XCode, run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.cybavo.reactnative.wallet.service.CybavoWalletServicePackage; to the imports at the top of the file
  • Add new CybavoWalletServicePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':@cybavo/react-native-wallet-service'
    project(':@cybavo/react-native-wallet-service').projectDir = new File(rootProject.projectDir, 	'../node_modules/@cybavo/react-native-wallet-service/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':@cybavo/react-native-wallet-service')
    

Usage

import { WalletSdk, Auth, Wallets } from "@cybavo/react-native-wallet-service";

WalletConnect

CYBAVO Wallet App SDK has integrated WalletConnect to support wallet apps connecting with Dapps (Web3 Apps).

  1. Following code snippet is the simple usage of how to new a session, approve session request and approve call request

    For further technical specification, please refer to WalletConnect's official document

    import { WalletConnectSdk } from "@cybavo/react-native-wallet-service";
    const { WalletConnectManager, WalletConnectHelper } = WalletConnectSdk;
    // Establish session, then the callback will receive session request 
    let connectorWrapper = WalletConnectManager.newSession(
            walletConnectUri,
            walletAddress,
            walletId,
            walletClientMeta,
            (error, payload) => {
                sessionRequestCallback(connectorWrapper.getConnector().peerId, error, payload);
            }
          );
    
    let sessionRequestCallback = (peerId, error, payload) => {
        //approve session, then pass the listeners to receive call request and disconnect event
        WalletConnectManager.approveSession(
              peerId,
              {
                accounts: [walletAddress],
                chainId: 1, //main net
              },
              (error: any, payload: any) => {
                    callRequestListener(peerId, error, payload);
              },
              disconnectListener
        )
    }
    let callRequestListener = (peerId, error: any, payload: any) => {
        WalletConnectManager.approveRequest(peerId, response).then(() => {})
    }
    let disconnectListener = (error: any, payload: any) => {}
  2. API to support handling call request

    Here defined methods that wallet app should implement. We also provided API to handle corresponding methods:

    • personal_sign, eth_sign
    let message = payload.params[0];
    let result = await Wallets.walletConnectSignMessage(
           walletId,
           convertHexToUtf8(message),
           pinSecret
         );
    • eth_sendTransaction
    let tx = payload.params[0];
    // 1. sign transaction
    let result = await Wallets.walletConnectSignTransaction(
           walletId,
           tx,
           transactionFee,
           pinSecret
         );
    // 2. send signed transaction
    let sendResult = await Wallets.walletConnectSendSignedTransaction(
                walletId,
                result.signedTx
              );
    // return TXID as approve response to the Dapp
    let response = { result: sendResult.txid, id: payload.id };
    await WalletConnectManager.approveRequest(peerId, response);
    • eth_signTypedData
    let message = payload.params[1];
         let result = await Wallets.walletConnectSignTypedData(
           walletId,
           message,
           pinSecret
         );
    let response = { result: '0x' + result.signedTx, id: payload.id };
    await WalletConnectManager.approveRequest(peerId, response);
    • eth_sendRawTransaction
    let signedTx = params[0];
    let sendResult = await Wallets.walletConnectSendSignedTransaction(
                walletId,
                signedTx
              );
    // return TXID as approve response to the Dapp
    let response = { result: sendResult.txid, id: payload.id };
    await WalletConnectManager.approveRequest(peerId, response);
    • eth_signTransaction
    let tx = payload.params[0];
    let result = await Wallets.walletConnectSignTransaction(
           walletId,
           tx,
           transactionFee,
           pinSecret
         );
     let response = { result: result.signedTx, id: payload.id };
     await WalletConnectManager.approveRequest(peerId, response);
  3. Other supportive API

    • Wallets.walletConnectSync

      Check if there're any changes after transactions committed through Wallets.walletConnectSendSignedTransaction or Wallets.sendSignedTx and perform the updates.

    • Wallets.getWalletConnectApiHistory

      All walletconnect related API will be logged as ApiHistoryItem with vary API Names. Use Wallets.getWalletConnectApiHistory to fetch API histories.

    • Wallets.cancelWalletConnectTransaction

      Use Wallets.cancelWalletConnectTransaction to cancel a pending transaction which sent through Wallets.walletConnectSendSignedTransaction.

      It's required a higher transaction fee (1.1 times) to replace the original transaction with 0 amount.

Check our sample app on GitHub: https://github.com/CYBAVO/react-native_wallet_sdk_sample

Refer to documents for details of extra parameters.

Package Sidebar

Install

npm i @cybavo/react-native-wallet-service

Weekly Downloads

4

Version

1.2.301

License

UNLICENSED

Unpacked Size

825 kB

Total Files

59

Last publish

Collaborators

  • cybavo-dev