Giter VIP home page Giter VIP logo

zoobc / zoobc-sdk Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 4.0 26.26 MB

Small set of libraries written with TypeScript and compiled to be JavaScript, making it easy to implement / integrate applications so that they connect with the P2P API of the nodes in the blockchain for the Web API of the explorer servers and wallet.

Home Page: https://www.npmjs.com/package/zbc-sdk

License: MIT License

JavaScript 86.17% TypeScript 13.53% Shell 0.31%
grpc grpc-web typescript javascript blockchain

zoobc-sdk's Introduction

Screenshot

ZooBC-SDK

npm download license build

ZooBC-SDK is a small set of libraries written with TypeScript and compiled to be JavaScript, making it easy to implement / integrate applications so that they connect with the P2P API of the nodes in the blockchain for the Web API of the explorer servers and wallet.

Start using ZooBC-SDK

For instructions on how to use web and mobile for a project, please refer to these documents:

General Usage

Add 'zbc-sdk' packages to your project by executing:

$ npm install zbc-sdk
or
$ yarn add zbc-sdk

Here's an example of basic usage for connection:

import React, { useState, useEffect } from 'react';
import zoobc from 'zbc-sdk';

const App = () => {
  const [blocks, setBlocks] = useState([])
  const [error, setError] = useState(null)
  const [detail, setDetail] = useState(null)

  useEffect(() => {
    const hosts = [
      { host: 'http://your-ip-address:your-port', name: 'Testnet' },
    ];
    zoobc.Network.list(hosts)
    listBlocks();
  }, [])

  const listBlocks = () => {
    zoobc.Block
      .getBlocks({height: 0})
      .then(res => setBlocks(res.blocksList))
      .catch(err => setError(err))
  };

  const onClickBlockId = (id) => {
    zoobc.Block
      .getBlockById(id)
      .then(res => {
        setDetail(res)
        setError(null)
      })
      .catch(err => {
        setError(err)
        setDetail(null)
      })
  }

  const onClickBlockHeight = (height) => {
    zoobc.Block
      .getBlockByHeight(height)
      .then(res => {
        setDetail(res)
        setError(null)
      })
      .catch(err => {
        setError(err)
        setDetail(null)
      })
  }

  return (
    <>
      {!!error && (
        <>
          <div><strong>Error</strong></div>
          <code>{JSON.stringify(error)}</code>
        </>
      )}{!!detail && (
        <>
          <div><strong>Detail</strong></div>
          <code>{JSON.stringify(detail)}</code>
        </>
      )}
        <table>
          <thead>
            <tr>
              <th>Id</th>
              <th>Previous Hash</th>
              <th>Height</th>
              <th>Timestamp</th>
              <th>Version</th>
            </tr>
          </thead>
          <tbody>
            {blocks.length > 0 &&
              blocks.map((data, key) => {
                return (
                  <tr key={key}>
                    <td onClick={() => onClickBlockId(data.block.id)}>
                      {data.block.id}
                    </td>
                    <td>{data.block.previousblockhash}</td>
                    <td onClick={() => onClickBlockHeight(data.block.height)}>
                      {data.block.height}
                    </td>
                    <td>{data.block.timestamp}</td>
                    <td>{data.block.version}</td>
                  </tr>
                );
              })}
          </tbody>
        </table>
      </>
  )
}

export default App;

Contributors

Thanks to all who have contributed to ZooBC-SDK!


Gungde

Eko

Irfan

Yandi

Nata

Bagas

Kevin

Adhiim

Witarsana

License

This project is licensed under the Apache License - see the LICENSE file for details

zoobc-sdk's People

Contributors

gungdesurya avatar eksant avatar bagasagastya avatar gedeyandi456 avatar iamnafri avatar witarsana avatar kevinh2810 avatar zaenury avatar capt4ce avatar gedenata avatar jhonkus avatar dependabot[bot] avatar bzpython avatar

Watchers

James Cloos avatar  avatar Roberto Capodieci avatar  avatar  avatar

zoobc-sdk's Issues

[FEATURE] Multi Signature

  • Create Multisig Address
  • Create getPendingList function from MultisigServiceClient.getPendingTransactions
  • Create getPending function from MultisigServiceClient.getPendingTransactionDetailByTransactionHash
  • Create getMultiSignatureInfo function from MultisigServiceClient.getMultisignatureInfo
  • Create multisignatureBuilder function to build transactions bytes from multisig params before send it to the node
  • Create postTransaction function to create new multisignature transaction

