@bestinslot/wallet-kit 0.13.5 → 0.13.8
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.
- package/README.md +4 -0
- package/dist/{balances-CqYGF0ez.js → balances-BnXuM9CG.js} +2362 -2073
- package/dist/browser.js +55 -53
- package/dist/core.js +33 -29
- package/dist/{mint-C_wN10-d.js → mint-CHlWPuov.js} +201 -102
- package/dist/node.js +192 -190
- package/dist/react.js +5 -5
- package/dist/{register-browser-providers-J2bm6PEo.js → register-browser-providers-b9rpXGqV.js} +35 -35
- package/dist/types/api/brc20.d.ts +42 -0
- package/dist/types/api/swap.d.ts +14 -2
- package/dist/types/api/wallet.d.ts +2 -2
- package/dist/types/core/bis.d.ts +2 -1
- package/dist/types/core/bis_swap.d.ts +49 -0
- package/dist/types/core/brc20-send.d.ts +96 -0
- package/dist/types/core/helpers.d.ts +39 -18
- package/dist/types/core/mint.d.ts +1 -0
- package/dist/types/core/store-network.d.ts +42 -0
- package/dist/types/core.d.ts +2 -1
- package/dist/vue.js +9 -9
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useSyncExternalStore as u, useCallback as r, useState as w } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { T as c, e, k as l, i as n } from "./mint-CHlWPuov.js";
|
|
3
3
|
function m() {
|
|
4
|
-
const
|
|
5
|
-
return [
|
|
4
|
+
const t = u(c, e, e), s = r((o) => l(o), []);
|
|
5
|
+
return [t, s];
|
|
6
6
|
}
|
|
7
7
|
function S() {
|
|
8
|
-
const
|
|
9
|
-
return { session: s, network:
|
|
8
|
+
const t = u(c, e, e), [s, o] = w(() => n() ?? null), a = r(() => o(n() ?? null), []), k = r((i) => l(i), []);
|
|
9
|
+
return { session: s, network: t, setNetwork: k, refresh: a };
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
12
|
m as useNetwork,
|
package/dist/{register-browser-providers-J2bm6PEo.js → register-browser-providers-b9rpXGqV.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
async function
|
|
1
|
+
import { F as l, E as x, G as b, e as d, U as B, I as p, h as S, V as P, S as T } from "./mint-CHlWPuov.js";
|
|
2
|
+
async function C() {
|
|
3
3
|
if (!window.LeatherProvider) throw new Error("Leather extension not found.");
|
|
4
4
|
const e = await window.LeatherProvider.request("getAddresses");
|
|
5
5
|
if (!e) throw new Error("Failed to get wallets.");
|
|
@@ -92,14 +92,14 @@ async function I(e, n, t, s, o, i) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
const A = {
|
|
95
|
-
getWallets:
|
|
95
|
+
getWallets: C,
|
|
96
96
|
signMessage: $,
|
|
97
97
|
signMessageDeterministic: L,
|
|
98
98
|
sendBTC: F,
|
|
99
99
|
signPSBT: M,
|
|
100
100
|
sign: I
|
|
101
101
|
};
|
|
102
|
-
async function
|
|
102
|
+
async function U() {
|
|
103
103
|
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
104
104
|
const e = d();
|
|
105
105
|
let n;
|
|
@@ -116,24 +116,24 @@ async function K() {
|
|
|
116
116
|
}
|
|
117
117
|
];
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function H() {
|
|
120
120
|
const e = d();
|
|
121
121
|
if (e === "mainnet") return window.okxwallet?.bitcoin;
|
|
122
122
|
if (e === "testnet") return window.okxwallet?.bitcoinTestnet;
|
|
123
123
|
if (e === "signet") return window.okxwallet?.bitcoinSignet;
|
|
124
124
|
}
|
|
125
|
-
async function
|
|
126
|
-
const e =
|
|
125
|
+
async function K() {
|
|
126
|
+
const e = H();
|
|
127
127
|
return typeof e?.getAccounts != "function" ? [] : await e.getAccounts() ?? [];
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
const n =
|
|
129
|
+
function N(e) {
|
|
130
|
+
const n = H();
|
|
131
131
|
if (typeof n?.on != "function") return () => {
|
|
132
132
|
};
|
|
133
133
|
const t = (s) => e(s?.address ? [s.address] : []);
|
|
134
134
|
return n.on("accountChanged", t), () => n.removeListener?.("accountChanged", t);
|
|
135
135
|
}
|
|
136
|
-
async function
|
|
136
|
+
async function q(e) {
|
|
137
137
|
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
138
138
|
const n = d();
|
|
139
139
|
let t;
|
|
@@ -146,7 +146,7 @@ async function N(e) {
|
|
|
146
146
|
else throw new Error("Unsupported network for OKX.");
|
|
147
147
|
return p.from(t, "base64").toString("hex");
|
|
148
148
|
}
|
|
149
|
-
async function
|
|
149
|
+
async function D(e) {
|
|
150
150
|
if (!window.okxwallet) throw new Error("OKX extension not found.");
|
|
151
151
|
const n = S();
|
|
152
152
|
if (!n) throw new Error("No payment wallet found.");
|
|
@@ -239,11 +239,11 @@ async function W(e, n, t, s, o, i) {
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
const _ = {
|
|
242
|
-
getWallets:
|
|
243
|
-
getAccounts:
|
|
244
|
-
onAccountsChanged:
|
|
245
|
-
signMessage:
|
|
246
|
-
signMessageDeterministic:
|
|
242
|
+
getWallets: U,
|
|
243
|
+
getAccounts: K,
|
|
244
|
+
onAccountsChanged: N,
|
|
245
|
+
signMessage: q,
|
|
246
|
+
signMessageDeterministic: D,
|
|
247
247
|
sendBTC: O,
|
|
248
248
|
signPSBT: v,
|
|
249
249
|
sign: W
|
|
@@ -273,7 +273,7 @@ function R(e) {
|
|
|
273
273
|
const t = (s) => e(s ?? []);
|
|
274
274
|
return n.on("accountsChanged", t), () => n.removeListener?.("accountsChanged", t);
|
|
275
275
|
}
|
|
276
|
-
async function
|
|
276
|
+
async function V(e) {
|
|
277
277
|
await k();
|
|
278
278
|
try {
|
|
279
279
|
const n = await window.unisat.signMessage(e, "bip322-simple");
|
|
@@ -282,7 +282,7 @@ async function j(e) {
|
|
|
282
282
|
throw console.error("Failed to sign message", n), new Error("Failed to sign message.");
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
async function
|
|
285
|
+
async function j(e) {
|
|
286
286
|
await k();
|
|
287
287
|
const n = S();
|
|
288
288
|
if (!n) throw new Error("No payment wallet found.");
|
|
@@ -297,7 +297,7 @@ async function Q(e) {
|
|
|
297
297
|
throw console.error("Failed to sign message", s), new Error("Failed to sign message.");
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
async function
|
|
300
|
+
async function J(e, n) {
|
|
301
301
|
await k();
|
|
302
302
|
try {
|
|
303
303
|
return await window.unisat.sendBitcoin(n, e);
|
|
@@ -328,7 +328,7 @@ async function E(e, n, t) {
|
|
|
328
328
|
}
|
|
329
329
|
return n && (o = await window.unisat.pushPsbt(o)), o;
|
|
330
330
|
}
|
|
331
|
-
async function
|
|
331
|
+
async function Q(e, n, t, s, o, i) {
|
|
332
332
|
let r = null;
|
|
333
333
|
if (!n)
|
|
334
334
|
r = await E(x(e), !1, []);
|
|
@@ -368,11 +368,11 @@ const Y = {
|
|
|
368
368
|
getWallets: G,
|
|
369
369
|
getAccounts: z,
|
|
370
370
|
onAccountsChanged: R,
|
|
371
|
-
signMessage:
|
|
372
|
-
signMessageDeterministic:
|
|
373
|
-
sendBTC:
|
|
371
|
+
signMessage: V,
|
|
372
|
+
signMessageDeterministic: j,
|
|
373
|
+
sendBTC: J,
|
|
374
374
|
signPSBT: E,
|
|
375
|
-
sign:
|
|
375
|
+
sign: Q
|
|
376
376
|
};
|
|
377
377
|
function y() {
|
|
378
378
|
const e = d();
|
|
@@ -383,7 +383,7 @@ function y() {
|
|
|
383
383
|
}
|
|
384
384
|
async function Z() {
|
|
385
385
|
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
386
|
-
const e =
|
|
386
|
+
const e = P({
|
|
387
387
|
purposes: ["ordinals", "payment"],
|
|
388
388
|
message: "[Best in Slot] wants to know your addresses!",
|
|
389
389
|
network: {
|
|
@@ -399,7 +399,7 @@ async function Z() {
|
|
|
399
399
|
}
|
|
400
400
|
async function ee(e, n, t) {
|
|
401
401
|
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
402
|
-
const s =
|
|
402
|
+
const s = P({
|
|
403
403
|
address: t,
|
|
404
404
|
message: e,
|
|
405
405
|
protocol: "BIP322",
|
|
@@ -417,7 +417,7 @@ async function ne(e) {
|
|
|
417
417
|
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
418
418
|
const n = S();
|
|
419
419
|
if (!n) throw new Error("No payment wallet found.");
|
|
420
|
-
const t = n.address, s =
|
|
420
|
+
const t = n.address, s = P({
|
|
421
421
|
address: t,
|
|
422
422
|
message: e,
|
|
423
423
|
protocol: "ECDSA",
|
|
@@ -445,9 +445,9 @@ async function te(e, n) {
|
|
|
445
445
|
]
|
|
446
446
|
})).result.txid;
|
|
447
447
|
}
|
|
448
|
-
async function
|
|
448
|
+
async function X(e, n, t, s) {
|
|
449
449
|
if (!window.XverseProviders?.BitcoinProvider) throw new Error("Xverse extension not found.");
|
|
450
|
-
const o =
|
|
450
|
+
const o = P({
|
|
451
451
|
network: {
|
|
452
452
|
type: y()
|
|
453
453
|
},
|
|
@@ -462,7 +462,7 @@ async function se(e, n, t, s, o, i) {
|
|
|
462
462
|
const r = l.Psbt.fromHex(e), a = [];
|
|
463
463
|
for (let w = 0; w < r.inputCount; w++)
|
|
464
464
|
i && i.includes(w) || s.includes(w) || a.push(w);
|
|
465
|
-
const c = await
|
|
465
|
+
const c = await X(
|
|
466
466
|
x(e),
|
|
467
467
|
!1,
|
|
468
468
|
[
|
|
@@ -491,10 +491,10 @@ const ie = {
|
|
|
491
491
|
signMessage: ee,
|
|
492
492
|
signMessageDeterministic: ne,
|
|
493
493
|
sendBTC: te,
|
|
494
|
-
signPSBT:
|
|
494
|
+
signPSBT: X,
|
|
495
495
|
sign: se
|
|
496
496
|
};
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
497
|
+
T("leather", A);
|
|
498
|
+
T("okx", _);
|
|
499
|
+
T("unisat", Y);
|
|
500
|
+
T("xverse", ie);
|
|
@@ -1,6 +1,48 @@
|
|
|
1
|
+
import { Brc20SendQuote, SendAsBrc20Args, SendAsBrc20ProgArgs, SendAsBrc20ProgResult, SendAsBrc20Result } from '../core/brc20-send';
|
|
1
2
|
import { BISWalletPurpose, PaymentOpts } from '../types/common';
|
|
2
3
|
export type { Brc20AmountOptions, Brc20DeployOptions, Brc20PredeployOptions, Brc20PredeployResult, } from '../core/brc20-inscriptions';
|
|
3
4
|
export { computeBrc20PredeployHash, deployBrc20Inscription, generateBrc20Salt, mintBrc20Inscription, predeployInscriptions, transferBrc20Inscription, } from '../core/brc20-inscriptions';
|
|
5
|
+
export type { Brc20SendPart, Brc20SendQuote, Brc20SendStepName, Brc20SendStepQuote, SendAsBrc20Args, SendAsBrc20ProgArgs, SendAsBrc20ProgResult, SendAsBrc20Result, } from '../core/brc20-send';
|
|
6
|
+
/**
|
|
7
|
+
* Sends a ticker so the recipient receives plain BRC-20. `fromBrc20Amount` is sent as a BRC-20
|
|
8
|
+
* transfer inscription and `fromProgAmount` as a BRC2.0 withdraw inscription, both to `recipient`.
|
|
9
|
+
* Every transaction is signed as one chain (each step spends the previous step's output) and the chain
|
|
10
|
+
* is broadcast at the end, so the parts never compete for a UTXO.
|
|
11
|
+
*
|
|
12
|
+
* With `dryRun: true` nothing is signed or broadcast and the result is a fee quote: total sats,
|
|
13
|
+
* wallet prompts, and a per-step breakdown. `onSignRequest` is called before each wallet prompt with
|
|
14
|
+
* `{ step, total }`; `total` is 2 per part.
|
|
15
|
+
*
|
|
16
|
+
* @param args - `tick`, `fromBrc20Amount` and `fromProgAmount` (decimal strings, either may be `"0"`), `recipient`, `feeRate` (sats/vB), `dryRun`, and optional `onSignRequest`.
|
|
17
|
+
* @returns The quote for a dry run; otherwise the transaction ids of each part plus every txid in chain order.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sendAsBrc20(args: SendAsBrc20Args & {
|
|
20
|
+
dryRun: true;
|
|
21
|
+
}): Promise<Brc20SendQuote>;
|
|
22
|
+
export declare function sendAsBrc20(args: SendAsBrc20Args & {
|
|
23
|
+
dryRun: false;
|
|
24
|
+
}): Promise<SendAsBrc20Result>;
|
|
25
|
+
export declare function sendAsBrc20(args: SendAsBrc20Args): Promise<Brc20SendQuote | SendAsBrc20Result>;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a ticker so the recipient receives BRC2.0. When `topUpFromBrc20` is above 0, that much base
|
|
28
|
+
* BRC-20 is first deposited into the sender's own BRC2.0 balance; then an ERC-20
|
|
29
|
+
* `transfer(recipientEvm, amount)` call on `contractAddress` moves `amount` to the EVM address of
|
|
30
|
+
* `recipient`. Both are inscribed from the ordinals identity, which owns the BRC2.0 balance, and the
|
|
31
|
+
* call spends the deposit's output so the deposit is indexed first.
|
|
32
|
+
*
|
|
33
|
+
* With `dryRun: true` nothing is signed or broadcast and the result is a fee quote. `onSignRequest` is
|
|
34
|
+
* called before each wallet prompt with `{ step, total }`; `total` is 2, or 4 with a top-up.
|
|
35
|
+
*
|
|
36
|
+
* @param args - `tick`, `contractAddress`, `topUpFromBrc20` (decimal string, may be `"0"`), `amount` (bigint, 18 decimals, as in `swap.deposit`), `recipient`, `feeRate` (sats/vB), `dryRun`, and optional `onSignRequest`.
|
|
37
|
+
* @returns The quote for a dry run; otherwise the transaction ids of each part plus every txid in chain order.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs & {
|
|
40
|
+
dryRun: true;
|
|
41
|
+
}): Promise<Brc20SendQuote>;
|
|
42
|
+
export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs & {
|
|
43
|
+
dryRun: false;
|
|
44
|
+
}): Promise<SendAsBrc20ProgResult>;
|
|
45
|
+
export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs): Promise<Brc20SendQuote | SendAsBrc20ProgResult>;
|
|
4
46
|
/**
|
|
5
47
|
* Interface representing the result of an inscription and send to OP_RETURN operation, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. This interface is used to encapsulate the details of the deploy, call and deposit operations in the BRC2.0 programmable module.
|
|
6
48
|
*
|
package/dist/types/api/swap.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WalletActivityKind } from '../core/bis_swap';
|
|
1
|
+
import { GetRecentActivityRequest, WalletActivityKind } from '../core/bis_swap';
|
|
2
2
|
import { SignProgressOptions } from '../core/sign-progress';
|
|
3
3
|
export { generateAndStoreSwapWallet as createSwapWallet, ensureSwapWallet, getAddLiquidityResult, getKlines, requestMinerFee as getMinerFee, getMinerFeesOfDepositOrder, getMinerFeesOfWrapOrder, getPairReserves, getPairVolumeOverDays, getRemoveLiquidityResult, getSwapBalance, getSwapBalances, getSwapResult as getSwapExactInputResult, getSwap2Result as getSwapExactOutputResult, getSwapInfo, getSwapStatus, getSwapWalletSecurityCode, getTokenDecimals, getTvlHistory, getUnwrapResult as getUnwrapBtcResult, importSwapWallet, listPairs, listTokens, tryGetSwapReferrerInfo, } from '../core/bis_swap';
|
|
4
|
-
export type { EnsureSwapWalletResult, GetActivityOfPairResponse, GetKlinesRequest, GetKlinesResponse, GetPairVolumeRequest, GetPairVolumeResponse, GetSwapStatusResponse, GetTvlHistoryRequest, GetTvlHistoryResponse, GetWalletActivitiesResponse, ImportSwapWalletOptions, Kline, ListPairsOrderBy, ListPairsRequest, ListPairsResponse, PairActivityEntry, PairInfo, PairReserves, SwapBalance, SwapInfo, TokenInfo, TvlPoint, WalletActivityEntry, WalletActivityKind, } from '../core/bis_swap';
|
|
4
|
+
export type { EnsureSwapWalletResult, GetActivityOfPairResponse, GetKlinesRequest, GetKlinesResponse, GetPairVolumeRequest, GetPairVolumeResponse, GetRecentActivityRequest, GetRecentActivityResponse, GetSwapStatusResponse, GetTvlHistoryRequest, GetTvlHistoryResponse, GetWalletActivitiesResponse, ImportSwapWalletOptions, Kline, ListPairsOrderBy, ListPairsRequest, ListPairsResponse, PairActivityEntry, PairInfo, PairReserves, RecentActivityEntry, RecentActivityKind, RecentActivityToken, SwapBalance, SwapInfo, TokenInfo, TvlPoint, WalletActivityEntry, WalletActivityKind, } from '../core/bis_swap';
|
|
5
5
|
export type { AllBalanceDetails } from '../core/helpers';
|
|
6
6
|
export type { SignProgressOptions, SignRequest } from '../core/sign-progress';
|
|
7
7
|
export type { BISSwapWalletInfo } from '../core/store';
|
|
@@ -36,6 +36,18 @@ export declare function getWalletActivities(pubkey: string, pairAddress?: string
|
|
|
36
36
|
* @param offset - (Optional) The number of activities to skip before starting to collect the result set. Defaults to 0.
|
|
37
37
|
*/
|
|
38
38
|
export declare function getActivityOfPair(pairAddress: string, limit?: number, offset?: number): Promise<import('./swap').GetActivityOfPairResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the newest operations across every pair, newest first.
|
|
41
|
+
*
|
|
42
|
+
* Page back by passing the last row's `id` as `before`; `has_more` on the response says whether
|
|
43
|
+
* older operations exist. Backends that predate the parameters ignore them and return the newest
|
|
44
|
+
* 15 operations without `has_more`.
|
|
45
|
+
*
|
|
46
|
+
* @param opts - (Optional) `limit` (an integer from 1 to 100; the backend defaults to 15), `before` (an op-id cursor) and `kinds` (`swap`, `add_liq`, `remove_liq`, `withdraw`, `unwrap`; every kind when omitted).
|
|
47
|
+
* @returns A promise that resolves to the page of activities.
|
|
48
|
+
* @throws If `limit` is out of range, `before` is not a positive integer id, or `kinds` is empty or names an unknown kind, before any request is sent.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getRecentActivity(opts?: GetRecentActivityRequest): Promise<import('./swap').GetRecentActivityResponse>;
|
|
39
51
|
/**
|
|
40
52
|
* Adds liquidity to a specified token pair with the desired amounts and slippage tolerance.
|
|
41
53
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WalletInfo } from '../types/wallet';
|
|
2
|
-
export { getAllBalanceDetails, getCardinalBalance, getOrdinalsWallet, getPaymentWallet, getSession, sendBTC, sendInscription, setNetwork, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from '../core/bis';
|
|
3
|
-
export type { AccountChangeEvent } from '../core/bis';
|
|
2
|
+
export { getAllBalanceDetails, getCardinalBalance, getEndpoints, getOrdinalsWallet, getPaymentWallet, getSession, sendBTC, sendInscription, setEndpoints, setNetwork, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from '../core/bis';
|
|
3
|
+
export type { AccountChangeEvent, Endpoints, EndpointsConfig } from '../core/bis';
|
|
4
4
|
export type { WalletInfo };
|
|
5
5
|
export { getNetwork } from '../core/store-network';
|
|
6
6
|
export type { BISNetwork, BISSession, BISWallet, BISWalletProvider, BISWalletPurpose, } from '../types/common';
|
package/dist/types/core/bis.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export { getAllBalanceDetails, getCardinalBalance } from './helpers';
|
|
|
5
5
|
export { getOrdinalsWallet, getPaymentWallet, sendBTC, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from './providers';
|
|
6
6
|
export type { AccountChangeEvent } from './providers';
|
|
7
7
|
export { getWalletInfo as getSession } from './store';
|
|
8
|
-
export { getNetwork, setNetwork } from './store-network';
|
|
8
|
+
export { getEndpoints, getNetwork, setEndpoints, setNetwork } from './store-network';
|
|
9
|
+
export type { Endpoints, EndpointsConfig } from './store-network';
|
|
9
10
|
/**
|
|
10
11
|
* Sends an inscription to a target wallet with the specified postage, fee rate, and dry run option. The function determines the appropriate method for sending the inscription based on the target wallet's properties and the specified wallet type. It uses the provided signing function to sign the necessary transactions for sending the inscription.
|
|
11
12
|
*
|
|
@@ -371,6 +371,55 @@ export interface GetActivityOfPairResponse {
|
|
|
371
371
|
* @returns {Promise<GetActivityOfPairResponse>} A promise that resolves to an object containing the pair address, token details, and an array of recent activities for that pair. Each activity includes details such as the type of activity (add/remove liquidity or swap), timestamp, block height, success status, user address and pubkey, amounts involved, and token addresses.
|
|
372
372
|
*/
|
|
373
373
|
export declare function getActivityOfPair(params: GetActivityOfPairRequest): Promise<GetActivityOfPairResponse>;
|
|
374
|
+
/** A kind of operation `getRecentActivity` can filter on; `swap` covers swap1 and swap2. */
|
|
375
|
+
export type RecentActivityKind = 'swap' | 'add_liq' | 'remove_liq' | 'withdraw' | 'unwrap';
|
|
376
|
+
export interface GetRecentActivityRequest {
|
|
377
|
+
/** Page size, 1-100. The backend defaults to 15. */
|
|
378
|
+
limit?: number;
|
|
379
|
+
/** Op-id cursor: only operations with a lower id. Pass the last row's `id` to page back. */
|
|
380
|
+
before?: string;
|
|
381
|
+
/** Kinds to keep. When omitted, every kind is returned. */
|
|
382
|
+
kinds?: readonly RecentActivityKind[];
|
|
383
|
+
}
|
|
384
|
+
export interface RecentActivityToken {
|
|
385
|
+
address: string;
|
|
386
|
+
symbol: string;
|
|
387
|
+
decimals: number;
|
|
388
|
+
}
|
|
389
|
+
export interface RecentActivityEntry {
|
|
390
|
+
id: string;
|
|
391
|
+
op_type: number;
|
|
392
|
+
type: 'add_liq' | 'remove_liq' | 'swap1' | 'swap2' | 'withdraw' | 'unwrap';
|
|
393
|
+
/** Milliseconds since the epoch, when the operation was placed. */
|
|
394
|
+
timestamp: number;
|
|
395
|
+
block_height: number | null;
|
|
396
|
+
executed: boolean;
|
|
397
|
+
success: boolean;
|
|
398
|
+
user_address: string | null;
|
|
399
|
+
user_pubkey: string | null;
|
|
400
|
+
/** A swap's input token, a liquidity change's first token, or a withdraw/unwrap's token. */
|
|
401
|
+
token_1: RecentActivityToken | null;
|
|
402
|
+
/** A swap's output token or a liquidity change's second token; null for withdraw/unwrap. */
|
|
403
|
+
token_2: RecentActivityToken | null;
|
|
404
|
+
amount1: string | null;
|
|
405
|
+
amount2: string | null;
|
|
406
|
+
liquidity?: string | null;
|
|
407
|
+
target_address?: string;
|
|
408
|
+
target_pkscript?: string;
|
|
409
|
+
}
|
|
410
|
+
export interface GetRecentActivityResponse {
|
|
411
|
+
/** Newest first, across every pair. */
|
|
412
|
+
activities: RecentActivityEntry[];
|
|
413
|
+
/** Whether older activity exists past this page. Absent on older backends. */
|
|
414
|
+
has_more?: boolean;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Fetches the newest operations across every pair, newest first by op id.
|
|
418
|
+
*
|
|
419
|
+
* @param params Optional page size (1-100), op-id cursor and kinds filter.
|
|
420
|
+
* @returns {Promise<GetRecentActivityResponse>} The page of activities and whether older ones exist.
|
|
421
|
+
*/
|
|
422
|
+
export declare function getRecentActivity(params?: GetRecentActivityRequest): Promise<GetRecentActivityResponse>;
|
|
374
423
|
/** A kind of wallet activity that `getWalletActivities` can filter on. */
|
|
375
424
|
export type WalletActivityKind = 'swap' | 'add_liq' | 'remove_liq' | 'deposit' | 'withdraw' | 'unwrap';
|
|
376
425
|
interface GetWalletActivitiesRequest {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { SignProgressOptions } from './sign-progress';
|
|
2
|
+
/** The transactions of one inscribe-and-send step. */
|
|
3
|
+
export interface Brc20SendPart {
|
|
4
|
+
commitTxId: string;
|
|
5
|
+
revealTxId: string;
|
|
6
|
+
/** The transaction that moves the inscription to its target (recipient or OP_RETURN). */
|
|
7
|
+
sendTxId: string;
|
|
8
|
+
inscriptionId: string;
|
|
9
|
+
}
|
|
10
|
+
/** Fee breakdown of one inscribe-and-send step. */
|
|
11
|
+
export interface Brc20SendStepQuote {
|
|
12
|
+
step: Brc20SendStepName;
|
|
13
|
+
/** Miner fees of the commit, reveal and send transactions. */
|
|
14
|
+
minerFeeSats: number;
|
|
15
|
+
/** Sats the send leaves on its target output (the recipient's postage, or 1 sat on OP_RETURN). */
|
|
16
|
+
postageSats: number;
|
|
17
|
+
/** Wallet prompts this step raises. */
|
|
18
|
+
walletPrompts: number;
|
|
19
|
+
}
|
|
20
|
+
/** What a composite send costs, built without signing or broadcasting. */
|
|
21
|
+
export interface Brc20SendQuote {
|
|
22
|
+
/** Sats the wallet spends in all: miner fees plus postage. */
|
|
23
|
+
totalSats: number;
|
|
24
|
+
minerFeeSats: number;
|
|
25
|
+
postageSats: number;
|
|
26
|
+
/** Wallet prompts the real send raises; `onSignRequest` reports each of them. */
|
|
27
|
+
walletPrompts: number;
|
|
28
|
+
feeRate: number;
|
|
29
|
+
steps: Brc20SendStepQuote[];
|
|
30
|
+
}
|
|
31
|
+
export type Brc20SendStepName = 'brc20Transfer' | 'progWithdraw' | 'progDeposit' | 'progTransfer';
|
|
32
|
+
/**
|
|
33
|
+
* Parses a BRC-20 decimal amount string into an 18-decimal bigint.
|
|
34
|
+
*
|
|
35
|
+
* @param value - A non-negative decimal string with at most 18 fractional digits, such as `"0"` or `"12.5"`.
|
|
36
|
+
* @param label - The argument name used in error messages.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseBrc20Amount(value: string, label: string): bigint;
|
|
39
|
+
export interface SendAsBrc20Args extends SignProgressOptions {
|
|
40
|
+
tick: string;
|
|
41
|
+
/** Amount taken from the sender's base BRC-20 balance, as a decimal string; `"0"` skips it. */
|
|
42
|
+
fromBrc20Amount: string;
|
|
43
|
+
/** Amount taken from the sender's BRC2.0 balance, as a decimal string; `"0"` skips it. */
|
|
44
|
+
fromProgAmount: string;
|
|
45
|
+
/** Bitcoin address that receives plain BRC-20. */
|
|
46
|
+
recipient: string;
|
|
47
|
+
feeRate: number;
|
|
48
|
+
dryRun: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface SendAsBrc20Result {
|
|
51
|
+
/** The BRC-20 transfer inscription sent to the recipient, or null when `fromBrc20Amount` is 0. */
|
|
52
|
+
brc20Transfer: Brc20SendPart | null;
|
|
53
|
+
/** The BRC2.0 withdraw inscription sent to the recipient, or null when `fromProgAmount` is 0. */
|
|
54
|
+
progWithdraw: Brc20SendPart | null;
|
|
55
|
+
/** Every broadcast transaction id, in chain order. */
|
|
56
|
+
txIds: string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sends a ticker so the recipient receives plain BRC-20, drawing on the sender's base BRC-20 balance
|
|
60
|
+
* first and its BRC2.0 balance second. The base part is a BRC-20 transfer inscription sent to the
|
|
61
|
+
* recipient; the BRC2.0 part is a `brc20-module` withdraw inscription sent to the recipient. Both
|
|
62
|
+
* parts are signed as one chain and broadcast together.
|
|
63
|
+
*/
|
|
64
|
+
export declare function sendAsBrc20(args: SendAsBrc20Args): Promise<Brc20SendQuote | SendAsBrc20Result>;
|
|
65
|
+
export interface SendAsBrc20ProgArgs extends SignProgressOptions {
|
|
66
|
+
tick: string;
|
|
67
|
+
/** The token's BRC2.0 (ERC-20) contract address. */
|
|
68
|
+
contractAddress: string;
|
|
69
|
+
/**
|
|
70
|
+
* Amount deposited from the sender's base BRC-20 balance into its own BRC2.0 balance before the
|
|
71
|
+
* transfer, as a decimal string; `"0"` skips the deposit.
|
|
72
|
+
*/
|
|
73
|
+
topUpFromBrc20: string;
|
|
74
|
+
/** Total amount the recipient receives, in 18 decimals (the BRC2.0 token unit, as in `swap.deposit`). */
|
|
75
|
+
amount: bigint;
|
|
76
|
+
/** Bitcoin address whose BRC2.0 (EVM) address receives the tokens. */
|
|
77
|
+
recipient: string;
|
|
78
|
+
feeRate: number;
|
|
79
|
+
dryRun: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface SendAsBrc20ProgResult {
|
|
82
|
+
/** The deposit into the sender's BRC2.0 balance, or null when `topUpFromBrc20` is 0. */
|
|
83
|
+
progDeposit: Brc20SendPart | null;
|
|
84
|
+
/** The ERC-20 `transfer` call to the recipient. */
|
|
85
|
+
progTransfer: Brc20SendPart;
|
|
86
|
+
/** Every broadcast transaction id, in chain order. */
|
|
87
|
+
txIds: string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Sends a ticker so the recipient receives BRC2.0. When `topUpFromBrc20` is above 0, a deposit first
|
|
91
|
+
* moves that much of the sender's base BRC-20 into its own BRC2.0 balance; then an ERC-20
|
|
92
|
+
* `transfer(recipientEvm, amount)` call moves `amount` to the recipient's EVM address. Both are
|
|
93
|
+
* inscribed from the ordinals identity, which owns the BRC2.0 balance, and the call's commit spends
|
|
94
|
+
* the deposit's output so the deposit is indexed first.
|
|
95
|
+
*/
|
|
96
|
+
export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs): Promise<Brc20SendQuote | SendAsBrc20ProgResult>;
|
|
@@ -1,7 +1,41 @@
|
|
|
1
|
+
import { Endpoints } from './store-network';
|
|
1
2
|
import * as bitcoinjs from 'bitcoinjs-lib';
|
|
2
3
|
export declare const txHexByIdCache: {
|
|
3
4
|
[txid: string]: any;
|
|
4
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns the base URL configured for an endpoint on the selected network.
|
|
8
|
+
*
|
|
9
|
+
* @param key The endpoint to resolve.
|
|
10
|
+
* @returns The base URL, without a trailing slash.
|
|
11
|
+
* @throws {Error} If the selected network has no such endpoint configured.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEndpointBase(key: keyof Endpoints): string;
|
|
14
|
+
/**
|
|
15
|
+
* Picks the sequencer endpoint for a route: `sequencerRead` for display reads,
|
|
16
|
+
* `sequencer` for writes and pre-sign reads.
|
|
17
|
+
*
|
|
18
|
+
* @param path The route path, optionally with a sub-path and query string.
|
|
19
|
+
* @returns The endpoint key that serves the route.
|
|
20
|
+
*/
|
|
21
|
+
export declare function sequencerEndpointFor(path: string): 'sequencerRead' | 'sequencer';
|
|
22
|
+
/**
|
|
23
|
+
* Builds the full URL for a route on a configured endpoint, after checking that
|
|
24
|
+
* a `/v1` service serves the selected network.
|
|
25
|
+
*
|
|
26
|
+
* @param key The endpoint that serves the route.
|
|
27
|
+
* @param path The route path, with any query string, relative to the endpoint base.
|
|
28
|
+
* @returns The full URL.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getEndpointUrl(key: keyof Endpoints, path: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Builds the full URL for a swap sequencer route, routed to `sequencerRead` or
|
|
33
|
+
* `sequencer` by {@link sequencerEndpointFor}.
|
|
34
|
+
*
|
|
35
|
+
* @param path The route path, with any query string.
|
|
36
|
+
* @returns The full URL.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getSwapBackendUrl(path: string): Promise<string>;
|
|
5
39
|
/**
|
|
6
40
|
* Creates an unsecured JWT token with the given payload.
|
|
7
41
|
*
|
|
@@ -185,13 +219,6 @@ export declare function verifySignature(message: string, signatureHex: string, a
|
|
|
185
219
|
* @throws An error if the verification process fails, such as due to invalid input parameters.
|
|
186
220
|
*/
|
|
187
221
|
export declare function verifySignatureLocal(message: string, signatureHex: string, address: string): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Fetches the current chain tip (the latest block height) from the backend API. The function sends a request to the backend to retrieve the current chain tip and returns it as a number. If the request fails, it throws an error indicating that the chain tip could not be retrieved.
|
|
190
|
-
*
|
|
191
|
-
* @returns A promise that resolves to the current chain tip (latest block height) as a number, or throws an error if the request fails.
|
|
192
|
-
* @throws An error if the request to fetch the chain tip fails, indicating that the chain tip could not be retrieved.
|
|
193
|
-
*/
|
|
194
|
-
export declare function getChainTip(): Promise<number>;
|
|
195
222
|
/**
|
|
196
223
|
* A generic helper function to handle fetch requests with consistent error handling.
|
|
197
224
|
* It automatically checks for non-ok HTTP responses and for an 'error' field
|
|
@@ -205,13 +232,14 @@ export declare function getChainTip(): Promise<number>;
|
|
|
205
232
|
*/
|
|
206
233
|
export declare function fetchWithErrors<T>(url: string, options: RequestInit): Promise<T>;
|
|
207
234
|
/**
|
|
208
|
-
* Retrieves the
|
|
235
|
+
* Retrieves the BRC2.0 JSON-RPC URL configured as the `rpc` endpoint for the selected network.
|
|
209
236
|
*
|
|
210
|
-
* @returns The
|
|
237
|
+
* @returns The RPC URL.
|
|
238
|
+
* @throws {Error} If the selected network has no RPC endpoint configured.
|
|
211
239
|
*/
|
|
212
|
-
export declare function getPublicRpcUrl(): string
|
|
240
|
+
export declare function getPublicRpcUrl(): Promise<string>;
|
|
213
241
|
/**
|
|
214
|
-
* Executes an eth_call on the
|
|
242
|
+
* Executes an eth_call on the BRC2.0 RPC configured for the selected network. The function constructs the JSON-RPC request payload with the provided data and sends it to the RPC URL for execution. It returns a promise that resolves to the result of the eth_call, or throws an error if the request fails.
|
|
215
243
|
*
|
|
216
244
|
* @param to The address of the contract to call.
|
|
217
245
|
* @param abi The ABI of the contract to call.
|
|
@@ -220,10 +248,3 @@ export declare function getPublicRpcUrl(): string;
|
|
|
220
248
|
* @returns A promise that resolves to the result of the eth_call as a string, or throws an error if the request fails.
|
|
221
249
|
*/
|
|
222
250
|
export declare function ethCallOnPublicRpc(to: string, abi: any, functionName: string, params: any): Promise<string>;
|
|
223
|
-
/**
|
|
224
|
-
* Constructs the appropriate backend URL for a given API path based on the current network (signet or mainnet). The function checks the current network using the getNetwork function and returns the corresponding URL for the swap backend API. If the network is not supported, it throws an error indicating that the network is unsupported for the orderbook backend URL.
|
|
225
|
-
*
|
|
226
|
-
* @param path The specific API path to append to the base URL for the swap backend.
|
|
227
|
-
* @returns The full URL for the swap backend API corresponding to the current network and the provided path.
|
|
228
|
-
*/
|
|
229
|
-
export declare function getSwapBackendUrl(path: string): string;
|
|
@@ -5,6 +5,7 @@ import { InscribeFees, InscribeMultipleResult, InscribeResult, SendInscriptionRe
|
|
|
5
5
|
import { Buffer } from 'node:buffer';
|
|
6
6
|
import { WalletInfo } from '../types/wallet';
|
|
7
7
|
import * as bitcoinjs from 'bitcoinjs-lib';
|
|
8
|
+
export declare function getDustValue(wallet: WalletInfo): number;
|
|
8
9
|
interface TapLeafScriptInfo {
|
|
9
10
|
script: Buffer;
|
|
10
11
|
controlBlock: Buffer;
|
|
@@ -18,3 +18,45 @@ export declare function setNetwork(newNetwork: BISNetwork): void;
|
|
|
18
18
|
* @returns An unsubscribe function that removes the listener.
|
|
19
19
|
*/
|
|
20
20
|
export declare function subscribeToNetwork(listener: (network: BISNetwork) => void): () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Base URLs of the backend services the kit talks to on one network. Each is
|
|
23
|
+
* joined with a route path (`<base>/<route>`), so a trailing slash is optional.
|
|
24
|
+
*/
|
|
25
|
+
export interface Endpoints {
|
|
26
|
+
/** Indexer reads: UTXOs, balances, raw transactions, BIP-322 verification. */
|
|
27
|
+
indexer: string;
|
|
28
|
+
/** Bitcoin transaction submission: `testmempoolaccept` and `sendrawtransactions`. */
|
|
29
|
+
tx: string;
|
|
30
|
+
/** Swap sequencer display reads: tokens, pairs table, volume, klines, TVL, activity feeds, token decimals. */
|
|
31
|
+
sequencerRead: string;
|
|
32
|
+
/** Swap sequencer writes and the fresh reads taken right before signing (status, fees, nonce, balances, reserves, deposit, swap, withdraw, ...). */
|
|
33
|
+
sequencer: string;
|
|
34
|
+
/** BRC2.0 JSON-RPC endpoint used for `eth_call`. */
|
|
35
|
+
rpc: string;
|
|
36
|
+
}
|
|
37
|
+
/** Per-network endpoint overrides accepted by {@link setEndpoints}. */
|
|
38
|
+
export type EndpointsConfig = {
|
|
39
|
+
[N in BISNetwork]?: Partial<Endpoints>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Overrides the backend base URLs per network. Each network's entry is merged
|
|
43
|
+
* over the built-in defaults, so only the keys you pass change. Every call
|
|
44
|
+
* replaces the previous overrides; `setEndpoints({})` restores the defaults.
|
|
45
|
+
*
|
|
46
|
+
* A base URL whose path starts with `/v1` is checked against its server's
|
|
47
|
+
* `/v1/info` before the first request to that origin, and requests fail if the
|
|
48
|
+
* server reports a different network than the one selected.
|
|
49
|
+
*
|
|
50
|
+
* @param config Per-network partial endpoint maps, e.g. `{ signet: { rpc: 'https://my-rpc.example' } }`.
|
|
51
|
+
* @throws {Error} If a key is unknown or a value is not an absolute http(s) URL.
|
|
52
|
+
*/
|
|
53
|
+
export declare function setEndpoints(config: EndpointsConfig): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the effective base URLs for a network: the defaults with any
|
|
56
|
+
* {@link setEndpoints} overrides applied. Testnet has no `sequencerRead`,
|
|
57
|
+
* `sequencer` or `rpc` unless configured.
|
|
58
|
+
*
|
|
59
|
+
* @param network The network to read. Defaults to the selected network.
|
|
60
|
+
* @returns The endpoint map for that network.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getEndpoints(network?: BISNetwork): Partial<Endpoints>;
|
package/dist/types/core.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export * as brc20 from './api/brc20';
|
|
|
4
4
|
export * as mint from './api/mint';
|
|
5
5
|
export * as balances from './api/balances';
|
|
6
6
|
export * from './api/helpers';
|
|
7
|
-
export { getNetwork, setNetwork, subscribeToNetwork } from './core/store-network';
|
|
7
|
+
export { getEndpoints, getNetwork, setEndpoints, setNetwork, subscribeToNetwork, } from './core/store-network';
|
|
8
|
+
export type { Endpoints, EndpointsConfig } from './core/store-network';
|
|
8
9
|
export type { PaymentOpts } from './types/common';
|
|
9
10
|
export * as bitcoinjs from 'bitcoinjs-lib';
|
|
10
11
|
export * as Buff from '@cmdcode/buff-utils';
|
package/dist/vue.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ref as s, onScopeDispose as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import { ref as s, onScopeDispose as u, watch as i } from "vue";
|
|
2
|
+
import { e as r, T as c, k as a } from "./mint-CHlWPuov.js";
|
|
3
|
+
function n() {
|
|
4
|
+
const o = s(r()), t = c((e) => {
|
|
5
|
+
o.value !== e && (o.value = e);
|
|
6
6
|
});
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
}),
|
|
7
|
+
return u(t, !0), i(o, (e) => {
|
|
8
|
+
e !== r() && a(e);
|
|
9
|
+
}), o;
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
n as useNetwork
|
|
13
13
|
};
|
package/package.json
CHANGED