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

dotswap-wallet

v1.0.58

Published

用于web钱包集合调用

Downloads

947

Readme

web3 钱包聚合库

设计的初衷

  1. 使用立即执行函数保持私有域变量,确定钱包信息变量锁定,并脱离所有框架的生命周期。
  2. 磨平不同平台调用不同钱包api内容
  3. 脱离于各项目,物理隔离wallet钱包和项目业务逻辑两者产生的问题

主要的 api 与变量

  1. walletApi 用于调用钱包 api 的。
  2. walletDict 支持的钱包的字典对应
  3. hasWallet 获取浏览器中是否存在对应的钱包

walletApi 提供的 api 与方法

  1. connect 用于连接钱包
  2. disconnect 用于断开钱包
  3. getInfo 获取用户信息
  4. sign 用于签名
  5. signPsbt 用于签名 psbt
  6. signPsbts 用于多签签名 psbts
  7. sendBitcoin 用于发送 btc
  8. getNetwork 用于获取钱包当前网络
import { walletApi, walletDict } from "dotswap-wallet";

const {connect, disconnect, sign, signPsbt, sendBitcoin } = walletApi;
// 连接钱包
const connectFn = async () {
  const data = await connect({
    name: walletDict.unisat,
    network: network || "testnet",
    handleMismatchNetwork: true,
  });
  console.log("data", data)
  // 输出的data内容
  // {
  //   name: WalletName | null; // 钱包名称
  //   network: Network; // 当前网络
  //   publicKey: string; // 公钥
  //   accounts: string[]; // 账户
  //   address: string; // 钱包地址
  //   btcAddress: string; // BTC钱包地址
  //   btcPublicKey: string; // BTC钱包公钥
  //   balance?: {
  //     confirmed?: number; // 确认的余额
  //     total?: number; // 总余额
  //     unconfirmed?: number; // 未确认的余额
  //   };
  // }
}
// 断链
const disconnectFn = () => {
  disconnect()
}

// 签名
const signMessage = () => {
  return await sign({
    msg,
  });
  // signMsgStr
}

// 签psbt
const signPsbtFn = () => {
  return await signPsbt({
    psbt,
  });
  // hex psbt
}

// 签psbts
const signPsbtsFn = () => {
  return await signPsbts({ psbt: psbts, option: options });
  // ['hex psbt'....]
}

// 发送btc
const sendBitcoinFn = () => {
  return await sendBitcoin({
    address,
    satoshis,
    option,
  });
}

Api 部分

  1. getBase64Str 获取 base64 字符串
  2. getHexStr 获取 hex 字符串
  3. getNeedFinalList 获取 finalze 的列表
  4. completeFinalList 用于手动finalze