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

bch-snap

v0.1.1

Published

A MetaMask Snap for Bitcoin Cash

Downloads

3,741

Readme

Bitcoin Cash Wallet

A MetaMask Snap for Bitcoin Cash. The wallet website is bchwallet.

RPC Methods

bch_getAddress: Get current BCH cash address.

parameters:

{
  network: 'mainnet' | 'testnet'
}

bch_switchAddress: Switch bch address (based on BIP32) and cache index to browser (based on snap manage state). The current address used by each DApp are stored independently of each other.

parameters:

{
  network: 'mainnet' | 'testnet'
}

bch_showWIF: Show wif private key in snap window. This method DOES NOT return the user's private key to the DApp. It is for MetaMask’s display only.

parameters:

{
  network: 'mainnet' | 'testnet'
}

bch_getPublicKey: Get current BCH cash address’s public key.

parameters:

{
  network: 'mainnet' | 'testnet'
}

bch_signTransaction: Sign for BCH unsigned transactions.

parameters:

{
  network: 'mainnet' | 'testnet';
  unsignedTx: string;
}

bch_signTransactionForArg:Sign for BCH unsigned transactions. This method is intended to solve the problem of passing SignatureTemplate parameter.

SignatureTemplate can be found here: https://github.com/CashScript/cashscript/blob/v0.8.2/packages/cashscript/src/SignatureTemplate.ts#L4

parameters:

{
  network: 'mainnet' | 'testnet';
  unsignedTx: string;
}

the original unsignedTx is an object like this:

TransactionCommon can be found here: https://github.com/bitauth/libauth/blob/master/src/lib/message/transaction-types.ts#L245

SourceOutput can be found here: https://github.com/mainnet-cash/mainnet-js/blob/1.1.28/packages/mainnet-js/src/wallet/model.ts#L317

import {type TransactionCommon} from '@bitauth/libauth';
import {type SourceOutput} from "mainnet-js";

export type UnsignedTx = {
  transaction  : TransactionCommon,
  sourceOutputs: SourceOutput[],
}

where unsignedTx parameter is a string using pack(), you can refer to the following code:

export function pack(tx: any) {
  return JSON.stringify(tx, (_, value) => typeof value === "bigint" ? `${value.toString()}` : value)
}

export function unPack(txStr: string) {
  return JSON.parse(txStr, function (key, value) {
    if (!!value && typeof value === "object") {
      const keys = Object.keys(value)
      const values = Object.values(value)

      const b = keys.every((v: any) => typeof Number(v) === "number") && values.every((v: any) => typeof v === "number")
      if (!b) {
        return value
      }
      return new Uint8Array(values as any);
    }
    if (["token", "nft"].includes(key) && value === null) {
      return undefined
    }
    if (["valueSatoshis", "amount"].includes(key)) {
      return BigInt(value)
    }
    return value;
  })
}