@bestinslot/wallet-kit 0.13.8 → 0.14.1
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/dist/{balances-BnXuM9CG.js → balances-Hy-8lE7A.js} +2272 -2147
- package/dist/browser.js +19 -18
- package/dist/core.js +25 -24
- package/dist/{mint-CHlWPuov.js → mint-CSk_3TfL.js} +107 -73
- package/dist/node.js +18 -17
- package/dist/react.js +1 -1
- package/dist/{register-browser-providers-b9rpXGqV.js → register-browser-providers-BdTwEVwB.js} +13 -13
- package/dist/types/api/balances.d.ts +11 -0
- package/dist/types/api/brc20.d.ts +43 -0
- package/dist/types/api/helpers.d.ts +1 -0
- package/dist/types/core/backend-error.d.ts +31 -0
- package/dist/types/core/brc20-send.d.ts +33 -2
- package/dist/types/core/frbtc.d.ts +58 -0
- package/dist/types/core/helpers.d.ts +3 -5
- package/dist/vue.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Brc20SendQuote, SendAsBrc20Args, SendAsBrc20ProgArgs, SendAsBrc20ProgResult, SendAsBrc20Result } from '../core/brc20-send';
|
|
2
|
+
import { FrBtcResult, UnwrapBtcFromBrc20ProgArgs, WrapBtcToBrc20ProgArgs } from '../core/frbtc';
|
|
2
3
|
import { BISWalletPurpose, PaymentOpts } from '../types/common';
|
|
3
4
|
export type { Brc20AmountOptions, Brc20DeployOptions, Brc20PredeployOptions, Brc20PredeployResult, } from '../core/brc20-inscriptions';
|
|
4
5
|
export { computeBrc20PredeployHash, deployBrc20Inscription, generateBrc20Salt, mintBrc20Inscription, predeployInscriptions, transferBrc20Inscription, } from '../core/brc20-inscriptions';
|
|
@@ -43,6 +44,48 @@ export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs & {
|
|
|
43
44
|
dryRun: false;
|
|
44
45
|
}): Promise<SendAsBrc20ProgResult>;
|
|
45
46
|
export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs): Promise<Brc20SendQuote | SendAsBrc20ProgResult>;
|
|
47
|
+
export type { FrBtcResult, UnwrapBtcFromBrc20ProgArgs, WrapBtcToBrc20ProgArgs } from '../core/frbtc';
|
|
48
|
+
export { getFrBtcAddress } from '../core/frbtc';
|
|
49
|
+
/**
|
|
50
|
+
* Wraps BTC into frBTC held by the wallet's own BRC2.0 address, with no smart wallet involved. One
|
|
51
|
+
* call inscription runs `wrap()` on Subfrost's frBTC contract; its send transaction pays `amount`
|
|
52
|
+
* sats to the frBTC signer, and the contract mints frBTC, less its `premium()` fee, to the ordinals
|
|
53
|
+
* address's BRC2.0 address.
|
|
54
|
+
*
|
|
55
|
+
* With `dryRun: true` nothing is signed or broadcast and the result is a fee quote whose
|
|
56
|
+
* `paymentSats` is the wrapped amount. `onSignRequest` is called before each wallet prompt with
|
|
57
|
+
* `{ step, total }`; `total` is 2.
|
|
58
|
+
*
|
|
59
|
+
* @param args - `amount` (bigint sats, at least 546), `feeRate` (sats/vB), `dryRun`, and optional `onSignRequest`.
|
|
60
|
+
* @returns The quote for a dry run; otherwise the call's transaction ids plus every txid in chain order.
|
|
61
|
+
*/
|
|
62
|
+
export declare function wrapBtcToBrc20Prog(args: WrapBtcToBrc20ProgArgs & {
|
|
63
|
+
dryRun: true;
|
|
64
|
+
}): Promise<Brc20SendQuote>;
|
|
65
|
+
export declare function wrapBtcToBrc20Prog(args: WrapBtcToBrc20ProgArgs & {
|
|
66
|
+
dryRun: false;
|
|
67
|
+
}): Promise<FrBtcResult>;
|
|
68
|
+
export declare function wrapBtcToBrc20Prog(args: WrapBtcToBrc20ProgArgs): Promise<Brc20SendQuote | FrBtcResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Unwraps frBTC held by the wallet's own BRC2.0 address into BTC paid to `recipient`, with no smart
|
|
71
|
+
* wallet involved. One call inscription runs `unwrap2` on Subfrost's frBTC contract, which burns the
|
|
72
|
+
* frBTC and queues the payment; its send transaction pays a 546-sat marker to the frBTC signer, which
|
|
73
|
+
* pays the BTC out in a later Bitcoin transaction.
|
|
74
|
+
*
|
|
75
|
+
* With `dryRun: true` nothing is signed or broadcast and the result is a fee quote. `onSignRequest` is
|
|
76
|
+
* called before each wallet prompt with `{ step, total }`; `total` is 2.
|
|
77
|
+
*
|
|
78
|
+
* @param args - `amount` (bigint sats), `recipient` (Bitcoin address), `feeRate` (sats/vB), `dryRun`, and optional `onSignRequest`.
|
|
79
|
+
* @returns The quote for a dry run; otherwise the call's transaction ids plus every txid in chain order.
|
|
80
|
+
* @throws {Error} When the BRC2.0 frBTC balance is below `amount`, before anything is signed.
|
|
81
|
+
*/
|
|
82
|
+
export declare function unwrapBtcFromBrc20Prog(args: UnwrapBtcFromBrc20ProgArgs & {
|
|
83
|
+
dryRun: true;
|
|
84
|
+
}): Promise<Brc20SendQuote>;
|
|
85
|
+
export declare function unwrapBtcFromBrc20Prog(args: UnwrapBtcFromBrc20ProgArgs & {
|
|
86
|
+
dryRun: false;
|
|
87
|
+
}): Promise<FrBtcResult>;
|
|
88
|
+
export declare function unwrapBtcFromBrc20Prog(args: UnwrapBtcFromBrc20ProgArgs): Promise<Brc20SendQuote | FrBtcResult>;
|
|
46
89
|
/**
|
|
47
90
|
* 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.
|
|
48
91
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { BackendError } from '../core/backend-error';
|
|
1
2
|
export { getEvmAddressFromBitcoinAddress, getEvmAddressFromPkScript } from '../core/brc20';
|
|
2
3
|
export { delegateInscription, jsonInscription, textInscription } from '../types/inscription';
|
|
3
4
|
export { addressWalletInfo, opReturnWalletInfo } from '../types/wallet';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a backend request fails: the request did not complete, the response had a 4xx/5xx
|
|
3
|
+
* status, or a 2xx body carried an `error` field.
|
|
4
|
+
*
|
|
5
|
+
* Branch on `code`, the backend's stable machine-readable code (e.g. `WALLET_KEY_MISMATCH`,
|
|
6
|
+
* `FEES_INSUFFICIENT`, `SEQUENCER_HALTED`), and fall back to `status`. `detail` is the backend's
|
|
7
|
+
* own English text; `message` is that text prefixed with `API Request Failed: `. `ref` is the
|
|
8
|
+
* backend's ID for the failed request, which its logs carry too.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BackendError extends Error {
|
|
11
|
+
readonly detail: string;
|
|
12
|
+
readonly status: number | undefined;
|
|
13
|
+
readonly code: string | undefined;
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly ref?: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* @param detail The backend's error text, or a description of the transport failure.
|
|
18
|
+
* @param status The HTTP status, or `undefined` when no response arrived.
|
|
19
|
+
* @param code The backend's error code, when its body carried one.
|
|
20
|
+
* @param url The requested URL.
|
|
21
|
+
* @param ref The backend's request ID, when its body carried one.
|
|
22
|
+
*/
|
|
23
|
+
constructor(detail: string, status: number | undefined, code: string | undefined, url: string, ref?: string | undefined);
|
|
24
|
+
}
|
|
25
|
+
/** The error built from a JSON body with an `error` field, carrying its `code` and `ref`. */
|
|
26
|
+
export declare function backendErrorFromBody(body: any, status: number, url: string): BackendError;
|
|
27
|
+
/**
|
|
28
|
+
* Reads an error response body: a JSON `{ error, code, ref }` object, any other JSON value, or
|
|
29
|
+
* plain text. An empty body falls back to the status line.
|
|
30
|
+
*/
|
|
31
|
+
export declare function backendErrorFromResponse(response: Response, url: string): Promise<BackendError>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SignProgressOptions } from './sign-progress';
|
|
2
|
+
import { InscriptionDetails } from '../types/inscription';
|
|
3
|
+
import { WalletInfo } from '../types/wallet';
|
|
2
4
|
/** The transactions of one inscribe-and-send step. */
|
|
3
5
|
export interface Brc20SendPart {
|
|
4
6
|
commitTxId: string;
|
|
@@ -14,21 +16,47 @@ export interface Brc20SendStepQuote {
|
|
|
14
16
|
minerFeeSats: number;
|
|
15
17
|
/** Sats the send leaves on its target output (the recipient's postage, or 1 sat on OP_RETURN). */
|
|
16
18
|
postageSats: number;
|
|
19
|
+
/** Sats the send pays to its extra outputs, such as the BTC an frBTC wrap sends to the signer. */
|
|
20
|
+
paymentSats: number;
|
|
17
21
|
/** Wallet prompts this step raises. */
|
|
18
22
|
walletPrompts: number;
|
|
19
23
|
}
|
|
20
24
|
/** What a composite send costs, built without signing or broadcasting. */
|
|
21
25
|
export interface Brc20SendQuote {
|
|
22
|
-
/** Sats the wallet spends in all: miner fees
|
|
26
|
+
/** Sats the wallet spends in all: miner fees, postage and payments. */
|
|
23
27
|
totalSats: number;
|
|
24
28
|
minerFeeSats: number;
|
|
25
29
|
postageSats: number;
|
|
30
|
+
paymentSats: number;
|
|
26
31
|
/** Wallet prompts the real send raises; `onSignRequest` reports each of them. */
|
|
27
32
|
walletPrompts: number;
|
|
28
33
|
feeRate: number;
|
|
29
34
|
steps: Brc20SendStepQuote[];
|
|
30
35
|
}
|
|
31
|
-
export type Brc20SendStepName = 'brc20Transfer' | 'progWithdraw' | 'progDeposit' | 'progTransfer';
|
|
36
|
+
export type Brc20SendStepName = 'brc20Transfer' | 'progWithdraw' | 'progDeposit' | 'progTransfer' | 'frBtcWrap' | 'frBtcUnwrap';
|
|
37
|
+
/** An output the send transaction carries right after the target, at vout 1, 2, …. */
|
|
38
|
+
export interface ChainExtraOutput {
|
|
39
|
+
wallet: WalletInfo;
|
|
40
|
+
value: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ChainStep {
|
|
43
|
+
name: Brc20SendStepName;
|
|
44
|
+
inscription: InscriptionDetails;
|
|
45
|
+
target: WalletInfo;
|
|
46
|
+
extraOutputs?: ChainExtraOutput[];
|
|
47
|
+
/** Most inputs the send may spend; the chain is refused before broadcast when it spends more. */
|
|
48
|
+
maxSendInputs?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ChainResult {
|
|
51
|
+
parts: Record<string, Brc20SendPart>;
|
|
52
|
+
txIds: string[];
|
|
53
|
+
}
|
|
54
|
+
export declare function opReturnTarget(): WalletInfo;
|
|
55
|
+
/**
|
|
56
|
+
* Builds a `brc20-prog` call inscription. BRC2.0 grants `content bytes × GAS_PER_BYTE` gas, so the
|
|
57
|
+
* content is padded with spaces when its bytes alone fall short of `gasCeiling`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function callInscription(contractAddress: string, calldata: string, gasCeiling: number): Promise<InscriptionDetails>;
|
|
32
60
|
/**
|
|
33
61
|
* Parses a BRC-20 decimal amount string into an 18-decimal bigint.
|
|
34
62
|
*
|
|
@@ -36,6 +64,9 @@ export type Brc20SendStepName = 'brc20Transfer' | 'progWithdraw' | 'progDeposit'
|
|
|
36
64
|
* @param label - The argument name used in error messages.
|
|
37
65
|
*/
|
|
38
66
|
export declare function parseBrc20Amount(value: string, label: string): bigint;
|
|
67
|
+
export declare function assertRecipient(recipient: string): void;
|
|
68
|
+
export declare function assertFeeRate(feeRate: number): void;
|
|
69
|
+
export declare function runChain(steps: ChainStep[], feeRate: number, dryRun: boolean, options: SignProgressOptions): Promise<Brc20SendQuote | ChainResult>;
|
|
39
70
|
export interface SendAsBrc20Args extends SignProgressOptions {
|
|
40
71
|
tick: string;
|
|
41
72
|
/** Amount taken from the sender's base BRC-20 balance, as a decimal string; `"0"` skips it. */
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Brc20SendPart, Brc20SendQuote } from './brc20-send';
|
|
2
|
+
import { SignProgressOptions } from './sign-progress';
|
|
3
|
+
import { Buffer } from 'node:buffer';
|
|
4
|
+
/**
|
|
5
|
+
* Value of the marker output an unwrap pays the frBTC signer, and the smallest wrap: the dust limit
|
|
6
|
+
* of every standard output type.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FRBTC_SIGNER_DUST_SATS = 546;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the frBTC contract address on the selected network, lowercased.
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} On a network without frBTC (testnet).
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFrBtcAddress(): string;
|
|
15
|
+
/** Reads the output script of the frBTC signer, which receives wrapped BTC and unwrap markers. */
|
|
16
|
+
export declare function getFrBtcSignerScript(): Promise<Buffer>;
|
|
17
|
+
/**
|
|
18
|
+
* Reads the frBTC balance held by a Bitcoin address's BRC2.0 (EVM) address.
|
|
19
|
+
*
|
|
20
|
+
* @param bitcoinAddress - The Bitcoin address whose BRC2.0 balance to read; the ordinals address for a connected wallet.
|
|
21
|
+
* @returns The balance in sats (frBTC has 8 decimals).
|
|
22
|
+
*/
|
|
23
|
+
export declare function getFrBtcBalanceOfAddress(bitcoinAddress: string): Promise<bigint>;
|
|
24
|
+
export interface WrapBtcToBrc20ProgArgs extends SignProgressOptions {
|
|
25
|
+
/** BTC to wrap, in sats. The wallet's BRC2.0 address receives the frBTC. */
|
|
26
|
+
amount: bigint;
|
|
27
|
+
feeRate: number;
|
|
28
|
+
dryRun: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface UnwrapBtcFromBrc20ProgArgs extends SignProgressOptions {
|
|
31
|
+
/** frBTC to unwrap, in sats, taken from the wallet's BRC2.0 balance. */
|
|
32
|
+
amount: bigint;
|
|
33
|
+
/** Bitcoin address the signer pays the BTC to. */
|
|
34
|
+
recipient: string;
|
|
35
|
+
feeRate: number;
|
|
36
|
+
dryRun: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface FrBtcResult {
|
|
39
|
+
/** The call inscription's commit, reveal and send transactions. */
|
|
40
|
+
call: Brc20SendPart;
|
|
41
|
+
/** Every broadcast transaction id, in chain order. */
|
|
42
|
+
txIds: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Wraps BTC into frBTC held by the wallet's own BRC2.0 address. One call inscription runs `wrap()` on
|
|
46
|
+
* the frBTC contract, and its send transaction pays `amount` sats to the frBTC signer at vout 1; the
|
|
47
|
+
* contract mints frBTC, less its `premium()` fee, to the inscription's owner, the ordinals address.
|
|
48
|
+
*/
|
|
49
|
+
export declare function wrapBtcToBrc20Prog(args: WrapBtcToBrc20ProgArgs): Promise<Brc20SendQuote | FrBtcResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Unwraps frBTC held by the wallet's own BRC2.0 address into BTC paid to `recipient`. One call
|
|
52
|
+
* inscription runs `unwrap2(amount, 1, recipientScript)` on the frBTC contract, and its send
|
|
53
|
+
* transaction pays a 546-sat marker to the frBTC signer at vout 1. The contract burns the frBTC and
|
|
54
|
+
* queues the payment; the signer pays it out in a later Bitcoin transaction.
|
|
55
|
+
*
|
|
56
|
+
* @throws {Error} When the BRC2.0 frBTC balance is below `amount`, before anything is signed.
|
|
57
|
+
*/
|
|
58
|
+
export declare function unwrapBtcFromBrc20Prog(args: UnwrapBtcFromBrc20ProgArgs): Promise<Brc20SendQuote | FrBtcResult>;
|
|
@@ -220,15 +220,13 @@ export declare function verifySignature(message: string, signatureHex: string, a
|
|
|
220
220
|
*/
|
|
221
221
|
export declare function verifySignatureLocal(message: string, signatureHex: string, address: string): boolean;
|
|
222
222
|
/**
|
|
223
|
-
*
|
|
224
|
-
* It automatically checks for non-ok HTTP responses and for an 'error' field
|
|
225
|
-
* in the JSON response body, throwing a descriptive error in either case.
|
|
223
|
+
* Fetches a backend JSON route.
|
|
226
224
|
*
|
|
227
225
|
* @param url The URL to fetch.
|
|
228
226
|
* @param options The standard RequestInit options for the fetch call.
|
|
229
227
|
* @returns A promise that resolves with the parsed JSON data of type T.
|
|
230
|
-
* @throws {
|
|
231
|
-
*
|
|
228
|
+
* @throws {BackendError} When the request does not complete, the HTTP status is not ok, the body
|
|
229
|
+
* is not JSON, or the body carries an `error` field. It holds the status and the backend's `code`.
|
|
232
230
|
*/
|
|
233
231
|
export declare function fetchWithErrors<T>(url: string, options: RequestInit): Promise<T>;
|
|
234
232
|
/**
|
package/dist/vue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref as s, onScopeDispose as u, watch as i } from "vue";
|
|
2
|
-
import { e as r,
|
|
2
|
+
import { e as r, U as c, k as a } from "./mint-CSk_3TfL.js";
|
|
3
3
|
function n() {
|
|
4
4
|
const o = s(r()), t = c((e) => {
|
|
5
5
|
o.value !== e && (o.value = e);
|
package/package.json
CHANGED