0.2.0-alpha • Published 1 year ago

bdledger-sdk v0.2.0-alpha

Weekly downloads
19
License
MIT
Repository
github
Last release
1 year ago

BDLedger SDK for Node.js

npm package

Installation

npm install --save bdledger-sdk

Set esModuleInterop to true in your `tsconfig.json.

Usage

Example:

import { Bdledger, blockToHexView, transactionToHexView } from 'bdledger-sdk'

const bdledger = new Bdledger('localhost:2401')

test()

async function test() {
  const version = await bdledger.clientVersion()
  console.log(version)

  const ledgers = await bdledger.getLedgers()
  console.log(ledgers)

  const tx = await bdledger.getTransactionByHash({
    ledger: 'default',
    hash: Buffer.from('52e050aa413dc5a3b32488c4fd0aefb103f8e667', 'hex'),
  })
  if (tx) {
    console.dir(transactionToHexView(tx))
  }

  let b = await bdledger.getBlockByHash({
    ledger: 'default',
    hash: Buffer.from('572b7531addccbee30ebb5d9a77544a0f2229cb0', 'hex'),
    fullTransactions: false,
  })
  if (b) {
    console.dir(blockToHexView(b))
  }

  b = await bdledger.getBlockByHash({
    ledger: 'default',
    hash: Buffer.from('572b7531addccbee30ebb5d9a77544a0f2229cb0', 'hex'),
    fullTransactions: true,
  })
  if (b) {
    console.dir(blockToHexView(b))
  }
}

Please refer to:

Development

npm install
git submodule update --remote

Run in api/grpc

npm install

Generate gRPC code with:

npm run genGrpc

Generated gRPC code will be in src/grpc

Reference: gRPC examples for Node.js

Testing (TODO)

  1. Download mock server
  2. Run mock servers with --port={{port}}
  3. Set the port in test/client.test.js
  4. Run npm test
0.2.0-alpha

1 year ago

0.1.9-alpha

1 year ago

0.1.10-alpha

1 year ago

0.1.11-alpha

1 year ago

0.1.12-alpha

1 year ago

0.1.13-alpha

1 year ago

0.1.8-alpha

3 years ago

0.1.7-alpha

3 years ago

0.1.6-alpha

3 years ago

0.1.5-alpha

3 years ago

0.1.3-alpha

3 years ago

0.1.4-alpha

3 years ago

0.1.1-alpha

3 years ago

0.1.2-alpha

3 years ago

0.1.0-alpha

3 years ago

0.0.7-alpha

3 years ago

0.0.6-alpha

3 years ago

0.0.5-alpha

3 years ago

0.0.4-alpha

4 years ago

0.0.3-alpha

4 years ago

0.0.2-alpha

4 years ago

0.0.1-alpha

4 years ago

0.0.1

4 years ago