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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@caict/bop-typescript-sdk

v1.0.2

Published

Xinghuo bop sdk

Readme

bop-typescript-sdk

[bop] sdk to develop with Xinghuo BIF Open Platform

What

The current package is primarily designed to implement interfaces for the Xinghuo Open Platform. Up to now, it has already realized two major modules, namely, the [Basic Service API] and the [Message Subscription Service]. Through these modules, direct communication with the Xinghuo Open Platform is feasible. In addition, relevant protocol components are handled using Protocol Buffers (protobuf).

Installation

First, you need to install the sdk by running

npm install @caict/bop-typescript-sdk

And add the following statement to your file:

require("@caict/bop-typescript-sdk");

Or, if you are using TypeScript, add this to your file:

import "@caict/bop-typescript-sdk";

Use example

https service

import {
  Config,
  ProviderByBop,
  BopInterface,
  SignerByBop,
} from "@caict/bop-typescript-sdk";

(async () => {
  const apiKey = "xxx";
  const apiSecret = "xxx";
  const config = new Config(
    "https://bif-mainnet.bitfactory.cn",
    apiKey,
    apiSecret,
  );
  let provider = new ProviderByBop(new BopInterface(config));
  console.log(await provider.chain.getChainInfo());

  let signer = new SignerByBop("your enc private key");
  let signerWithProvider = signer.connect(provider);
  console.log(await signerWithProvider.getAccount());
})();

ws service

import {
  WsProviderByBop,
  BopWsInterface,
  WsConfig,
  bopwsprotocol,
} from "@caict/bop-typescript-sdk";

async function main() {
  try {
    // 创建 BopWsInterface 实例,这里假设已经有 bopWs 实例化代码,可根据实际情况修改
    const config = new WsConfig("ws://bif-mainnet.bitfactory.cn/bif/subscribe"); // 替换为实际的 WebSocket 地址
    const bopWs = new BopWsInterface(config.url, config.heartBeatInterval);

    // 标志位,用于判断 BLOCK_HEADER 回调是否已经发生
    let blockHeaderCallbackTriggered = false;

    const subscriptionBlockHeaderId = await bopWs.bop.subscribe(
      bopwsprotocol.MessageType.BLOCK_HEADER,
      (data) => {
        let message: LedgerHeaderMessage = {};
        message = LedgerHeaderMessage.fromJSON(data);
        console.log("dealBlockHeader ing...", message);

        // 设置标志位为 true,表示回调已经发生
        blockHeaderCallbackTriggered = true;
      },
    );
    console.log("Subscription BlockHeader ID:", subscriptionBlockHeaderId);

    if (subscriptionBlockHeaderId !== "-1") {
      // 等待 BLOCK_HEADER 回调发生
      await new Promise<void>((resolve) => {
        const intervalId = setInterval(() => {
          if (blockHeaderCallbackTriggered) {
            clearInterval(intervalId);
            resolve();
          }
        }, 100); // 每 100 毫秒检查一次标志位
      });
      // 取消订阅
      await bopWs.bop.unsubscribe(
        bopwsprotocol.MessageType.BLOCK_HEADER,
        subscriptionBlockHeaderId,
      );
      console.log("Unsubscribed from BLOCK_HEADER");
    }

    // 断开连接
    await bopWs.bop.disconnect();
    console.log("Disconnected from WebSocket");
  } catch (error) {
    console.error("An error occurred:", error);
  }
}

// 调用 main 函数
main();