@bestinslot/wallet-kit 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +108 -0
  2. package/dist/balances-BQiaAIaq.js +9627 -0
  3. package/dist/browser.js +205 -0
  4. package/dist/core.js +39 -0
  5. package/dist/mint-BXVHw4CQ.js +70722 -0
  6. package/dist/node.js +1787 -0
  7. package/dist/react.js +14 -0
  8. package/dist/register-browser-providers-CLLT6W6P.js +499 -0
  9. package/dist/types/adapters/react/use-network.d.ts +8 -0
  10. package/dist/types/adapters/react/use-wallet.d.ts +15 -0
  11. package/dist/types/adapters/vue/use-network.d.ts +12 -0
  12. package/dist/types/api/balances.d.ts +52 -0
  13. package/dist/types/api/brc20.d.ts +110 -0
  14. package/dist/types/api/helpers.d.ts +3 -0
  15. package/dist/types/api/mint.d.ts +57 -0
  16. package/dist/types/api/modal.d.ts +3 -0
  17. package/dist/types/api/swap.d.ts +122 -0
  18. package/dist/types/api/wallet.browser.d.ts +2 -0
  19. package/dist/types/api/wallet.d.ts +6 -0
  20. package/dist/types/api/wallet.node.d.ts +4 -0
  21. package/dist/types/browser.d.ts +10 -0
  22. package/dist/types/components/Dev.vue.d.ts +11 -0
  23. package/dist/types/components/connect-modal-view.d.ts +28 -0
  24. package/dist/types/components/dev/BRC20.vue.d.ts +2 -0
  25. package/dist/types/components/dev/Button.vue.d.ts +17 -0
  26. package/dist/types/components/dev/Input.vue.d.ts +12 -0
  27. package/dist/types/components/dev/Label.vue.d.ts +17 -0
  28. package/dist/types/components/dev/Select.vue.d.ts +17 -0
  29. package/dist/types/components/dev/SessionInfo.vue.d.ts +6 -0
  30. package/dist/types/core/bis.d.ts +21 -0
  31. package/dist/types/core/bis_swap.d.ts +622 -0
  32. package/dist/types/core/brc20.d.ts +229 -0
  33. package/dist/types/core/connect-modal.d.ts +15 -0
  34. package/dist/types/core/helpers.d.ts +212 -0
  35. package/dist/types/core/mint.d.ts +364 -0
  36. package/dist/types/core/modal.d.ts +21 -0
  37. package/dist/types/core/providers.d.ts +90 -0
  38. package/dist/types/core/register-browser-providers.d.ts +1 -0
  39. package/dist/types/core/register-local-provider.d.ts +1 -0
  40. package/dist/types/core/storage.d.ts +19 -0
  41. package/dist/types/core/store-network.d.ts +20 -0
  42. package/dist/types/core/store.d.ts +39 -0
  43. package/dist/types/core.d.ts +10 -0
  44. package/dist/types/lib/bitcoin.d.ts +8 -0
  45. package/dist/types/lib/dev-worker.d.ts +1 -0
  46. package/dist/types/lib/dev.d.ts +9 -0
  47. package/dist/types/lib/swap-constants.d.ts +7 -0
  48. package/dist/types/lib/swap-reporting.d.ts +80 -0
  49. package/dist/types/lib/uniswap_ops.d.ts +238 -0
  50. package/dist/types/lib/web3.d.ts +7 -0
  51. package/dist/types/node.d.ts +9 -0
  52. package/dist/types/provider/api.d.ts +97 -0
  53. package/dist/types/provider/leather.d.ts +2 -0
  54. package/dist/types/provider/local.d.ts +39 -0
  55. package/dist/types/provider/okx.d.ts +2 -0
  56. package/dist/types/provider/unisat.d.ts +2 -0
  57. package/dist/types/provider/xverse.d.ts +2 -0
  58. package/dist/types/react.d.ts +3 -0
  59. package/dist/types/types/common.d.ts +33 -0
  60. package/dist/types/types/global.d.ts +26 -0
  61. package/dist/types/types/inscription.d.ts +147 -0
  62. package/dist/types/types/vite-env.d.ts +7 -0
  63. package/dist/types/types/wallet.d.ts +50 -0
  64. package/dist/types/vue.d.ts +2 -0
  65. package/dist/vue.js +13 -0
  66. package/package.json +133 -0
