@bestinslot/wallet-kit 0.14.2 → 0.14.4

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.
@@ -1,3 +1,4 @@
1
+ import { MempoolAcceptResult, OrdinalUtxo, Utxo } from './chain-providers';
1
2
  import { Endpoints } from './store-network';
2
3
  import * as bitcoinjs from 'bitcoinjs-lib';
3
4
  export declare const txHexByIdCache: {
@@ -25,9 +26,10 @@ export declare function sequencerEndpointFor(path: string): 'sequencerRead' | 's
25
26
  *
26
27
  * @param key The endpoint that serves the route.
27
28
  * @param path The route path, with any query string, relative to the endpoint base.
29
+ * @param base A base URL to use in place of the configured `key` endpoint.
28
30
  * @returns The full URL.
29
31
  */
30
- export declare function getEndpointUrl(key: keyof Endpoints, path: string): Promise<string>;
32
+ export declare function getEndpointUrl(key: keyof Endpoints, path: string, base?: string): Promise<string>;
31
33
  /**
32
34
  * Builds the full URL for a swap sequencer route, routed to `sequencerRead` or
33
35
  * `sequencer` by {@link sequencerEndpointFor}.
@@ -84,6 +86,18 @@ export declare function clearExtraUtxos(): void;
84
86
  * @returns A string representing the type of the UTXO output, such as 'pubkeyhash', 'scripthash', 'witness_v0_keyhash', 'witness_v0_scripthash', 'witness_v1_taproot', 'pubkey', 'anchor', 'witness_unknown', 'nulldata', 'multisig', or 'nonstandard'.
85
87
  */
86
88
  export declare function utxoOutputTypeFromOutputScript(output: any, network: any): 'pubkeyhash' | 'scripthash' | 'witness_v0_keyhash' | 'witness_v0_scripthash' | 'witness_v1_taproot' | 'pubkey' | 'anchor' | 'witness_unknown' | 'nulldata' | 'multisig' | 'nonstandard';
89
+ /** The output types wallet-kit can spend, named as in Bitcoin Core's `scriptPubKey.type`. */
90
+ export type UtxoScriptType = APIUtxoInfo['script_type'];
91
+ /** A cardinal UTXO with the outpoint string and script type wallet-kit's transaction builders read. */
92
+ export type CardinalUtxoInfo = Utxo & {
93
+ utxo: string;
94
+ script_type: UtxoScriptType;
95
+ };
96
+ /** An ordinal UTXO with the outpoint string and script type wallet-kit's transaction builders read. */
97
+ export type OrdinalUtxoInfo = OrdinalUtxo & {
98
+ utxo: string;
99
+ script_type: UtxoScriptType;
100
+ };
87
101
  /**
88
102
  * Returns the ordinal UTXOs that the saved extra transactions create for `addr`: the
89
103
  * output carrying the saved extra inscription, unless another extra transaction spends it.
@@ -92,13 +106,14 @@ export declare function utxoOutputTypeFromOutputScript(output: any, network: any
92
106
  * @param addr The address the inscription output must pay to.
93
107
  * @returns The extra ordinal UTXOs for `addr`, empty when no extras are saved.
94
108
  */
95
- export declare function getExtraOrdinalUtxos(addr: string): APIOrdinalUtxoInfo[];
109
+ export declare function getExtraOrdinalUtxos(addr: string): OrdinalUtxoInfo[];
96
110
  /**
97
111
  * Converts a witness stack to a script witness format that can be used in Bitcoin transactions.
98
112
  * @param witness An array representing the witness stack, where each element is a buffer or a string that can be converted to a buffer.
99
113
  * @returns A buffer containing the script witness data that can be included in a Bitcoin transaction input.
100
114
  */
101
115
  export declare function witnessStackToScriptWitness(witness: any[]): any;
116
+ /** A cardinal UTXO as the Best in Slot API's `cardinal_utxos` route serves it. */
102
117
  export interface APIUtxoInfo {
103
118
  address: string;
104
119
  amounts: number[] | null;
@@ -116,24 +131,22 @@ export interface APIUtxoInfo {
116
131
  vsize: number | null;
117
132
  }
118
133
  /**
119
- * Fetches the UTXOs associated with a given address from the backend API and applies fixes to include any extra UTXOs that are currently in the process of being used in transactions but not yet confirmed on the blockchain.
134
+ * Lists the cardinal UTXOs of an address from the chain provider (see `setProviders`), with the saved extra transactions applied: outputs they spend are dropped and outputs they create for the address are added.
120
135
  *
121
136
  * @param addr The address for which to fetch the UTXOs.
122
137
  * @param fetchedUtxos A response from `fetchCardinalUtxos(addr)` to use in place of a new fetch. Each call works on its own copy, since coin selection sorts and splices the list it is given.
123
138
  * @returns A promise that resolves to an array of UTXO information objects.
124
139
  */
125
- export declare function getCardinalUtxos(addr: string, fetchedUtxos?: APIUtxoInfo[]): Promise<APIUtxoInfo[]>;
140
+ export declare function getCardinalUtxos(addr: string, fetchedUtxos?: Utxo[]): Promise<CardinalUtxoInfo[]>;
126
141
  /**
127
- * Fetches the backend's cardinal UTXO list for an address as served, without the saved extra UTXOs applied. A dry run that prices several transactions fetches this once and passes it to each `getCardinalUtxos` call.
142
+ * Fetches the chain provider's cardinal UTXO list for an address as served, without the saved extra UTXOs applied. A dry run that prices several transactions fetches this once and passes it to each `getCardinalUtxos` call.
128
143
  *
129
144
  * @param addr The address for which to fetch the UTXOs.
130
- * @returns A promise that resolves to the backend's array of UTXO information objects.
145
+ * @returns A promise that resolves to the provider's array of UTXOs.
131
146
  */
132
- export declare function fetchCardinalUtxos(addr: string): Promise<APIUtxoInfo[]>;
147
+ export declare function fetchCardinalUtxos(addr: string): Promise<Utxo[]>;
133
148
  /**
134
- * This function gets the balance of a given address by fetching its UTXOs from the backend and summing
135
- * their values. It also applies fixes to include any extra UTXOs that are currently in the process of
136
- * being used in transactions but not yet confirmed on the blockchain.
149
+ * Sums the values of an address's cardinal UTXOs, with the saved extra transactions applied as in `getCardinalUtxos`.
137
150
  *
138
151
  * @param address The address for which to fetch the balance.
139
152
  * @returns The total balance of the address in satoshis.
@@ -144,15 +157,13 @@ export interface AllBalanceDetails {
144
157
  mempool_balance: number;
145
158
  }
146
159
  /**
147
- * Fetches the balance details of a given address from the backend API, including both confirmed and mempool balances. It also applies fixes to include any extra UTXOs that are currently in the process of being used in transactions but not yet confirmed on the blockchain.
160
+ * Reads the confirmed and mempool balances of an address from the chain provider (see `setProviders`).
148
161
  *
149
162
  * @param addr The address for which to fetch the balance details.
150
163
  * @returns A promise that resolves to an object containing the confirmed balance and mempool balance of the address in satoshis.
151
164
  */
152
165
  export declare function getAllBalanceDetails(addr: string): Promise<AllBalanceDetails>;
153
- /**
154
- * Represents the structure of UTXO information returned by the backend API for ordinal UTXOs. It includes details such as the address, amounts, block height, inscription IDs, rune IDs, satpoints, script, script type, transaction fee, transaction ID, UTXO identifier, value, vout index, and virtual size of the UTXO.
155
- */
166
+ /** An ordinal UTXO as the Best in Slot API's `ordinal_utxos` route serves it. */
156
167
  export interface APIOrdinalUtxoInfo {
157
168
  address: string;
158
169
  amounts: number[] | null;
@@ -170,43 +181,56 @@ export interface APIOrdinalUtxoInfo {
170
181
  vsize: number | null;
171
182
  }
172
183
  /**
173
- * Fetches the ordinal UTXOs associated with a given address from the backend API and applies fixes to include any extra UTXOs that are currently in the process of being used in transactions but not yet confirmed on the blockchain.
184
+ * Lists the ordinal UTXOs of an address from the chain provider (see `setProviders`), with the saved extra transactions applied: outputs they spend are dropped and the output carrying the saved extra inscription is added.
174
185
  *
175
186
  * @param addr The address for which to fetch the ordinal UTXOs.
176
187
  *
177
188
  * @returns A promise that resolves to an array of ordinal UTXO information objects.
178
189
  */
179
- export declare function getOrdinalUtxos(addr: string): Promise<APIOrdinalUtxoInfo[]>;
190
+ export declare function getOrdinalUtxos(addr: string): Promise<OrdinalUtxoInfo[]>;
180
191
  /**
181
- * Fetches the raw transaction hex for a given transaction ID from the backend API. It caches the result to avoid redundant network requests.
192
+ * Finds the address's unspent output that carries an inscription, with the saved extra transactions applied: the output they create for the inscription comes first, and an output they spend is not returned. A chain provider with `inscriptionUtxo` (see `setProviders`) answers in one lookup, whatever else the address holds; any other is searched through its `ordinalUtxos`.
193
+ *
194
+ * @param addr The address holding the inscription.
195
+ * @param inscriptionId The inscription's id (`<txid>i<index>`).
196
+ * @returns The output, or `null` when the address does not hold the inscription.
197
+ */
198
+ export declare function getInscriptionUtxo(addr: string, inscriptionId: string): Promise<OrdinalUtxoInfo | null>;
199
+ /**
200
+ * Returns the raw transaction hex for a transaction ID. Transactions the kit built or fetched before come from a cache; any other is read from the chain provider (see `setProviders`).
182
201
  *
183
202
  * @param txid The transaction ID for which to fetch the raw transaction hex.
184
203
  * @returns A promise that resolves to the raw transaction hex string.
185
204
  */
186
205
  export declare function getTxhex(txid: string): Promise<string>;
187
206
  /**
188
- * Validates a list of transaction hexes by sending them to the backend API for testing their acceptance into the mempool. The function combines the provided transaction hexes with any currently saved extra transaction hexes and sends them to the backend for validation.
207
+ * Tests the mempool acceptance of a list of transactions through the chain provider (see `setProviders`). The saved extra transactions are tested first, so the given transactions may spend their outputs.
189
208
  *
190
209
  * @param txHexes An array of transaction hex strings representing the transactions to be validated.
191
- * @returns A promise that resolves to the validation result returned by the backend API, or null if the validation request fails.
210
+ * @returns A promise that resolves to one result per tested transaction, saved extras included, or null when the provider's request fails with a {@link BackendError}.
192
211
  */
193
- export declare function validateTxes(txHexes: string[]): Promise<any>;
212
+ export declare function validateTxes(txHexes: string[]): Promise<MempoolAcceptResult[] | null>;
194
213
  /**
195
- * Broadcasts a list of transaction hexes to the network by sending them to the backend API. The function throws an error if there are any extra transaction hexes currently set, as broadcasting is not allowed in that state.
214
+ * Broadcasts a list of transactions through the chain provider (see `setProviders`). The function throws an error if there are any extra transaction hexes currently set, as broadcasting is not allowed in that state.
196
215
  *
197
216
  * @param txHexes An array of transaction hex strings representing the transactions to be broadcasted.
198
- * @returns A promise that resolves to the result of the broadcast request returned by the backend API, or null if the broadcast request fails.
217
+ * @returns A promise that resolves to the broadcast transactions' txids, or null when the provider's request fails with a {@link BackendError}.
199
218
  * @throws An error if there are extra transaction hexes currently set, as broadcasting is not allowed in that state.
200
219
  */
201
- export declare function broadcastTxes(txHexes: string[]): Promise<any>;
220
+ export declare function broadcastTxes(txHexes: string[]): Promise<string[] | null>;
221
+ /** The BRC2.0 precompile that verifies a BIP-322 signature; it returns 1 for a valid one. */
222
+ export declare const BIP322_VERIFY_PRECOMPILE = "0x00000000000000000000000000000000000000fe";
202
223
  /**
203
- * Verifies a signature for a given message, signature, and address by sending the verification request to the backend API. The function constructs the necessary parameters for the verification request, including converting the message to hexadecimal format and generating the pkscript from the provided address, and then sends the request to the backend for verification.
224
+ * Verifies a BIP-322 signature with the BRC2.0 chain's own verifier: an `eth_call` to its BIP-322
225
+ * precompile through the network's BRC2.0 RPC provider (see `setProviders`). A signature it accepts
226
+ * is one the chain accepts. A call the node rejects, such as one with a malformed signature, or a
227
+ * request that fails, counts as invalid.
204
228
  *
205
- * @param message The message for which the signature needs to be verified.
206
- * @param signatureHex The signature in hexadecimal format that needs to be verified against the message and address.
207
- * @param address The Bitcoin address that is claimed to have produced the signature for the given message.
208
- * @returns A promise that resolves to a boolean indicating whether the signature is valid for the given message and address, or throws an error if the verification process fails.
209
- * @throws An error if the verification process fails, such as due to network issues or invalid input parameters.
229
+ * @param message The signed message.
230
+ * @param signatureHex The signature, hex encoded.
231
+ * @param address The address that signed.
232
+ * @returns Whether the chain's verifier accepts the signature.
233
+ * @throws {Error} If the address is not valid on the selected network.
210
234
  */
211
235
  export declare function verifySignature(message: string, signatureHex: string, address: string): Promise<boolean>;
212
236
  /**
@@ -232,12 +256,13 @@ export declare function fetchWithErrors<T>(url: string, options: RequestInit): P
232
256
  /**
233
257
  * Retrieves the BRC2.0 JSON-RPC URL configured as the `rpc` endpoint for the selected network.
234
258
  *
259
+ * @param base An RPC URL to use in place of the configured `rpc` endpoint.
235
260
  * @returns The RPC URL.
236
261
  * @throws {Error} If the selected network has no RPC endpoint configured.
237
262
  */
238
- export declare function getPublicRpcUrl(): Promise<string>;
263
+ export declare function getPublicRpcUrl(base?: string): Promise<string>;
239
264
  /**
240
- * 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.
265
+ * Executes an eth_call through the BRC2.0 RPC provider of the selected network (see `setProviders`). It returns a promise that resolves to the result of the eth_call, or throws an error if the request fails.
241
266
  *
242
267
  * @param to The address of the contract to call.
243
268
  * @param abi The ABI of the contract to call.
@@ -1,7 +1,8 @@
1
- import { APIOrdinalUtxoInfo, APIUtxoInfo } from '../core/helpers';
2
1
  import { SignFunction, SignResponse } from '../provider/api';
3
2
  import { PaymentOpts } from '../types/common';
4
3
  import { InscribeFees, InscribeMultipleResult, InscribeResult, SendInscriptionResult, InscriptionDetails } from '../types/inscription';
4
+ import { Utxo } from './chain-providers';
5
+ import { OrdinalUtxoInfo } from './helpers';
5
6
  import { Buffer } from 'node:buffer';
6
7
  import { WalletInfo } from '../types/wallet';
7
8
  import * as bitcoinjs from 'bitcoinjs-lib';
@@ -131,7 +132,7 @@ export declare function mintWithReclaimsAll(inscriptionDetails: InscriptionDetai
131
132
  * broadcasting. Mirrors mintWithExtraInputInCommitFeeRate. `fetchedCardinalUtxos`, the
132
133
  * payer's `fetchCardinalUtxos` response, funds the commit in place of a new fetch.
133
134
  */
134
- export declare function mintWithReclaimsCheckFees(inscriptionDetails: InscriptionDetails, reclaimInputs: ReclaimInput[], feeRate: number, postage: number | null, fetchedCardinalUtxos?: APIUtxoInfo[]): Promise<{
135
+ export declare function mintWithReclaimsCheckFees(inscriptionDetails: InscriptionDetails, reclaimInputs: ReclaimInput[], feeRate: number, postage: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<{
135
136
  unsigned_commit_tx_hex: string;
136
137
  signed_reveal_tx_hex: string;
137
138
  inscription_id: string;
@@ -195,11 +196,11 @@ export interface InscriptionUTXODetails {
195
196
  utxo: string;
196
197
  }
197
198
  /**
198
- * Locates an inscription's UTXO on `inscriptionAddr`. Searches `ordinalUtxos` when given.
199
- * Otherwise an inscription created by the saved extra transactions resolves from them
200
- * directly, and any other inscription is looked up in the backend's `ordinal_utxos` list.
199
+ * Locates an inscription's UTXO on `inscriptionAddr`. Searches `ordinalUtxos` when given;
200
+ * otherwise reads it with `getInscriptionUtxo` (saved extra transactions first, then the
201
+ * chain provider).
201
202
  */
202
- export declare function getInscriptionDetails(inscriptionId: string, inscriptionAddr: string, ordinalUtxos?: APIOrdinalUtxoInfo[]): Promise<InscriptionUTXODetails | null>;
203
+ export declare function getInscriptionDetails(inscriptionId: string, inscriptionAddr: string, ordinalUtxos?: OrdinalUtxoInfo[]): Promise<InscriptionUTXODetails | null>;
203
204
  /**
204
205
  * Sends multiple inscriptions in one transaction with a buffer output and returns the fee paid for the transaction. This is used for batch minting or batch sending when the user wants to know the fee before actually sending the transaction.
205
206
  *
@@ -271,7 +272,7 @@ interface InscribeCheckFeesResult {
271
272
  *
272
273
  * @returns an object containing the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used
273
274
  */
274
- export declare function mintAllCheckFees(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: APIUtxoInfo[]): Promise<InscribeCheckFeesResult>;
275
+ export declare function mintAllCheckFees(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<InscribeCheckFeesResult>;
275
276
  /**
276
277
  * Sends an inscription to a target address using an OP_RETURN output. This function builds a transaction that spends the inscription UTXO and creates an OP_RETURN output with the inscription data, along with a target output with the specified postage. It then signs and broadcasts the transaction. If dryRun is true, it returns the signed transaction hex without broadcasting.
277
278
  *
@@ -350,7 +351,7 @@ interface SendInscriptionFeeRateResult {
350
351
  *
351
352
  * @returns an object containing the transaction ID, unsigned transaction hex, and calculated transaction fee
352
353
  */
353
- export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate(inscriptionId: string, extraInputUtxos: UtxoInfoWithWallet[], targetWallet: WalletInfo, targetPostage: number, extraOutputUtxos: OutputUtxoInfo[], feeRate: number, fetchedCardinalUtxos?: APIUtxoInfo[]): Promise<SendInscriptionFeeRateResult>;
354
+ export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate(inscriptionId: string, extraInputUtxos: UtxoInfoWithWallet[], targetWallet: WalletInfo, targetPostage: number, extraOutputUtxos: OutputUtxoInfo[], feeRate: number, fetchedCardinalUtxos?: Utxo[]): Promise<SendInscriptionFeeRateResult>;
354
355
  /**
355
356
  * Mints an inscription with extra input UTXOs included in the commit transaction. This function builds and signs the commit and reveal transactions for minting an inscription, while allowing the user to include additional input UTXOs in the commit transaction. This can be useful in cases where the user wants to fund the commit transaction with specific UTXOs or needs to include additional inputs for other reasons. The function retrieves the connected wallets, builds and signs the transactions, validates them, and broadcasts them to the network. If dryRun is true, it returns the signed transaction hex without broadcasting.
356
357
  *
@@ -379,5 +380,5 @@ export declare function mintWithExtraInputInCommitAll(inscriptionDetails: Inscri
379
380
  *
380
381
  * @returns an object containing the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used
381
382
  */
382
- export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: APIUtxoInfo[]): Promise<InscribeCheckFeesResult>;
383
+ export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<InscribeCheckFeesResult>;
383
384
  export {};
@@ -78,8 +78,8 @@ export declare function getPaymentWallet(): BISWallet | undefined;
78
78
  */
79
79
  export declare function getSignFn(provider: BISWalletProvider): SignFunction;
80
80
  /**
81
- * Signs a message using the currently connected wallet provider, then verifies it
82
- * against the backend. Returns the signature, or throws if signing or verification fails.
81
+ * Signs a message using the currently connected wallet provider, then verifies its BIP-322
82
+ * signature. Returns the signature, or throws if signing or verification fails.
83
83
  *
84
84
  * @param message The message to sign.
85
85
  * @param walletType The wallet purpose to sign with ('payment' | 'ordinals' | 'all').
@@ -51,6 +51,14 @@ export type EndpointsConfig = {
51
51
  * @throws {Error} If a key is unknown or a value is not an absolute http(s) URL.
52
52
  */
53
53
  export declare function setEndpoints(config: EndpointsConfig): void;
54
+ /**
55
+ * Checks that a value is an absolute http(s) URL.
56
+ *
57
+ * @param label The setting the value belongs to, used as the error prefix.
58
+ * @param value The URL to check.
59
+ * @throws {Error} If the value is not a valid URL or uses another protocol.
60
+ */
61
+ export declare function assertHttpUrl(label: string, value: string): void;
54
62
  /**
55
63
  * Returns the effective base URLs for a network: the defaults with any
56
64
  * {@link setEndpoints} overrides applied. Testnet has no `sequencerRead`,
@@ -6,6 +6,8 @@ export * as balances from './api/balances';
6
6
  export * from './api/helpers';
7
7
  export { getEndpoints, getNetwork, setEndpoints, setNetwork, subscribeToNetwork, } from './core/store-network';
8
8
  export type { Endpoints, EndpointsConfig } from './core/store-network';
9
+ export { getProviders, setProviders } from './core/chain-providers';
10
+ export type { NetworkProviders, ProvidersConfig } from './core/chain-providers';
9
11
  export type { PaymentOpts } from './types/common';
10
12
  export * as bitcoinjs from 'bitcoinjs-lib';
11
13
  export * as Buff from '@cmdcode/buff-utils';
@@ -0,0 +1,118 @@
1
+ /** The most tokens a swap path can list (two hops). */
2
+ export declare const MAX_SWAP_PATH_LENGTH = 3;
3
+ /** One pool step of a swap route. Amounts are in base units. */
4
+ export interface SwapRouteHop {
5
+ pair_address: string;
6
+ token_in: string;
7
+ token_out: string;
8
+ amount_in: bigint;
9
+ amount_out: bigint;
10
+ /** The pool's LP fee, in bps. Already reflected in `amount_out`. */
11
+ lp_fee_bps: bigint;
12
+ }
13
+ /**
14
+ * The best route the swap backend found for a swap at current reserves.
15
+ *
16
+ * `amounts[0]` is the input and `amounts[amounts.length - 1]` the output; with an exact input the
17
+ * first is the amount asked for, with an exact output the last is. Pass `path` to
18
+ * `swapExactInput` / `swapExactOutput` to execute this route.
19
+ */
20
+ export interface SwapRoute {
21
+ /** Token addresses from input to output, lowercased: 2 for a direct swap, 3 for a routed one. */
22
+ path: string[];
23
+ /** The amount at each token of `path`, net of LP fees. */
24
+ amounts: bigint[];
25
+ hops: SwapRouteHop[];
26
+ /** The LP fee of every hop added up, in bps. */
27
+ lp_fee_bps_total: bigint;
28
+ /** The protocol fee on the input token, in bps (the swap's `token1FeeBps`). */
29
+ token1FeeBps: bigint;
30
+ /** The protocol fee on the output token, in bps (the swap's `token2FeeBps`). */
31
+ token2FeeBps: bigint;
32
+ }
33
+ /** The `result` of the swap backend's `/get_swap_route`, as served. */
34
+ export interface RawSwapRoute {
35
+ path: string[];
36
+ amounts: string[];
37
+ hops: {
38
+ pair_address: string;
39
+ token_in: string;
40
+ token_out: string;
41
+ amount_in: string;
42
+ amount_out: string;
43
+ lp_fee_bps: number | string;
44
+ }[];
45
+ lp_fee_bps_total: number | string;
46
+ token1FeeBps: string;
47
+ token2FeeBps: string;
48
+ }
49
+ /**
50
+ * Converts a `/get_swap_route` result into a `SwapRoute`, checking that its path is one the swap
51
+ * flow can sign.
52
+ *
53
+ * @param raw The backend's route.
54
+ * @param tokenIn The input token asked for.
55
+ * @param tokenOut The output token asked for.
56
+ * @returns The route with bigint amounts and lowercased addresses.
57
+ * @throws {Error} If the path does not run from `tokenIn` to `tokenOut` or is malformed.
58
+ */
59
+ export declare function parseSwapRoute(raw: RawSwapRoute, tokenIn: string, tokenOut: string): SwapRoute;
60
+ /**
61
+ * Checks a swap path against the swap's input and output tokens, as the swap backend does.
62
+ *
63
+ * @param path Token addresses from `token1` to `token2`, or `undefined` for the direct path.
64
+ * @param token1 The input token.
65
+ * @param token2 The output token.
66
+ * @returns The path lowercased; `[token1, token2]` when `path` is undefined.
67
+ * @throws {Error} If the path lists fewer than 2 or more than 3 tokens, holds an invalid or
68
+ * repeated address, or does not start at `token1` and end at `token2`.
69
+ */
70
+ export declare function resolveSwapPath(path: readonly string[] | undefined, token1: string, token2: string): string[];
71
+ /** The fields shared by the exact-input and exact-output BIP322 swap texts. */
72
+ interface SwapOrderTextFields {
73
+ /** Token addresses from input to output; the direct path is `[token1, token2]`. */
74
+ path: readonly string[];
75
+ token1FeeBps: string;
76
+ token2FeeBps: string;
77
+ btc_fee: string;
78
+ referrer_pubkey?: string;
79
+ ref_return_bps?: string;
80
+ }
81
+ /**
82
+ * The BIP322 text signed for an exact-input swap (`/swap`). A routed path adds a
83
+ * `Route: a -> x -> b` line after the token addresses.
84
+ */
85
+ export declare function swapOrderSignatureText(fields: SwapOrderTextFields & {
86
+ in_amt: string;
87
+ min_out_amt: string;
88
+ }): string;
89
+ /**
90
+ * The BIP322 text signed for an exact-output swap (`/swap2`). A routed path adds a
91
+ * `Route: a -> x -> b` line after the token addresses.
92
+ */
93
+ export declare function swap2OrderSignatureText(fields: SwapOrderTextFields & {
94
+ max_in_amt: string;
95
+ out_amt: string;
96
+ }): string;
97
+ /** The fields of the BLS swap message; `amount1`/`amount2` are the op's two amount words. */
98
+ export interface SwapBLSMessageFields {
99
+ pubkey: string;
100
+ nonce: bigint;
101
+ /** Token addresses from input to output; the direct path is `[token1, token2]`. */
102
+ path: readonly string[];
103
+ amount1: bigint;
104
+ amount2: bigint;
105
+ token1FeeBps: bigint;
106
+ token2FeeBps: bigint;
107
+ btc_fee: bigint;
108
+ referrer_pubkey?: string;
109
+ ref_return_bps?: bigint;
110
+ }
111
+ /**
112
+ * The hex message hashed to the BLS curve and signed for a swap op: `03` for exact input (swap1)
113
+ * with amounts (in_amt, min_out_amt), `04` for exact output (swap2) with (max_in_amt, out_amt).
114
+ * Every path address is left-padded to 64 hex chars (the contract's address[] encoding), in path
115
+ * order.
116
+ */
117
+ export declare function swapBLSMessage(opType: '03' | '04', fields: SwapBLSMessageFields): string;
118
+ export {};
package/dist/vue.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ref as s, onScopeDispose as u, watch as i } from "vue";
2
- import { e as r, U as c, k as a } from "./mint-CSk_3TfL.js";
3
- function n() {
2
+ import { e as r, Z as c, l as a } from "./mint-eUvlNox0.js";
3
+ function w() {
4
4
  const o = s(r()), t = c((e) => {
5
5
  o.value !== e && (o.value = e);
6
6
  });
@@ -9,5 +9,5 @@ function n() {
9
9
  }), o;
10
10
  }
11
11
  export {
12
- n as useNetwork
12
+ w as useNetwork
13
13
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bestinslot/wallet-kit",
3
3
  "type": "module",
4
- "version": "0.14.2",
4
+ "version": "0.14.4",
5
5
  "private": false,
6
6
  "description": "A lightweight JavaScript library for connecting Bitcoin wallets with a unified API.",
7
7
  "license": "MIT",