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

ckt-lumos-transaction-manager

v0.30.0

Published

Pending Transactions Manager for lumos

Downloads

6

Readme

@ckb-lumos/transaction-manager

TransactionManager offer a simple way to query and cache the pending transactions, it means you can get the pending cells without waiting for the transaction to be confirmed.

Quick Start

The easiest way to use the module is to use the RPCTransactionManager class, which uses the RPC module to query the pending transactions.

const indexer = new RPCTransactionManager({ rpcUrl: "https://localhost:8114" });
const collector = indexer.collector({ lock: aliceLock });

for await (const cell of collector.collect()) {
  // do something with the cell
}

Tips:

The collector method accepts the same options as the CkbIndexerQueryOptions of the @ckb-lumos/indexer module, but it is a little different from the CkbIndexerQueryOptions when querying pending cells.

  • skip is suppressed when collector(queryOptions), and when usePendingCells is set to true
  • fromBlock and toBlock are ignored, pending cells will be returned regardless of the block number.
  • when order is set to desc, the pending cells will be returned first

A More Advanced Example

Custom Cache Storage

TransactionManager use an in-memory cache to store the pending transactions by default, but you can also use your own cache storage by passing the storage options.

import { Store } from "@ckb-lumos/transaction-manager";
// set a prefix to avoid the key conflicts other libraries
const CUSTOM_KEY_PREFIX = "__lumos_store__";
const storage: Store = {
  getItem(key) {
    const customKey = CUSTOM_KEY_PREFIX + key;
    const value = window.localStorage.getItem(customKey);
    if (!value) return value;
    // deep clone to avoid the value being modified by the caller
    return JSON.parse(value)[customKey];
  },
  hasItem(key) {
    return !!window.localStorage.getItem(CUSTOM_KEY_PREFIX + key);
  },
  removeItem(key) {
    window.localStorage.removeItem(CUSTOM_KEY_PREFIX + key);
  },
  setItem(key, value) {
    window.localStorage.setItem(CUSTOM_KEY_PREFIX + key, JSON.stringify(value));
  },
};

new RPCTransactionManager({ rpcUrl: "http://localhost:8114", storage });