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

bq-wallet

v1.0.3

Published

用于web钱包集合调用

Downloads

6

Readme

web3 钱包聚合库

结构

  1. 组件 WalletProvider 用于维持钱包数据上下文
  2. hooks 用于钱包 api 调用

WalletProvider 使用

import { WalletProvider } from "bq-wallet";
export default function Index() {
  return <WalletProvider>{/* More JSX code here */}</WalletProvider>;
}

hooks

  1. useWallet 用于用于调用钱包 api 的。
  2. useWalletSelector 用于获取钱包数据

useWallet 提供的 api

  1. connect 用于连接钱包
  2. disconnect 用于断开钱包
  3. getInfo 用于获取余额
  4. sign 用于签名
  5. signPsbt 用于签名 psbt
  6. sendBitcoin 用于发送 btc
  7. getNetwork 用于获取钱包当前网络
  8. changeWallet 切换不同钱包或网络
import UseWalletComp "./UseWalletComp";
import { WalletProvider } from "bq-wallet";
export default function Index() {
  return <WalletProvider>
    <UseWalletComp />
  </WalletProvider>;
}

// UseWalletComp
import { useWallet } from "bq-wallet";
export default function UseWalletComp() {
    const {connect, disconnect, getInfo, sign, ... } = useWallet()
}

useWalletSelector 提供的数据

// 输出的ts类型
{
  name: WalletName | null; // 钱包名称
  network: Network; // 当前网络
  publicKey: string; // 公钥
  accounts: string[]; // 账户
  address: string; // 钱包地址
  btcAddress: string; // BTC钱包地址
  btcPublicKey: string; // BTC钱包公钥
  balance?: {
    confirmed?: number; // 确认的余额
    total?: number; // 总余额
    unconfirmed?: number; // 未确认的余额
  };
}
import UseWalletComp "./UseWalletComp";
import { WalletProvider } from "bq-wallet";
export default function Index() {
  return <WalletProvider>
    <UseWalletComp />
  </WalletProvider>;
}

// UseWalletComp
import { useWalletSelector } from "bq-wallet";
export default function UseWalletComp() {
    const walletInfo = useWalletSelector()
}

Api 部分

  1. stringFormatTransition 用于 hex 与 base64 的转换
  2. getBase64Str 获取 base64 字符串
  3. getHexStr 获取 hex 字符串
  4. detectEncoding 判断字符串类型
  5. btcToSatoshis 用于 btc 转成 satoshis
  6. satoshisToBtc 用于 btc 转成 satoshis