Note:
Please see https://github.com/zoobc/zoobc-core/wiki/Multi-Signature-Transaction for guidence

[FEATURE] Convert Mempool Transactions from GRPC to ZBC Wallet Format

  • Create function that filter all mempool transactions to be only send money (type = 1)
  • Create function that return only one mempool transaction that has type register, update, claim, or remove

Transaction Type Code:
register node= 2
update node = 258
remove node = 514
claim node = 770

[Master] Boilerplate Project

To do:

  • Initial dependencies like as mocha, grpc-pack, etc
  • Create directory source (main project)
  • Create directory test (unit testing)
  • Create directory example (example to implementation)
  • Update README

[TEST] Keyring

generateRandomPhrase

Cases

Input: number word = 12 | 24
Result: return string that contain 12 or 24 words

Input: number word = not 12 neither 24
Result: return error

calcDerivationPath

Cases

Input: create some test case and use that as a input
Result: return BIP32Interface object that contain expected properties value on test case result

[Testing] Init

Unit testing functions to ensure the function of init zoobc sdk has items message structure, error messages, etc.

[TEST] Account

getBalance

Cases

Input: Address that have transactions
Result: return object with accountbalance properties

[Testing] Unit Test All Function From SDK

Unit testing functions to ensure the function of list blocks or block details has items message structure, error messages, etc.

  • Unit testing functions to ensure the function of list blocks or block details has items message structure, error messages, etc.

  • Unit testing functions to ensure the function of list transactions or transaction details has items message structure, error messages, etc.

[TEST] Wallet

encryptPassphrase

Cases

Input: create some test case and use that as a input
Result: return a base64 string that already expected on test case result

decryptPassphrase

Cases

Input: create some test case and use that as a input
Result: return a string of passphrase that already expected on test case result

[REQ] when do we release to npmjs?

Describe
It seems like the issue of unit testing is gone, can we start publishing to npmjs at this time?
And which version should we start with for the alpha release?

Refactoring CI after updating repo

Is your feature request related to a problem? Please describe.
Minor bug for refactoring CI with update repo. Please adjust working directory in config.yml with the repo used.

[TEST] Escrow

getList

Cases

Input: input correct params
Result: return object with escrowList properties as an array

get

Cases

Input: input an correct Id
Result: return escrow object

approval

Cases

Input: input correct params
Result: return new escrow transactions object

[FEATURE] Health Check

TO DO

  • implement healthCheck() function given by new schema
  • creating unit testing for this function

[Generator] Protogen

The initial function is to connect with the P2P API of the nodes in the blockchain.

[TEST] Node

getHardwareInfo

Cases

Input: seed and ip that owned by node
Result: stream nodeharware object every 5 seconds

generateNodeKey

Cases

Input: seed and ip that owned by node
Result: return a new nodepublickey

getList

Cases

Input: input correct params
Result: return an object with noderegistrationsList object

get

Cases

Input: input correct params
Result: return noderegistrationt object

register, update, remove, claim

Cases

Input: input correct params
Result: return a new transaction object

[BUG] Protogen syntax error

Describe the bug
Syntax error in some line when execute protogen.sh

To Reproduce
Steps to reproduce the behavior:

  1. Go to terminal
  2. write ./protogen.sh and push enter
  3. See error in screenshots

Screenshots
image

[TEST] Block

getBlocks

Cases

Input: input height and/or limit
Result: return object with blockList properties as an array

getBlockById

Cases

Input: input an Id
Result: return block object

getBlockByHeight

Cases

Input: input an height number
Result: return block object

[BUG] getAccountBalance Endpoint Return Error "Address Not Found"

getAccountBalance endpoint in src/Account.ts function will return error "Address not found" if address has no transaction in database

Expect:
enpoint return the result with 0 balance and 0 spendable balance

Solution
if GRPC return error with error "Not Found" (error code: 5), resolve it with 0 balance and spendable balance

[TEST] Mempool

getList

Cases

Input: input correct params
Result: return object with mempoolTransactionsList properties as an array

get

Cases

Input: input correct Id
Result: return transaction object

[TEST] Transactions

getList

Cases

Input: input correct params
Result: return object with transactionsList properties as an array

get

Cases

Input: input correct Id
Result: return transaction object

sendMoney

Cases

Input: input correct params
Result: return new transaction object

[TEST] Poown

createAuth

Cases

Input: correct seed and request type = 1
Result: return base64 string with 108 length

request

Cases

Input: input corrects params
Result: return bytes of array

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.