1.0.72 • Published 4 months ago
dotswap-wallet v1.0.72
web3 钱包聚合库
设计的初衷
- 使用立即执行函数保持私有域变量,确定钱包信息变量锁定,并脱离所有框架的生命周期。
- 磨平不同平台调用不同钱包api内容
- 脱离于各项目,物理隔离wallet钱包和项目业务逻辑两者产生的问题
主要的 api 与变量
- walletApi 用于调用钱包 api 的。
- walletDict 支持的钱包的字典对应
- hasWallet 获取浏览器中是否存在对应的钱包
walletApi 提供的 api 与方法
- connect 用于连接钱包
- disconnect 用于断开钱包
- getInfo 获取用户信息
- sign 用于签名
- signPsbt 用于签名 psbt
- signPsbts 用于多签签名 psbts
- sendBitcoin 用于发送 btc
- 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 部分
- getBase64Str 获取 base64 字符串
- getHexStr 获取 hex 字符串
- getNeedFinalList 获取 finalze 的列表
- completeFinalList 用于手动finalze
1.0.72
4 months ago
1.0.71
4 months ago
1.0.70
4 months ago
1.0.69
5 months ago
1.0.68
5 months ago
1.0.67
5 months ago
1.0.66
8 months ago
1.0.65
9 months ago
1.0.64
9 months ago
1.0.62
9 months ago
1.0.61
9 months ago
1.0.60
10 months ago
1.0.63
9 months ago
1.0.48
10 months ago
1.0.47
10 months ago
1.0.46
10 months ago
1.0.49
10 months ago
1.0.51
10 months ago
1.0.50
10 months ago
1.0.55
10 months ago
1.0.54
10 months ago
1.0.53
10 months ago
1.0.52
10 months ago
1.0.59
10 months ago
1.0.58
10 months ago
1.0.57
10 months ago
1.0.56
10 months ago
1.0.43
11 months ago
1.0.42
11 months ago
1.0.41
11 months ago
1.0.45
11 months ago
1.0.39
12 months ago
1.0.38
1 year ago
1.0.40
12 months ago
1.0.37
1 year ago
1.0.36
1 year ago
1.0.33
1 year ago
1.0.32
1 year ago
1.0.35
1 year ago
1.0.34
1 year ago
1.0.29
1 year ago
1.0.31
1 year ago
1.0.30
1 year ago
1.0.28
1 year ago
1.0.27
1 year ago
1.0.26
1 year ago
1.0.25
1 year ago
1.0.24
1 year ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.23
1 year ago
1.0.19
1 year ago
1.0.18
1 year ago
1.0.17
1 year ago
1.0.16
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.0
1 year ago