package/dist/react.js ADDED
@@ -0,0 +1,14 @@
1
+ import { useSyncExternalStore as u, useCallback as r, useState as i } from "react";
2
+ import { w as c, d as t, i as l, h as n } from "./mint-BXVHw4CQ.js";
3
+ function m() {
4
+ const e = u(c, t, t), s = r((o) => l(o), []);
5
+ return [e, s];
6
+ }
7
+ function S() {
8
+ const e = u(c, t, t), [s, o] = i(() => n() ?? null), a = r(() => o(n() ?? null), []), k = r((w) => l(w), []);
9
+ return { session: s, network: e, setNetwork: k, refresh: a };
10
+ }
11
+ export {
12
+ m as useNetwork,
13
+ S as useWallet
14
+ };
@@ -0,0 +1,499 @@
1
+ import { x as l, y as x, z as k, d, A as B, B as p, f as S, C as P, D as T } from "./mint-BXVHw4CQ.js";
2
+ async function X() {
3
+ if (!window.LeatherProvider)
4
+ throw new Error("Leather extension not found.");
5
+ const n = await window.LeatherProvider.request("getAddresses");
6
+ if (!n)
7
+ throw new Error("Failed to get wallets.");
8
+ return n.result.addresses.map((t) => ({
9
+ address: t.address,
10
+ pubkey: t.publicKey || null,
11
+ purpose: t.type === "p2wpkh" ? "payment" : t.type === "p2tr" ? "ordinals" : "stx"
12
+ }));
13
+ }
14
+ async function $(n, e) {
15
+ if (!window.LeatherProvider)
16
+ throw new Error("Leather extension not found.");
17
+ if (!e)
18
+ throw new Error("Wallet type is required for signing messages with Leather.");
19
+ try {
20
+ const t = await window.LeatherProvider.request("signMessage", {
21
+ message: n,
22
+ paymentType: e === "ordinals" ? "p2tr" : "p2wpkh",
23
+ network: d()
24
+ });
25
+ return p.from(t.result.signature, "base64").toString("hex");
26
+ } catch (t) {
27
+ throw new Error(`Failed to sign message: ${t.message}`);
28
+ }
29
+ }
30
+ async function F(n) {
31
+ if (!window.LeatherProvider)
32
+ throw new Error("Leather extension not found.");
33
+ try {
34
+ const e = await window.LeatherProvider.request("signMessage", {
35
+ message: n,
36
+ paymentType: "p2wpkh",
37
+ network: d()
38
+ });
39
+ return {
40
+ signature: p.from(e.result.signature, "base64").toString("hex"),
41
+ address: e.result.address
42
+ };
43
+ } catch (e) {
44
+ throw new Error(`Failed to sign message: ${e.message}`);
45
+ }
46
+ }
47
+ async function L(n, e) {
48
+ if (!window.LeatherProvider)
49
+ throw new Error("Leather extension not found.");
50
+ try {
51
+ return (await window.LeatherProvider.request("sendTransfer", {
52
+ recipients: [
53
+ {
54
+ address: e,
55
+ amount: n.toString()
56
+ }
57
+ ],
58
+ network: d()
59
+ })).result.txid;
60
+ } catch (t) {
61
+ throw new Error(`Failed to send BTC: ${t.message}`);
62
+ }
63
+ }
64
+ async function M(n, e, t) {
65
+ if (!window.LeatherProvider)
66
+ throw new Error("Leather extension not found.");
67
+ const s = [];
68
+ for (let i = 0; i < t.length; i++)
69
+ for (let r = 0; r < t[i].signingIndexes.length; r++)
70
+ s.push(t[i].signingIndexes[r]);
71
+ return (await window.LeatherProvider.request("signPsbt", {
72
+ hex: B(n),
73
+ network: d(),
74
+ broadcast: e,
75
+ signAtIndex: s
76
+ })).result?.hex ?? "";
77
+ }
78
+ async function C(n, e, t, s, o, i) {
79
+ const r = l.Psbt.fromHex(n), a = [];
80
+ for (let w = 0; w < r.inputCount; w++)
81
+ i && i.includes(w) || s.includes(w) || a.push(w);
82
+ const c = await M(x(n), !1, [
83
+ {
84
+ address: e,
85
+ signingIndexes: a,
86
+ sigHash: l.Transaction.SIGHASH_DEFAULT
87
+ },
88
+ {
89
+ address: t,
90
+ signingIndexes: s,
91
+ sigHash: l.Transaction.SIGHASH_DEFAULT
92
+ }
93
+ ]), g = l.Psbt.fromHex(c);
94
+ k(g, i);
95
+ const u = g.extractTransaction(), f = u.toHex();
96
+ return {
97
+ txId: u.getId(),
98
+ signedTxHex: f
99
+ };
100
+ }
101
+ const I = {
102
+ getWallets: X,
103
+ signMessage: $,
104
+ signMessageDeterministic: F,
105
+ sendBTC: L,
106
+ signPSBT: M,
107
+ sign: C
108
+ };
109
+ async function K() {
110
+ if (!window.okxwallet)
111
+ throw new Error("OKX extension not found.");
112
+ const n = d();
113
+ let e;
114
+ if (n === "mainnet")
115
+ e = await window.okxwallet.bitcoin.connect();
116
+ else if (n === "testnet")
117
+ e = await window.okxwallet.bitcoinTestnet.connect();
118
+ else if (n === "signet")
119
+ e = await window.okxwallet.bitcoinSignet.connect();
120
+ else throw new Error("Unsupported network for OKX.");
121
+ if (!e)
122
+ throw new Error("Error fetching wallet data.");
123
+ return [
124
+ {
125
+ address: e.address,
126
+ pubkey: e.publicKey,
127
+ purpose: "all"
128
+ }
129
+ ];
130
+ }
131
+ async function U(n) {
132
+ if (!window.okxwallet)
133
+ throw new Error("OKX extension not found.");
134
+ const e = d();
135
+ let t;
136
+ if (e === "mainnet")
137
+ t = await window.okxwallet.bitcoin.signMessage(n, "bip322-simple");
138
+ else if (e === "testnet")
139
+ t = await window.okxwallet.bitcoinTestnet.signMessage(n, "bip322-simple");
140
+ else if (e === "signet")
141
+ t = await window.okxwallet.bitcoinSignet.signMessage(n, "bip322-simple");
142
+ else throw new Error("Unsupported network for OKX.");
143
+ return p.from(t, "base64").toString("hex");
144
+ }
145
+ async function D(n) {
146
+ if (!window.okxwallet)
147
+ throw new Error("OKX extension not found.");
148
+ const e = S();
149
+ if (!e)
150
+ throw new Error("No payment wallet found.");
151
+ const t = e.address, s = d();
152
+ let o;
153
+ if (s === "mainnet")
154
+ o = await window.okxwallet.bitcoin.signMessage(n, "ecdsa");
155
+ else if (s === "testnet")
156
+ o = await window.okxwallet.bitcoinTestnet.signMessage(n, "ecdsa");
157
+ else if (s === "signet")
158
+ o = await window.okxwallet.bitcoinSignet.signMessage(n, "ecdsa");
159
+ else throw new Error("Unsupported network for OKX.");
160
+ return {
161
+ signature: p.from(o, "base64").toString("hex"),
162
+ address: t
163
+ };
164
+ }
165
+ async function q(n, e) {
166
+ if (!window.okxwallet)
167
+ throw new Error("OKX extension not found.");
168
+ const t = d();
169
+ let s;
170
+ if (t === "mainnet")
171
+ s = await window.okxwallet.bitcoin.sendBitcoin(e, n);
172
+ else if (t === "testnet")
173
+ s = await window.okxwallet.bitcoinTestnet.sendBitcoin(e, n);
174
+ else if (t === "signet")
175
+ s = await window.okxwallet.bitcoinSignet.sendBitcoin(e, n);
176
+ else
177
+ throw new Error("Unsupported network for OKX.");
178
+ return s;
179
+ }
180
+ async function E(n, e, t) {
181
+ const s = B(n);
182
+ let o = null;
183
+ if (t.length !== 0) {
184
+ const i = [];
185
+ for (const r of t)
186
+ for (let a = 0; a < r.signingIndexes.length; a++)
187
+ i.push({
188
+ address: r.address,
189
+ index: r.signingIndexes[a]
190
+ // disableTweakSigner: i == 0 ? true : false // TODO: remove this hack!!
191
+ });
192
+ o = {
193
+ autoFinalized: !0,
194
+ toSignInputs: i
195
+ };
196
+ }
197
+ if (d() === "mainnet") {
198
+ let i = null;
199
+ return o ? i = await window.okxwallet.bitcoin.signPsbt(s, o) : i = await window.okxwallet.bitcoin.signPsbt(s), e && await window.okxwallet.bitcoin.pushPsbt(i), i;
200
+ } else if (d() === "testnet") {
201
+ if (e)
202
+ throw new Error("Cannot broadcast on testnet with okx");
203
+ let i = null;
204
+ return o ? i = await window.okxwallet.bitcoinTestnet.signPsbt(s, o) : i = await window.okxwallet.bitcoinTestnet.signPsbt(s), i;
205
+ } else if (d() === "signet") {
206
+ if (e)
207
+ throw new Error("Cannot broadcast on signet with okx");
208
+ let i = null;
209
+ return o ? i = await window.okxwallet.bitcoinSignet.signPsbt(s, o) : i = await window.okxwallet.bitcoinSignet.signPsbt(s), i;
210
+ } else
211
+ throw new Error("Unsupported network for OKX.");
212
+ }
213
+ async function N(n, e, t, s, o, i) {
214
+ let r = null;
215
+ if (!e)
216
+ r = await E(x(n), !1, []);
217
+ else {
218
+ const u = l.Psbt.fromHex(n), f = [];
219
+ for (let w = 0; w < u.inputCount; w++)
220
+ i && i.includes(w) || s.includes(w) || f.push(w);
221
+ r = await E(x(n), !1, [
222
+ {
223
+ address: e,
224
+ signingIndexes: f
225
+ },
226
+ {
227
+ address: t,
228
+ signingIndexes: s
229
+ }
230
+ ]);
231
+ }
232
+ const a = l.Psbt.fromHex(r);
233
+ k(a, i);
234
+ const c = a.extractTransaction(), g = c.toHex();
235
+ return {
236
+ txId: c.getId(),
237
+ signedTxHex: g
238
+ };
239
+ }
240
+ const O = {
241
+ getWallets: K,
242
+ signMessage: U,
243
+ signMessageDeterministic: D,
244
+ sendBTC: q,
245
+ signPSBT: E,
246
+ sign: N
247
+ };
248
+ async function b() {
249
+ if (!window.unisat)
250
+ throw new Error("UniSat not found.");
251
+ const n = await window.unisat.getNetwork(), e = d();
252
+ n !== "livenet" && e === "mainnet" ? await window.unisat.switchNetwork("livenet") : n === "livenet" && (e === "testnet" || e === "signet") && await window.unisat.switchNetwork("testnet");
253
+ }
254
+ async function W() {
255
+ await b();
256
+ const n = await window.unisat?.requestAccounts(), e = await window.unisat?.getPublicKey();
257
+ if (!n)
258
+ throw new Error("Failed to get wallets.");
259
+ return n.map((s) => ({
260
+ address: s,
261
+ pubkey: e,
262
+ purpose: "all"
263
+ }));
264
+ }
265
+ async function A(n) {
266
+ await b();
267
+ try {
268
+ const e = await window.unisat.signMessage(n, "bip322-simple");
269
+ return p.from(e, "base64").toString("hex");
270
+ } catch (e) {
271
+ throw console.error("Failed to sign message", e), new Error("Failed to sign message.");
272
+ }
273
+ }
274
+ async function _(n) {
275
+ await b();
276
+ const e = S();
277
+ if (!e)
278
+ throw new Error("No payment wallet found.");
279
+ const t = e.address;
280
+ try {
281
+ const s = await window.unisat.signMessage(n, "ecdsa");
282
+ return {
283
+ signature: p.from(s, "base64").toString("hex"),
284
+ address: t
285
+ };
286
+ } catch (s) {
287
+ throw console.error("Failed to sign message", s), new Error("Failed to sign message.");
288
+ }
289
+ }
290
+ async function z(n, e) {
291
+ await b();
292
+ try {
293
+ return await window.unisat.sendBitcoin(e, n);
294
+ } catch (t) {
295
+ throw console.error("Failed to send BTC", t), new Error("Failed to send BTC.");
296
+ }
297
+ }
298
+ async function v(n, e, t) {
299
+ if (await b(), !window.unisat)
300
+ throw new Error("UniSat not found.");
301
+ const s = B(n);
302
+ let o = null;
303
+ if (t.length === 0)
304
+ o = await window.unisat.signPsbt(s);
305
+ else {
306
+ const i = [];
307
+ for (const a of t)
308
+ for (let c = 0; c < a.signingIndexes.length; c++)
309
+ i.push({
310
+ address: a.address,
311
+ index: a.signingIndexes[c],
312
+ useTweakedSigner: a.useTweakedSigner ? a.useTweakedSigner[c] : void 0
313
+ });
314
+ const r = {
315
+ autoFinalized: !0,
316
+ toSignInputs: i
317
+ };
318
+ o = await window.unisat.signPsbt(s, r);
319
+ }
320
+ return e && (o = await window.unisat.pushPsbt(o)), o;
321
+ }
322
+ async function G(n, e, t, s, o, i) {
323
+ let r = null;
324
+ if (!e)
325
+ r = await v(x(n), !1, []);
326
+ else {
327
+ const u = l.Psbt.fromHex(n), f = [], w = [], y = [];
328
+ for (let h = 0; h < u.inputCount; h++)
329
+ if (!(i && i.includes(h))) {
330
+ if (s.includes(h)) {
331
+ o && o.includes(h) ? y.push(!0) : o && y.push(!1);
332
+ continue;
333
+ }
334
+ f.push(h), o && o.includes(h) ? w.push(!0) : o && w.push(!1);
335
+ }
336
+ r = await v(x(n), !1, [
337
+ {
338
+ address: e,
339
+ signingIndexes: f,
340
+ useTweakedSigner: w
341
+ },
342
+ {
343
+ address: t,
344
+ signingIndexes: s,
345
+ useTweakedSigner: y
346
+ }
347
+ ]);
348
+ }
349
+ const a = l.Psbt.fromHex(r);
350
+ k(a, i);
351
+ const c = a.extractTransaction(), g = c.toHex();
352
+ return {
353
+ txId: c.getId(),
354
+ signedTxHex: g
355
+ };
356
+ }
357
+ const R = {
358
+ checkNetwork: b,
359
+ getWallets: W,
360
+ signMessage: A,
361
+ signMessageDeterministic: _,
362
+ sendBTC: z,
363
+ signPSBT: v,
364
+ sign: G
365
+ };
366
+ function m() {
367
+ const n = d();
368
+ if (n === "mainnet")
369
+ return "Mainnet";
370
+ if (n === "testnet")
371
+ return "Testnet4";
372
+ if (n === "signet")
373
+ return "Signet";
374
+ throw new Error("Unknown BTC network type.");
375
+ }
376
+ async function j() {
377
+ if (!window.XverseProviders?.BitcoinProvider)
378
+ throw new Error("Xverse extension not found.");
379
+ const n = P({
380
+ purposes: ["ordinals", "payment"],
381
+ message: "[Best in Slot] wants to know your addresses!",
382
+ network: {
383
+ type: m()
384
+ }
385
+ }), e = await window.XverseProviders.BitcoinProvider?.connect(n);
386
+ if (!e)
387
+ throw new Error("Error fetching wallet data.");
388
+ return e.addresses.map((s) => ({
389
+ address: s.address,
390
+ pubkey: s.publicKey,
391
+ purpose: s.purpose
392
+ }));
393
+ }
394
+ async function V(n, e) {
395
+ if (!window.XverseProviders?.BitcoinProvider)
396
+ throw new Error("Xverse extension not found.");
397
+ const t = P({
398
+ address: e,
399
+ message: n,
400
+ protocol: "BIP322",
401
+ network: {
402
+ type: m()
403
+ }
404
+ }), s = await window.XverseProviders.BitcoinProvider.signMessage(t).catch(
405
+ (o) => {
406
+ throw console.error("Failed to sign message.", o), new Error("Failed to sign message.");
407
+ }
408
+ );
409
+ return p.from(s, "base64").toString("hex");
410
+ }
411
+ async function J(n) {
412
+ if (!window.XverseProviders?.BitcoinProvider)
413
+ throw new Error("Xverse extension not found.");
414
+ const e = S();
415
+ if (!e)
416
+ throw new Error("No payment wallet found.");
417
+ const t = e.address, s = P({
418
+ address: t,
419
+ message: n,
420
+ protocol: "ECDSA",
421
+ network: {
422
+ type: m()
423
+ }
424
+ }), o = await window.XverseProviders.BitcoinProvider.signMessage(s).catch(
425
+ (i) => {
426
+ throw console.error("Failed to sign message.", i), new Error("Failed to sign message.");
427
+ }
428
+ );
429
+ return {
430
+ signature: p.from(o, "base64").toString("hex"),
431
+ address: t
432
+ };
433
+ }
434
+ async function Q(n, e) {
435
+ if (!window.XverseProviders?.BitcoinProvider)
436
+ throw new Error("Xverse extension not found.");
437
+ return (await window.XverseProviders.BitcoinProvider.request("sendTransfer", {
438
+ recipients: [
439
+ {
440
+ address: e,
441
+ amount: n
442
+ }
443
+ ]
444
+ })).result.txid;
445
+ }
446
+ async function H(n, e, t, s) {
447
+ if (!window.XverseProviders?.BitcoinProvider)
448
+ throw new Error("Xverse extension not found.");
449
+ const o = P({
450
+ network: {
451
+ type: m()
452
+ },
453
+ message: s || "Sign Transaction",
454
+ psbtBase64: n,
455
+ broadcast: e,
456
+ inputsToSign: t
457
+ });
458
+ return await window.XverseProviders.BitcoinProvider.signTransaction(o);
459
+ }
460
+ async function Y(n, e, t, s, o, i) {
461
+ const r = l.Psbt.fromHex(n), a = [];
462
+ for (let w = 0; w < r.inputCount; w++)
463
+ i && i.includes(w) || s.includes(w) || a.push(w);
464
+ const c = await H(
465
+ x(n),
466
+ !1,
467
+ [
468
+ {
469
+ address: e,
470
+ signingIndexes: a,
471
+ sigHash: l.Transaction.SIGHASH_DEFAULT
472
+ },
473
+ {
474
+ address: t,
475
+ signingIndexes: s,
476
+ sigHash: l.Transaction.SIGHASH_DEFAULT
477
+ }
478
+ ],
479
+ "sign this pls"
480
+ ), g = l.Psbt.fromBase64(c.psbtBase64);
481
+ k(g, i);
482
+ const u = g.extractTransaction(), f = u.toHex();
483
+ return {
484
+ txId: u.getId(),
485
+ signedTxHex: f
486
+ };
487
+ }
488
+ const Z = {
489
+ getWallets: j,
490
+ signMessage: V,
491
+ signMessageDeterministic: J,
492
+ sendBTC: Q,
493
+ signPSBT: H,
494
+ sign: Y
495
+ };
496
+ T("leather", I);
497
+ T("okx", O);
498
+ T("unisat", R);
499
+ T("xverse", Z);
@@ -0,0 +1,8 @@
1
+ import { BISNetwork } from '../../types/common';
2
+ /**
3
+ * React adapter: subscribes to the framework-agnostic network store. Returns the
4
+ * current network and a setter, mirroring the Vue `useNetwork()` composable.
5
+ *
6
+ * @returns A `[network, setNetwork]` tuple.
7
+ */
8
+ export declare function useNetwork(): [BISNetwork, (network: BISNetwork) => void];
@@ -0,0 +1,15 @@
1
+ import { BISNetwork, BISSession } from '../../types/common';
2
+ /**
3
+ * React adapter: convenience hook bundling the connected session and the
4
+ * reactive network. `session` is read on mount and refreshable via `refresh()`
5
+ * (call it after your own connect flow resolves).
6
+ *
7
+ * @returns The current session (or null), the reactive network, a network
8
+ * setter, and a `refresh` to re-read the stored session.
9
+ */
10
+ export declare function useWallet(): {
11
+ session: BISSession | null;
12
+ network: BISNetwork;
13
+ setNetwork: (network: BISNetwork) => void;
14
+ refresh: () => void;
15
+ };
@@ -0,0 +1,12 @@
1
+ import { Ref } from 'vue';
2
+ import { BISNetwork } from '../../types/common';
3
+ /**
4
+ * Browser/Vue-only adapter: a reactive ref two-way synced to the framework-agnostic
5
+ * network store in `./store-network`. Reading reflects the current network; writing
6
+ * (e.g. via `v-model`) updates the shared store and every other consumer.
7
+ *
8
+ * Not part of the server build — it imports Vue.
9
+ *
10
+ * @returns A reactive ref to the current network.
11
+ */
12
+ export declare function useNetwork(): Ref<BISNetwork>;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Interface representing the balance information for a base BRC-20 token, including the available balance, transferrable balance, decimals, and ticker.
3
+ * The balances are represented in 18 decimals as per the BRC-20 standard, and the decimals field indicates the actual number of decimals for the token. The ticker field provides the symbol for the token.
4
+ *
5
+ * The availableBalanceIn18Decimals and transferrableBalanceIn18Decimals fields are returned as strings from the API and converted to bigint in the checkBaseBRC20BalanceOfAddress function for easier handling of large numbers. The decimals field is used to determine how to convert the 18-decimal balances to the actual token balance based on the token's specific decimal places. The ticker field is used for display purposes to show the token symbol alongside the balance information.
6
+ *
7
+ * availableBalanceIn18Decimals: The total balance of the specified BRC-20 token that is available in the Bitcoin address, represented in 18 decimals as per the BRC-20 standard. This balance includes all tokens that are currently held in the address, regardless of whether they are transferrable or not.
8
+ * transferrableBalanceIn18Decimals: The portion of the available balance that is currently transferrable, represented in 18 decimals. This balance indicates how many tokens can be transferred from the address at the current time, taking into account any restrictions or locks on the tokens.
9
+ * decimals: The number of decimal places that the specific BRC-20 token uses. This field is important for converting the 18-decimal balances to the actual token balance, as different tokens may have different decimal places.
10
+ * ticker: The symbol or abbreviation for the BRC-20 token, used for display purposes to identify the token alongside its balance information.
11
+ */
12
+ export interface BaseBRC20Balance {
13
+ availableBalanceIn18Decimals: bigint;
14
+ transferrableBalanceIn18Decimals: bigint;
15
+ decimals: number;
16
+ ticker: string;
17
+ }
18
+ /**
19
+ * Checks the base BRC-20 token balance for a given Bitcoin address and token address by making an API call to the swap backend.
20
+ *
21
+ * @param btcAddress The Bitcoin address to check the BRC-20 balance for.
22
+ * @param tokenAddress The address of the BRC-20 token to check the balance for.
23
+ *
24
+ * @returns {Promise<BaseBRC20Balance>} A promise that resolves to an object containing the available balance, transferrable balance, decimals, and ticker for the specified Bitcoin address and BRC-20 token address. The balances are returned as strings from the API and converted to bigint in this function.
25
+ */
26
+ export declare function getBaseBRC20BalanceOfAddress(btcAddress: string, tokenAddress: string): Promise<BaseBRC20Balance>;
27
+ /**
28
+ * Checks the BRC2.0 token balance for a given Bitcoin address and token address by making an API call to the swap backend. This function is used for checking the balance of BRC-20 tokens that are not based on the base BRC-20 standard, and it returns the balance as a single bigint value representing the total balance in 18 decimals.
29
+ *
30
+ * @param bitcoinAddress The Bitcoin address to check the BRC-20 balance for.
31
+ * @param tokenAddress The address of the BRC-20 token to check the balance for.
32
+ *
33
+ * @returns {Promise<bigint>} A promise that resolves to a bigint representing the total balance in 18 decimals for the specified Bitcoin address and BRC-20 token address.
34
+ */
35
+ export declare function getBRC20ProgBalanceOfAddress(bitcoinAddress: string, tokenAddress: string): Promise<bigint>;
36
+ /**
37
+ * Checks the BRC2.0 token balance for a given Bitcoin address and ticker by making an API call to the swap backend. This function is used for checking the balance of BRC-20 tokens that are not based on the base BRC-20 standard, and it returns the balance as a single bigint value representing the total balance in 18 decimals.
38
+ *
39
+ * @param bitcoinAddress The Bitcoin address to check the BRC-20 balance for.
40
+ * @param ticker The ticker of the BRC-20 token to check the balance for.
41
+ *
42
+ * @returns {Promise<bigint>} A promise that resolves to a bigint representing the total balance in 18 decimals for the specified Bitcoin address and BRC-20 token.
43
+ */
44
+ export declare function getBRC20ProgBalanceOfTicker(bitcoinAddress: string, ticker: string): Promise<bigint>;
45
+ /**
46
+ * Get token address of a ticker in BRC2.0 by making an API call to the public RPC.
47
+ *
48
+ * @param ticker The ticker of the BRC-20 token.
49
+ *
50
+ * @returns {Promise<string>} A promise that resolves to a string representing the token address of the specified ticker.
51
+ */
52
+ export declare function getBRC20ProgTokenAddressOfTicker(ticker: string): Promise<string>;