@bestinslot/wallet-kit 0.14.2 → 0.15.0-rc.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.
- package/README.md +1 -0
- package/dist/{balances-BCIlZEmP.js → balances-C92Gmgw4.js} +2747 -2586
- package/dist/browser.js +55 -51
- package/dist/core.js +40 -34
- package/dist/{mint-CSk_3TfL.js → mint-FmqHYTrX.js} +3803 -3408
- package/dist/node.js +383 -355
- package/dist/react.js +4 -4
- package/dist/register-browser-providers-C-EltUwj.js +569 -0
- package/dist/types/api/helpers.d.ts +3 -0
- package/dist/types/api/swap.d.ts +9 -6
- package/dist/types/api/wallet.d.ts +2 -2
- package/dist/types/core/bis-providers.d.ts +49 -0
- package/dist/types/core/bis.d.ts +2 -0
- package/dist/types/core/bis_swap.d.ts +59 -10
- package/dist/types/core/brc20-send.d.ts +2 -1
- package/dist/types/core/chain-providers.d.ts +133 -0
- package/dist/types/core/helpers.d.ts +48 -31
- package/dist/types/core/mint.d.ts +82 -8
- package/dist/types/core/providers.d.ts +11 -3
- package/dist/types/core/sign-progress.d.ts +3 -1
- package/dist/types/core/store-network.d.ts +8 -0
- package/dist/types/core.d.ts +2 -0
- package/dist/types/lib/swap-route.d.ts +118 -0
- package/dist/types/provider/api.d.ts +20 -0
- package/dist/types/types/global.d.ts +2 -0
- package/dist/vue.js +3 -3
- package/package.json +1 -1
- package/dist/register-browser-providers-BdTwEVwB.js +0 -500
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SignFunction, SignResponse } from '../provider/api';
|
|
1
|
+
import { SignFunction, SignManyFunction, 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';
|
|
9
|
+
/** Fee rates are sat/vB and may be fractional; every fee built from one is rounded up to whole sats. */
|
|
10
|
+
export declare function assertFeeRate(feeRate: number): void;
|
|
8
11
|
export declare function getDustValue(wallet: WalletInfo): number;
|
|
9
12
|
interface TapLeafScriptInfo {
|
|
10
13
|
script: Buffer;
|
|
@@ -125,13 +128,82 @@ export declare function mintWithReclaimsAll(inscriptionDetails: InscriptionDetai
|
|
|
125
128
|
postage: number;
|
|
126
129
|
secret: string;
|
|
127
130
|
}>;
|
|
131
|
+
/** One inscription of an `inscribeAllToOpReturn` package. */
|
|
132
|
+
export interface BatchedReveal {
|
|
133
|
+
revealTxId: string;
|
|
134
|
+
signedRevealTxHex: string;
|
|
135
|
+
inscriptionId: string;
|
|
136
|
+
secret: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* How the send tx of `inscribeAllToOpReturn` moves its inscriptions into OP_RETURN outputs.
|
|
140
|
+
*
|
|
141
|
+
* - `single`: one OP_RETURN output worth `postage * (n - 1) + 1` sats, which covers the first sat
|
|
142
|
+
* of every inscription input. The postage of all but the last inscription is burned.
|
|
143
|
+
* - `interleaved`: a 1-sat OP_RETURN output per inscription, each followed by a payer output that
|
|
144
|
+
* takes back the rest of that inscription's postage (the last one merges into change). Only `n`
|
|
145
|
+
* sats are burned. Multiple OP_RETURN outputs relay from Bitcoin Core 30.
|
|
146
|
+
* - `auto`: whichever of the two costs the payer less at the fee rate.
|
|
147
|
+
*
|
|
148
|
+
* Either layout leaves one postage minus a sat after its last OP_RETURN. The send pays the fee
|
|
149
|
+
* from it, or adds a payer input and returns it as change when that costs less (low fee rates).
|
|
150
|
+
*/
|
|
151
|
+
export type BatchedSendLayout = 'single' | 'interleaved' | 'auto';
|
|
152
|
+
export interface InscribeAllToOpReturnResult {
|
|
153
|
+
commitTxId: string;
|
|
154
|
+
signedCommitTxHex: string;
|
|
155
|
+
/** One reveal per inscription, in the order the inscriptions were given. */
|
|
156
|
+
reveals: BatchedReveal[];
|
|
157
|
+
sendTxId: string;
|
|
158
|
+
signedSendTxHex: string;
|
|
159
|
+
/** The send layout used; `auto` resolves to one of the other two. */
|
|
160
|
+
sendLayout: Exclude<BatchedSendLayout, 'auto'>;
|
|
161
|
+
/** Miner fees of the commit, the reveals and the send, plus the sats burned in OP_RETURN outputs. */
|
|
162
|
+
totalFee: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The fees an `inscribeAllToOpReturn` package with the same arguments would pay, built offline
|
|
166
|
+
* without signing: the commit, the reveals, and the send's miner fee plus the sats it burns in
|
|
167
|
+
* OP_RETURN outputs. The send is priced against `cardinals` (or a fresh fetch) as they stand
|
|
168
|
+
* before the commit, the way `inscribeAllToOpReturn` picks its send plan.
|
|
169
|
+
*/
|
|
170
|
+
export declare function getInscribeAllToOpReturnFee(inscriptions: InscriptionDetails[], reclaimInputs: ReclaimInput[], opReturnWallet: WalletInfo, feeRate: number, sendLayout?: BatchedSendLayout, cardinals?: UtxoInfo[]): Promise<{
|
|
171
|
+
totalFee: number;
|
|
172
|
+
sendLayout: Exclude<BatchedSendLayout, 'auto'>;
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* `psbt`'s unsigned transaction with each input's scriptSig as signing will leave it, so its txid
|
|
176
|
+
* is the signed tx's; or null when a signature lands in a scriptSig. SegWit and taproot inputs
|
|
177
|
+
* sign in the witness and keep an empty scriptSig, and a P2SH-P2WPKH input's scriptSig is the push
|
|
178
|
+
* of its redeem script. Any other input, such as legacy P2PKH, makes it null.
|
|
179
|
+
*/
|
|
180
|
+
export declare function unsignedTxOnceSigned(psbt: bitcoinjs.Psbt): bitcoinjs.Transaction | null;
|
|
181
|
+
/**
|
|
182
|
+
* Inscribes several inscriptions from one commit tx and sends them all to OP_RETURN outputs in
|
|
183
|
+
* one tx, so the wallet signs two transactions however many inscriptions there are. The signed
|
|
184
|
+
* package is validated with testmempoolaccept and returned for the caller to broadcast.
|
|
185
|
+
*
|
|
186
|
+
* Commit outputs: one self-send per reclaim input (same index and value as the input), then one
|
|
187
|
+
* taproot commit output per inscription, then payer change. Each inscription keeps its own reveal
|
|
188
|
+
* tx, because BRC-20 indexers only accept an inscription made in the first input of its reveal.
|
|
189
|
+
*
|
|
190
|
+
* The send tx spends the reveal outputs as inputs `0..n-1` in the given order, and its outputs
|
|
191
|
+
* follow `sendLayout`. Either way the first sat of every inscription input lands in an OP_RETURN
|
|
192
|
+
* output, in input order, so ord moves each inscription there and indexers process them in that
|
|
193
|
+
* order.
|
|
194
|
+
*
|
|
195
|
+
* With `signManyFunc`, the commit and the send are signed in one wallet prompt whenever the commit's
|
|
196
|
+
* txid is known before signing (see `unsignedTxOnceSigned`); the package is refused if the signed
|
|
197
|
+
* commit's txid differs. Otherwise `signFunc` signs the commit, then the send.
|
|
198
|
+
*/
|
|
199
|
+
export declare function inscribeAllToOpReturn(inscriptions: InscriptionDetails[], reclaimInputs: ReclaimInput[], opReturnWallet: WalletInfo, feeRate: number, signFunc: SignFunction, sendLayout?: BatchedSendLayout, signManyFunc?: SignManyFunction | null): Promise<InscribeAllToOpReturnResult>;
|
|
128
200
|
/**
|
|
129
201
|
* Estimates the fees for a reclaim mint by building the unsigned reclaim
|
|
130
202
|
* commit tx (Task 1) and a fee-sizing reveal tx offline, without signing or
|
|
131
203
|
* broadcasting. Mirrors mintWithExtraInputInCommitFeeRate. `fetchedCardinalUtxos`, the
|
|
132
204
|
* payer's `fetchCardinalUtxos` response, funds the commit in place of a new fetch.
|
|
133
205
|
*/
|
|
134
|
-
export declare function mintWithReclaimsCheckFees(inscriptionDetails: InscriptionDetails, reclaimInputs: ReclaimInput[], feeRate: number, postage: number | null, fetchedCardinalUtxos?:
|
|
206
|
+
export declare function mintWithReclaimsCheckFees(inscriptionDetails: InscriptionDetails, reclaimInputs: ReclaimInput[], feeRate: number, postage: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<{
|
|
135
207
|
unsigned_commit_tx_hex: string;
|
|
136
208
|
signed_reveal_tx_hex: string;
|
|
137
209
|
inscription_id: string;
|
|
@@ -161,10 +233,12 @@ export declare function resolveReclaimInputs(reclaimInscriptions: {
|
|
|
161
233
|
* @param amounts - array of amounts to send to each output wallet (must be the same length as outputWallets)
|
|
162
234
|
* @param changeWallet - the wallet to send the change to
|
|
163
235
|
* @param feeRate - the fee rate in sat/vbyte
|
|
236
|
+
* @param fundingInput - add a payer UTXO even when `forceInUtxos` cover the outputs and the fee, so
|
|
237
|
+
* their surplus returns as change instead of going to the miner
|
|
164
238
|
*
|
|
165
239
|
* @returns an object containing the built transaction and the fee paid for the transaction
|
|
166
240
|
*/
|
|
167
|
-
export declare function buildTransactionMultiOutput(utxoArray: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, outputWallets: WalletInfo[], amounts: number[], changeWallet: WalletInfo, feeRate: number): BuildTransactionResult;
|
|
241
|
+
export declare function buildTransactionMultiOutput(utxoArray: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, outputWallets: WalletInfo[], amounts: number[], changeWallet: WalletInfo, feeRate: number, fundingInput?: boolean): BuildTransactionResult;
|
|
168
242
|
interface SendMultiInscriptionWithBufferResult {
|
|
169
243
|
txid: string;
|
|
170
244
|
signed_tx_hex: string;
|
|
@@ -199,7 +273,7 @@ export interface InscriptionUTXODetails {
|
|
|
199
273
|
* Otherwise an inscription created by the saved extra transactions resolves from them
|
|
200
274
|
* directly, and any other inscription is looked up in the backend's `ordinal_utxos` list.
|
|
201
275
|
*/
|
|
202
|
-
export declare function getInscriptionDetails(inscriptionId: string, inscriptionAddr: string, ordinalUtxos?:
|
|
276
|
+
export declare function getInscriptionDetails(inscriptionId: string, inscriptionAddr: string, ordinalUtxos?: OrdinalUtxoInfo[]): Promise<InscriptionUTXODetails | null>;
|
|
203
277
|
/**
|
|
204
278
|
* 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
279
|
*
|
|
@@ -271,7 +345,7 @@ interface InscribeCheckFeesResult {
|
|
|
271
345
|
*
|
|
272
346
|
* @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
347
|
*/
|
|
274
|
-
export declare function mintAllCheckFees(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?:
|
|
348
|
+
export declare function mintAllCheckFees(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<InscribeCheckFeesResult>;
|
|
275
349
|
/**
|
|
276
350
|
* 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
351
|
*
|
|
@@ -350,7 +424,7 @@ interface SendInscriptionFeeRateResult {
|
|
|
350
424
|
*
|
|
351
425
|
* @returns an object containing the transaction ID, unsigned transaction hex, and calculated transaction fee
|
|
352
426
|
*/
|
|
353
|
-
export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate(inscriptionId: string, extraInputUtxos: UtxoInfoWithWallet[], targetWallet: WalletInfo, targetPostage: number, extraOutputUtxos: OutputUtxoInfo[], feeRate: number, fetchedCardinalUtxos?:
|
|
427
|
+
export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate(inscriptionId: string, extraInputUtxos: UtxoInfoWithWallet[], targetWallet: WalletInfo, targetPostage: number, extraOutputUtxos: OutputUtxoInfo[], feeRate: number, fetchedCardinalUtxos?: Utxo[]): Promise<SendInscriptionFeeRateResult>;
|
|
354
428
|
/**
|
|
355
429
|
* 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
430
|
*
|
|
@@ -379,5 +453,5 @@ export declare function mintWithExtraInputInCommitAll(inscriptionDetails: Inscri
|
|
|
379
453
|
*
|
|
380
454
|
* @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
455
|
*/
|
|
382
|
-
export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?:
|
|
456
|
+
export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<InscribeCheckFeesResult>;
|
|
383
457
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BISProvider, SignFunction } from '../provider/api';
|
|
1
|
+
import { BISProvider, SignFunction, SignManyFunction } from '../provider/api';
|
|
2
2
|
import { BISSession, BISWallet, BISWalletProvider, BISWalletPurpose } from '../types/common';
|
|
3
3
|
/**
|
|
4
4
|
* Thrown before signing when the account active in the wallet extension differs from the
|
|
@@ -78,8 +78,16 @@ export declare function getPaymentWallet(): BISWallet | undefined;
|
|
|
78
78
|
*/
|
|
79
79
|
export declare function getSignFn(provider: BISWalletProvider): SignFunction;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
81
|
+
* Returns the specified provider's function for signing several PSBTs in one wallet prompt, or
|
|
82
|
+
* null when the provider or its installed wallet has none.
|
|
83
|
+
*
|
|
84
|
+
* @param provider The wallet provider.
|
|
85
|
+
* @returns The provider's batch sign function, or null.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getSignManyFn(provider: BISWalletProvider): SignManyFunction | null;
|
|
88
|
+
/**
|
|
89
|
+
* Signs a message using the currently connected wallet provider, then verifies its BIP-322
|
|
90
|
+
* signature. Returns the signature, or throws if signing or verification fails.
|
|
83
91
|
*
|
|
84
92
|
* @param message The message to sign.
|
|
85
93
|
* @param walletType The wallet purpose to sign with ('payment' | 'ordinals' | 'all').
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SignFunction } from '../provider/api';
|
|
1
|
+
import { SignFunction, SignManyFunction } from '../provider/api';
|
|
2
2
|
/** A wallet prompt a multi-signature flow is about to raise. */
|
|
3
3
|
export interface SignRequest {
|
|
4
4
|
/** 1-based index of this prompt within the flow. */
|
|
@@ -27,4 +27,6 @@ export declare class SignProgress {
|
|
|
27
27
|
constructor(options?: SignProgressOptions, total?: number);
|
|
28
28
|
next(): void;
|
|
29
29
|
wrap(signFn: SignFunction): SignFunction;
|
|
30
|
+
/** As `wrap`, for a function that signs several PSBTs in one prompt: each call counts once. */
|
|
31
|
+
wrapMany(signMany: SignManyFunction): SignManyFunction;
|
|
30
32
|
}
|
|
@@ -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`,
|
package/dist/types/core.d.ts
CHANGED
|
@@ -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 {};
|
|
@@ -32,6 +32,20 @@ export interface SignatureWithAddress {
|
|
|
32
32
|
* @returns A promise that resolves to an object containing the signed PSBT as a hexadecimal string and optionally the transaction ID (txid) if the transaction was broadcasted. This allows developers to use the signed PSBT for further processing or to track the transaction on the blockchain. If there is an error in signing the PSBT, the promise will be rejected with a descriptive error message.
|
|
33
33
|
*/
|
|
34
34
|
export type SignFunction = (unsignedPsbtHex: string, paymentAddr: string, ordAddr: string, ordAddrIdxes: number[], useTweakSignerIdxes?: number[], noSignIdxes?: number[]) => Promise<SignResponse>;
|
|
35
|
+
/** One PSBT of a `SignManyFunction` call, with the arguments a `SignFunction` takes for it. */
|
|
36
|
+
export interface SignPsbtRequest {
|
|
37
|
+
unsignedPsbtHex: string;
|
|
38
|
+
paymentAddr: string;
|
|
39
|
+
ordAddr: string;
|
|
40
|
+
ordAddrIdxes: number[];
|
|
41
|
+
useTweakSignerIdxes?: number[];
|
|
42
|
+
noSignIdxes?: number[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Signs several PSBTs in one wallet prompt and returns one `SignResponse` per request, in order.
|
|
46
|
+
* The PSBTs may depend on each other (one spending another's outputs), so none is broadcast.
|
|
47
|
+
*/
|
|
48
|
+
export type SignManyFunction = (requests: SignPsbtRequest[]) => Promise<SignResponse[]>;
|
|
35
49
|
/**
|
|
36
50
|
* Defines the interface for a BISProvider, which includes methods for retrieving wallets, signing messages, and sending Bitcoin. The BISProvider interface specifies the structure that any wallet provider must implement to be compatible with the BIS Wallet Kit. This includes methods for getting the list of wallets, signing messages in both standard and deterministic ways, sending Bitcoin transactions, and signing PSBTs (Partially Signed Bitcoin Transactions). By adhering to this interface, different wallet providers can be integrated into the BIS Wallet Kit while ensuring a consistent API for developers using the kit.
|
|
37
51
|
*/
|
|
@@ -110,4 +124,10 @@ export interface BISProvider {
|
|
|
110
124
|
* @returns A promise that resolves to an object containing the signed PSBT as a hexadecimal string and optionally the transaction ID (txid) if the transaction was broadcasted. This allows developers to use the signed PSBT for further processing or to track the transaction on the blockchain. If there is an error in signing the PSBT, the promise will be rejected with a descriptive error message.
|
|
111
125
|
*/
|
|
112
126
|
sign: SignFunction;
|
|
127
|
+
/**
|
|
128
|
+
* Returns a function that signs several PSBTs in one wallet prompt, or null when the wallet
|
|
129
|
+
* (or its installed version) has no such method. Implemented only by providers whose wallet
|
|
130
|
+
* offers batch signing.
|
|
131
|
+
*/
|
|
132
|
+
getSignMany?: () => SignManyFunction | null;
|
|
113
133
|
}
|
|
@@ -21,6 +21,8 @@ interface UniSat {
|
|
|
21
21
|
switchNetwork: (network: string) => Promise<void>
|
|
22
22
|
signMessage: (message: string, type?: 'ecdsa' | 'bip322-simple') => Promise<string>
|
|
23
23
|
signPsbt: (psbt: any, options?: any) => Promise<string>
|
|
24
|
+
/** Signs several PSBT hexes in one prompt; absent before UniSat added batch signing. */
|
|
25
|
+
signPsbts?: (psbts: string[], options?: any[]) => Promise<string[]>
|
|
24
26
|
pushPsbt: (psbt: any) => Promise<string>
|
|
25
27
|
getPublicKey: () => Promise<string>
|
|
26
28
|
sendBitcoin: (toAddress: string, amountSats: number) => Promise<string>
|
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,
|
|
3
|
-
function
|
|
2
|
+
import { e as r, Z as c, l as a } from "./mint-FmqHYTrX.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
|
-
|
|
12
|
+
w as useNetwork
|
|
13
13
|
};
|
package/package.json
CHANGED