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

@jadepool/sdk

v1.1.0

Published

Jadepool nodejs SDK

Downloads

8

Readme

Jadepool Hub NodeJS SDK 兼 Cli 工具

关于cli工具

bin/cli是用于调用Jadepool Hub API的便捷命令行工具。

上手指南

命令帮助

bin/cli -h
# usage: cli.js [-h] [-v] [-f CONFIGFILE]
#               {keypairs,address-new,address-verify,withdraw,audit,order-get,audit-get,balance}
#               ...
# Jadepool SDK cli

# Optional arguments:
#   -h, --help            Show this help message and exit.
#   -v, --version         Show program's version number and exit.
#   -f CONFIGFILE, --configfile CONFIGFILE
#                         path of the config file

# sub-commands:
#   call API or generateKeypairs

#   {keypairs,address-new,address-verify,withdraw,audit,order-get,audit-get,balance,auth-coin}
#     keypairs            create ecc key pairs
#     address-new         call Jadepool API: newAddress
#     address-verify      call Jadepool API: verifyAddress
#     withdraw            call Jadepool API: withdraw
#     audit               call Jadepool API: audit
#     order-get           call Jadepool API: getOrder
#     audit-get           call Jadepool API: getAudit
#     balance             call Jadepool API: getBalance

修改配置文件

连接 Jadepool Hub 需要配置该环境使用的 ecc 私钥,用于签名认证。 若不在 cli 命令中使用 -f 指定配置文件,将默认使用工程目录下的 jpcli.config.json 文件。

{
  "eccKey": "7uK2lwGDIwopJdaduVr4maw1sPyjDB4J386gnQ01KXc=",
  "eccKeyEncoder": "base64",
  "httpEndpoint": "http://127.0.0.1:7001",
  "appId": "test"
}

配置参数说明

  • eccKey 签名私钥
  • eccKeyEncoder 私钥编码方式
  • httpEndpoint Jadepool Hub API URL
  • appId 签名对应的 AppId

命令详解

**注意:**下文中所有{}字段均表示该参数为变量,请根据实际情况传入参数。[]内为可选参数

创建公私钥对

# create new keypairs
bin/cli.js keypairs

创建新地址

# create new address
bin/cli.js address-new {coinId}

参数:

  • coinId: 币种名称

验证地址

bin/cli.js address-verify {coinId} {address}

参数:

  • coinId: 币种名称
  • address: 待验证地址

发起提现

# withdraw
bin/cli.js withdraw {coinId} {to} {value} {sequence} [-m {memo}] [-d {extraData}]

参数:

  • coinId: 币种名称
  • to: 到账地址
  • value: 金额
  • sequence: 序列号
  • memo: 提现备注
  • extraData: 额外参数,回调中将返回

发起统计

# audit
bin/cli.js audit {coinId} {auditTime}

参数:

  • coinId: 币种名称
  • auditTime: 统计时间

订单查询

bin/cli.js order-get {orderId}

参数:

  • orderId: 订单号

统计查询

bin/cli.js audit-get {auditId}

参数:

  • auditId: 统计号

钱包余额查询

bin/cli.js balance {coinId}

参数:

  • coinId: 币种名称

关于 NodeJS SDK

快速上手

安装sdk后,可以在 nodejs 代码中进行对瑶池API的调用。

npm install @jadepool/sdk

代码示例 Example

  const sdk = require('@jadepool/sdk')

  const config = {
    eccKey: 'ad70927341c3ccd4c745e51db0c00ce23edc667cfc71e990a584e9e951c39297', // ecc private key for signing request to Jadepool
    eccKeyEncoder: 'hex', // ecc private key encoding scheme
    httpEndpoint: 'http://localhost:7001', // Jadepool url
    appId: 'test' // app id for ecc key (set on Jadepool Admin)
  }
  const api = new sdk.Api(config)

  // get a new address
  let address = await api.newAddress('BTC')

  // verify if an address is valid
  let valid = await api.verifyAddress('BTC', address)

  // request a withdrawal
  let withdrawOrder = await api.withdraw({
    coinId: 'BTC',
    to: 'mg2bfYdfii2GG13HK94jXBYPPCSWRmSiAS',
    value: '0.1',
    sequence: 0
  })

  // request an audit
  let auditOrder = await api.audit('BTC', 1544601373000)

  // query a Jadepool order
  let order = await api.getOrder('5')

  // query a Jadepool audit order
  let audit = await api.getAudit('5c10c052f6372352b66dbe67')

  // get a token balance
  let balance = await api.getBalance('BTC')

License

MIT