npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-g8c-sdk

v1.0.1

Published

react native wallet sdk by namnh270

Downloads

4

Readme

WALLET SDK

Install package

  1. run npm install rn-wallet-sdk-test or yarn add rn-wallet-sdk-test
  2. To use this package, you will need to install React Native Nodeify to use node core modules and npm modules that use them in your React Native app by the following command line npm install rn-nodeify or yarn add rn-nodeify
  3. run rn-nodeify --install --hack if you use npm, add --yarn if you want to use yarn
  4. run cd ios && pod install && cd .. to install package on iOS
  5. you can run your project now react-native run-ios or react-native run-android

API

Wallet

  • generateMnemonic()
    • Returns:
      • Success: mnemonic 24 words.
      • Error: 'Generate mnemonic failed'.
  • generateWallet(mnemonic, password)
    • Parameters:
      • mnemonic: mnemonic 24 words.
      • password: password for encrypting private key and mnemonic.
    • Returns:
      • Success: (Promise) wallet object with public key, address, encryption of mnemonic and encryption of private key.
      • Error:
        • 'Get address from public key failed'.
        • 'Encrypt failed'.
        • Others.
  • encryptString(privateString, password)
    • Parameters:
      • privateString: private string will be encrypted.
      • password: password will be used to when encrypting.
    • Return :
      • Success: encryption of private string with password.
      • Error: 'Encrypt failed'.
  • decryptString(cipherText, password)
    • Parameters:
      • cipherText: encryption of private string.
      • password: password is used for decryption.
    • Return :
      • Success: decryption of cipherText with password.
      • Error: 'Encrypt failed'.
  • restoreWallet(mnemonic, password)
    • Parameters:
      • mnemonic: mnemonic passphrase will be used to restore wallet, examples: abandon abandon ...
      • password: password will be used to encrypt private key.
    • Returns:
      • Success: (Promise) wallet object with public key, address, encryption of mnemonic and encryption of private key.
      • Error:
        • 'Get address from public key failed'.
        • 'Encrypt failed'.
        • Others.
  • getAddressFromPublicKey(publicKey)
    • Parameters:
      • publicKey: public key of wallet.
    • Returns:
      • Success: address from public key.
      • Error: 'Get address from public key failed'.
  • getPublicKeyOffline(privateKey, curveType)
    • Parameters:
      • privateKey: private key of wallet.
      • curveType: type of curve algorithm.
    • Returns:
      • Success: public key from private key.
      • Error: null.
  • signatureOffline(txData, privateKey)
    • Parameters:
      • txData: data will be signed.
      • privateKey: private key will be used to signing txData.
    • Returns:
      • Success: signature.
      • Error: null.
  • verifyTransaction(tx)
    • Parameters:
      • tx: transaction need verifying.
    • Returns:
      • True: if transaction is valid.
      • False: otherwise.

API

  • Properties
    • api: uri of api server.
  • Constructor
    • new API(api) : create new instance API.
  • Methods
    • getBlock(height)
      • Parameters:
        • height: height of block.
      • Returns:
        • Success:(Promise) block at height.
        • Error: 'Get block failed'.
    • getTransaction(txHash)
      • Parameters:
        • txHash: hash of transaction.
      • Returns:
        • Success:(Promise) The transaction has transaction hash as input.
        • Error: 'Get transaction failed'.
    • getAccountDetail(address)
      • Parameters:
        • address: address of account (hex string, length = 40).
      • Returns:
        • Success: details of account has address as input.
        • Error: 'Get details account failed'.
    • getHistoryTransaction({address, page, limit = 10})
      • Parameters
        • address: address want to get history
        • page: number of pages
        • limit: default is 10, amount of transactions will be returned in response.
      • Returns:
        • Success:(Promise) transactions of address.
        • Error: 'Get transaction history failed'.
    • getSequence(address)
      • Parameters:
        • address: address of account wants to get sequence number.
      • Returns:
        • Success: (Promise) sequence of address.
        • Error:
          • 'Get sequence failed'.
          • 'Get details account failed'.
    • getBalance(address)
      • Parameters:
        • address: address of account wants to get balance.
      • Returns:
        • Success: (Promise) balance of address.
        • Error:
          • 'Get balance failed'.
          • 'Get details account failed'.
    • getPermission(address)
      • Parameters:
        • address: address wants to get permission.
      • Returns:
        • Success: (Promise) permission of address.
        • Error:
          • 'Get permission failed'.
          • 'Get details account failed'.
    • getParams(method, body, headers, uri) : static function
      • Parameters:
        • method: method of request( GET, POST, ...)
        • body: body of request
        • headers: header of request
        • uri: uri of request.
      • Returns:
        • Success: request as a JSON.
    • sendTransaction(tx)
      • Parameters:
        • tx: transaction will be sent to blockchain network.
      • Returns:
        • Success: (Promise) transaction hash of transaction.
        • Error: 'Send transaction failed'.
    • getTransactionFee()
      • Returns:
        • Success: (Promise) fee and address of receiver.
        • Error: 'Get transaction fee failed'.
    • requestAPI(endpoint, method, body, headers)
      • Parameters:
        • endpoint: request will be sent to endpoint
        • method: method of request (GET, POST)
        • body: body of request
        • headers: headers of request
      • Returns:
        • Success: response of request
        • Error: 'Error when request data'

Transaction

  • Properties
    • webAPI : instance of class API
    • wallet : instance of Wallet
    • utils : instance of Utils
    • CHAINID : chain identify of blockchain.
  • Constructor
    • new Transaction(chainId, urlAPI)
      • Parameters:
        • chainId: chain id of blockchain
        • urlAPI: uri of api server
      • Returns: instance of class Transaction
  • Methods
    • createSendTx(from, to , amount, privateKey)
      • Parameters:
        • from: address of sender
        • to: address of receiver
        • amount: amount of token will be sent
        • privateKey : private key of sender, which is used to sign transaction.
      • Returns:
        • Success:(Promise) transaction hash of transaction.
        • Other: Error

Usage

import WalletSDK from 'rn-wallet-sdk-test'

const mnemonic = WalletSDK.Wallet.generateMnemonic()
const wallet = await WalletSDK.Wallet.restoreWallet(mnemonic, password)
const wallet = await WalletSDK.Wallet.generateWallet(mnemonic, password)
const mnemonicEncrypt = WalletSDK.Wallet.encryptString(mnemonic, password)      
const mnemonic = WalletSDK.Wallet.decryptString(mnemonicEncrypt, password)      

Troubleshooting

Nodejs libraries error

If you continue install some packages on your project, please run rn-nodeify --install --hack after install them.

@babel/plugin-proposal-throw-expressions

Install this library if your project haven't had it yet to catch throw error

run npm install --dev @babel/plugin-proposal-throw-expressions or yarn add --dev @babel/plugin-proposal-throw-expressions