@bestinslot/wallet-kit 0.15.0-rc.7 → 0.15.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/dist/react.js CHANGED
@@ -1,12 +1,12 @@
1
- import { useSyncExternalStore as l, useCallback as r, useState as i } from "react";
2
- import { Z as u, e, l as c, j as n } from "./helpers-BwuYuc7j.js";
1
+ import { useSyncExternalStore as u, useCallback as r, useState as f } from "react";
2
+ import { _ as c, f as t, m as l, k as n } from "./helpers-DhmRTIg0.js";
3
3
  function m() {
4
- const t = l(u, e, e), s = r((o) => c(o), []);
5
- return [t, s];
4
+ const e = u(c, t, t), s = r((o) => l(o), []);
5
+ return [e, s];
6
6
  }
7
7
  function S() {
8
- const t = l(u, e, e), [s, o] = i(() => n() ?? null), a = r(() => o(n() ?? null), []), k = r((w) => c(w), []);
9
- return { session: s, network: t, setNetwork: k, refresh: a };
8
+ const e = u(c, t, t), [s, o] = f(() => n() ?? null), a = r(() => o(n() ?? null), []), k = r((w) => l(w), []);
9
+ return { session: s, network: e, setNetwork: k, refresh: a };
10
10
  }
11
11
  export {
12
12
  m as useNetwork,
@@ -1,7 +1,7 @@
1
- import { N as f, M as K, h as P, O as W, P as ke, Q as ve, R as Me, S as Ie, f as Ae, K as x, L as N, _ as Ce, V as Q, $ as Be, a0 as Ne, e as y, a1 as _e, J as _, a2 as J, a3 as v, Y as $ } from "./helpers-BwuYuc7j.js";
2
- const Z = 4294967295;
3
- let X = Math.floor(Math.random() * Z);
4
- const ee = () => (X = (X + 1) % Z, X), $e = () => typeof chrome < "u" && !!chrome.runtime && typeof chrome.runtime.connect == "function";
1
+ import { O as f, N as K, i as P, P as W, Q as ke, R as ve, S as Me, T as Ie, h as Ae, L as x, M as N, $ as Ce, X as Y, a0 as Be, a1 as Ne, f as y, a2 as _e, K as _, a3 as Z, a4 as v, Z as $ } from "./helpers-DhmRTIg0.js";
2
+ const J = 4294967295;
3
+ let X = Math.floor(Math.random() * J);
4
+ const ee = () => (X = (X + 1) % J, X), $e = () => typeof chrome < "u" && !!chrome.runtime && typeof chrome.runtime.connect == "function";
5
5
  async function Oe(e, n = {}) {
6
6
  const { maxRetries: t = 10, retryDelay: s = 200, timeoutErrorClass: o } = n;
7
7
  for (let i = 0; i <= t; i++)
@@ -245,11 +245,11 @@ function z(e) {
245
245
  return f.from(e).toString("hex");
246
246
  }
247
247
  function De(e, n) {
248
- const t = Q();
248
+ const t = Y();
249
249
  return n.toLowerCase().startsWith(t.bech32) ? x.payments.p2wpkh({ pubkey: e, network: t }).address : x.payments.p2pkh({ pubkey: e, network: t }).address;
250
250
  }
251
251
  function qe(e) {
252
- const n = f.from(Q().messagePrefix, "utf8"), t = f.from(e, "utf8"), s = f.alloc(Be(t.length));
252
+ const n = f.from(Y().messagePrefix, "utf8"), t = f.from(e, "utf8"), s = f.alloc(Be(t.length));
253
253
  return Ne(t.length, s), x.crypto.hash256(f.concat([n, s, t]));
254
254
  }
255
255
  function ze(e, n, t) {
@@ -402,7 +402,7 @@ var Ve = function(e, n, t, s) {
402
402
  if (t === "a" && !s) throw new TypeError("Private accessor was defined without a getter");
403
403
  if (typeof n == "function" ? e !== n || !s : !n.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
404
404
  return t === "m" ? s : t === "a" ? s.call(e) : s ? s.value : n.get(e);
405
- }, Ye = function(e, n, t, s, o) {
405
+ }, Qe = function(e, n, t, s, o) {
406
406
  if (s === "m") throw new TypeError("Private method is not writable");
407
407
  if (s === "a" && !o) throw new TypeError("Private accessor was defined without a setter");
408
408
  if (typeof n == "function" ? e !== n || !o : !n.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
@@ -410,14 +410,14 @@ var Ve = function(e, n, t, s) {
410
410
  }, C;
411
411
  let S;
412
412
  const O = /* @__PURE__ */ new Set();
413
- function Qe(e) {
413
+ function Ye(e) {
414
414
  k = void 0, O.add(e);
415
415
  }
416
- function Je(e) {
416
+ function Ze(e) {
417
417
  k = void 0, O.delete(e);
418
418
  }
419
419
  const E = {};
420
- function Ze() {
420
+ function Je() {
421
421
  if (S || (S = Object.freeze({ register: j, get: en, on: nn }), typeof window > "u"))
422
422
  return S;
423
423
  const e = Object.freeze({ register: j });
@@ -436,8 +436,8 @@ function Ze() {
436
436
  return S;
437
437
  }
438
438
  function j(...e) {
439
- return e = e.filter((n) => !O.has(n)), e.length ? (e.forEach((n) => Qe(n)), E.register?.forEach((n) => V(() => n(...e))), function() {
440
- e.forEach((t) => Je(t)), E.unregister?.forEach((t) => V(() => t(...e)));
439
+ return e = e.filter((n) => !O.has(n)), e.length ? (e.forEach((n) => Ye(n)), E.register?.forEach((n) => V(() => n(...e))), function() {
440
+ e.forEach((t) => Ze(t)), E.unregister?.forEach((t) => V(() => t(...e)));
441
441
  }) : () => {
442
442
  };
443
443
  }
@@ -469,7 +469,7 @@ class tn extends Event {
469
469
  bubbles: !1,
470
470
  cancelable: !1,
471
471
  composed: !1
472
- }), C.set(this, void 0), Ye(this, C, n, "f");
472
+ }), C.set(this, void 0), Qe(this, C, n, "f");
473
473
  }
474
474
  /** @deprecated */
475
475
  preventDefault() {
@@ -486,9 +486,9 @@ class tn extends Event {
486
486
  }
487
487
  C = /* @__PURE__ */ new WeakMap();
488
488
  const de = "bitcoin:connect", ue = "bitcoin:signTransaction", we = "bitcoin:signMessage", sn = ["bitcoin:events", "standard:events"];
489
- let Y;
489
+ let Q;
490
490
  function on(e) {
491
- return typeof window > "u" ? null : (Y ??= Ze(), Y.get().find(
491
+ return typeof window > "u" ? null : (Q ??= Je(), Q.get().find(
492
492
  (n) => e.test(n.name) && de in n.features && ue in n.features && we in n.features
493
493
  ) ?? null);
494
494
  }
@@ -672,7 +672,7 @@ async function mn(e, n) {
672
672
  return s;
673
673
  }
674
674
  async function fe(e, n, t) {
675
- const s = J(e);
675
+ const s = Z(e);
676
676
  let o = null;
677
677
  if (t.length !== 0) {
678
678
  const i = [];
@@ -826,7 +826,7 @@ async function Mn(e, n) {
826
826
  }
827
827
  async function me(e, n, t) {
828
828
  if (await T(), !window.unisat) throw new Error("UniSat not found.");
829
- const s = J(e);
829
+ const s = Z(e);
830
830
  let o = null;
831
831
  return t.length === 0 ? o = await window.unisat.signPsbt(s) : o = await window.unisat.signPsbt(s, ye(t)), n && (o = await window.unisat.pushPsbt(o)), o;
832
832
  }
@@ -1,4 +1,5 @@
1
1
  import { Brc20SendQuote, SendAsBrc20Args, SendAsBrc20ProgArgs, SendAsBrc20ProgResult, SendAsBrc20Result } from '../core/brc20-send';
2
+ import { TransactArgs, TransactResult } from '../core/brc20-transact';
2
3
  import { FrBtcResult, UnwrapBtcFromBrc20ProgArgs, WrapBtcToBrc20ProgArgs } from '../core/frbtc';
3
4
  import { BISWalletPurpose, PaymentOpts } from '../types/common';
4
5
  export type { Brc20AmountOptions, Brc20DeployOptions, Brc20PredeployOptions, Brc20PredeployResult, } from '../core/brc20-inscriptions';
@@ -44,6 +45,28 @@ export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs & {
44
45
  dryRun: false;
45
46
  }): Promise<SendAsBrc20ProgResult>;
46
47
  export declare function sendAsBrc20Prog(args: SendAsBrc20ProgArgs): Promise<Brc20SendQuote | SendAsBrc20ProgResult>;
48
+ export type { TransactArgs, TransactResult } from '../core/brc20-transact';
49
+ /**
50
+ * Inscribes a pre-signed legacy EVM transaction as a BRC2.0 `transact` op, so a signature made
51
+ * outside the kit (for example with a BRC2.0 EVM wallet) executes on BRC2.0. Only legacy (type 0)
52
+ * transactions carrying the BRC2.0 EIP-155 chain ID of the current network are accepted. The
53
+ * inscription is padded so its content bytes cover the transaction's gas limit, and its send
54
+ * transaction moves it to `OP_RETURN "BRC20PROG"`.
55
+ *
56
+ * With `dryRun: true` nothing is signed or broadcast and the result is a fee quote.
57
+ * `onSignRequest` is called before each wallet prompt with `{ step, total }`; `total` is 2.
58
+ *
59
+ * @param args - `rawTx` (signed legacy transaction hex, with or without `0x`), `feeRate` (sats/vB), `dryRun`, and optional `onSignRequest`.
60
+ * @returns The quote for a dry run; otherwise the inscription's transaction ids, every txid in chain order, and `txHash`, the BRC2.0 transaction hash (`keccak256(rawTx)`).
61
+ * @throws {Error} When `rawTx` is not a canonically encoded, low-s signed legacy transaction for this network's BRC2.0 chain, carries a non-zero value, sends to the zero address, its gas limit needs more inscription content than fits, or its nonce is below the signer's BRC2.0 account nonce or more than 9 above it, before anything is signed.
62
+ */
63
+ export declare function transact(args: TransactArgs & {
64
+ dryRun: true;
65
+ }): Promise<Brc20SendQuote>;
66
+ export declare function transact(args: TransactArgs & {
67
+ dryRun: false;
68
+ }): Promise<TransactResult>;
69
+ export declare function transact(args: TransactArgs): Promise<Brc20SendQuote | TransactResult>;
47
70
  export type { FrBtcResult, UnwrapBtcFromBrc20ProgArgs, WrapBtcToBrc20ProgArgs } from '../core/frbtc';
48
71
  export { getFrBtcAddress } from '../core/frbtc';
49
72
  /**
@@ -139,8 +162,7 @@ export interface InscribeAndSendToAddress {
139
162
  *
140
163
  * @param contractAddress The address of the smart contract to call.
141
164
  * @param calldataHex The calldata to send to the smart contract, encoded as a hexadecimal string.
142
- * @param estimatedGas The estimated amount of gas required for the transaction.
143
- * @param gasPerVbyte The gas cost per vbyte for the transaction.
165
+ * @param estimatedGas The gas the call needs. BRC2.0 grants 12000 gas per inscription content byte, so the kit pads the content with spaces until it grants at least this much.
144
166
  * @param feeRate The fee rate to use for the transaction, in satoshis per vbyte.
145
167
  * @param postage The amount of postage to include with the transaction, or null if no postage is needed.
146
168
  * @param dryRun A boolean indicating whether to perform a dry run of the transaction (i.e., simulate the transaction without actually sending it).
@@ -149,7 +171,7 @@ export interface InscribeAndSendToAddress {
149
171
  * @returns The result of the smart contract call, which may vary depending on the wallet type and the specifics of the transaction. The exact structure of the result will depend on the implementation of the callSmartContractFromOrdinalsWallet and callSmartContractFromPaymentWallet functions.
150
172
  * @throws An error if an unsupported wallet type is specified or if there is an issue with the smart contract call.
151
173
  */
152
- export declare function callSmartContract(contractAddress: string, calldataHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts, walletType?: BISWalletPurpose): Promise<InscribeAndSendToOpReturn>;
174
+ export declare function callSmartContract(contractAddress: string, calldataHex: string, estimatedGas: number, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts, walletType?: BISWalletPurpose): Promise<InscribeAndSendToOpReturn>;
153
175
  /**
154
176
  * Calls a smart contract function by encoding the function call with the provided ABI, function name, and parameters, and then invoking the callSmartContract function to execute the transaction. This function serves as a higher-level abstraction for calling smart contract functions, allowing developers to specify the function and parameters in a more intuitive way without needing to manually encode the calldata.
155
177
  *
@@ -157,9 +179,8 @@ export declare function callSmartContract(contractAddress: string, calldataHex:
157
179
  * @param abi The ABI (Application Binary Interface) of the smart contract, which defines the functions and their parameters for encoding the function call.
158
180
  * @param funcName The name of the function to call on the smart contract, which should be defined in the provided ABI.
159
181
  * @param params The parameters to pass to the smart contract function, which should be provided as an array and will be encoded according to the ABI specifications.
160
- * @param estimatedGas The estimated amount of gas required for the transaction, which is used to calculate the transaction fee and ensure that sufficient funds are available for the transaction to be processed.
161
- * @param gasPerVbyte The gas cost per vbyte for the transaction, which is used in conjunction with the estimated gas to calculate the total transaction fee.
162
- * @param feeRate The fee rate to use for the transaction, in satoshis per vbyte, which is used to calculate the total transaction fee based on the estimated gas and gas cost per vbyte.
182
+ * @param estimatedGas The gas the call needs. BRC2.0 grants 12000 gas per inscription content byte, so the kit pads the content with spaces until it grants at least this much.
183
+ * @param feeRate The fee rate to use for the transaction, in satoshis per vbyte.
163
184
  * @param postage The amount of postage to include with the transaction, or null if no postage is needed. Postage may be required for certain transactions to ensure that they are processed in a timely manner, especially during periods of high network congestion.
164
185
  * @param dryRun A boolean indicating whether to perform a dry run of the transaction (i.e., simulate the transaction without actually sending it). This can be useful for testing and debugging purposes to ensure that the function call is correctly encoded and that the transaction would succeed before actually sending it to the network.
165
186
  * @param paymentOpts Optional extra payment output: when `paymentOpts.paymentAmount` is greater than 0, the transaction sends that many sats to `paymentOpts.paymentAddress` (funded by the connected wallet — e.g. a service fee). Omit, or pass a non-positive amount, for no extra payment.
@@ -167,7 +188,40 @@ export declare function callSmartContract(contractAddress: string, calldataHex:
167
188
  * @returns The result of the smart contract call, which may vary depending on the wallet type and the specifics of the transaction. The exact structure of the result will depend on the implementation of the callSmartContractFromOrdinalsWallet and callSmartContractFromPaymentWallet functions, as well as the nature of the smart contract being called and the function being invoked.
168
189
  * @throws An error if the ABI is not an object, if the function name is not a string, if the parameters are not an array, if an unsupported wallet type is specified, or if there is an issue with the smart contract call.
169
190
  */
170
- export declare function callSmartContractAbi(contractAddress: string, abi: any, funcName: string, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts, walletType?: BISWalletPurpose): Promise<InscribeAndSendToOpReturn>;
191
+ export declare function callSmartContractAbi(contractAddress: string, abi: any, funcName: string, params: any, estimatedGas: number, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts, walletType?: BISWalletPurpose): Promise<InscribeAndSendToOpReturn>;
192
+ /**
193
+ * Deploys a smart contract on BRC2.0 from the ordinals identity. The deploy is inscribed from the
194
+ * ordinals address, so the contract's deployer is `getEvmAddressFromBitcoinAddress(ordinalsAddress)`.
195
+ *
196
+ * @param bytecodeHex - The contract creation bytecode, as a hexadecimal string.
197
+ * @param estimatedGas - The gas the deployment needs. BRC2.0 grants 12000 gas per inscription content byte, so the kit pads the content with spaces until it grants at least this much.
198
+ * @param feeRate - The fee rate in sats/vbyte, an integer.
199
+ * @param postage - The postage in sats for the inscription, or null for none.
200
+ * @param dryRun - If true, the transactions are signed or built but not broadcast.
201
+ * @param paymentOpts - Optional extra payment output: when `paymentOpts.paymentAmount` is greater than 0, the transaction sends that many sats to `paymentOpts.paymentAddress` (funded by the connected wallet). Omit, or pass a non-positive amount, for no extra payment.
202
+ *
203
+ * @returns The commit, reveal and send transaction ids and signed hexes, the inscription id, the postage and the secret.
204
+ * @throws {Error} When the broadcast request fails.
205
+ */
206
+ export declare function deploySmartContract(bytecodeHex: string, estimatedGas: number, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts): Promise<InscribeAndSendToOpReturn>;
207
+ /**
208
+ * Deploys a smart contract on BRC2.0 from the ordinals identity, encoding the bytecode with its
209
+ * constructor parameters from the ABI first. The deploy is inscribed from the ordinals address, so the
210
+ * contract's deployer is `getEvmAddressFromBitcoinAddress(ordinalsAddress)`.
211
+ *
212
+ * @param bytecode - The contract creation bytecode, as a hexadecimal string.
213
+ * @param abi - The contract ABI, used to encode the constructor parameters.
214
+ * @param params - The constructor parameters, encoded with the bytecode.
215
+ * @param estimatedGas - The gas the deployment needs. BRC2.0 grants 12000 gas per inscription content byte, so the kit pads the content with spaces until it grants at least this much.
216
+ * @param feeRate - The fee rate in sats/vbyte, an integer.
217
+ * @param postage - The postage in sats for the inscription, or null for none.
218
+ * @param dryRun - If true, the transactions are signed or built but not broadcast.
219
+ * @param paymentOpts - Optional extra payment output: when `paymentOpts.paymentAmount` is greater than 0, the transaction sends that many sats to `paymentOpts.paymentAddress` (funded by the connected wallet). Omit, or pass a non-positive amount, for no extra payment.
220
+ *
221
+ * @returns The commit, reveal and send transaction ids and signed hexes, the inscription id, the postage and the secret.
222
+ * @throws {Error} When the broadcast request fails.
223
+ */
224
+ export declare function deploySmartContractAbi(bytecode: string, abi: any, params: any[], estimatedGas: number, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts): Promise<InscribeAndSendToOpReturn>;
171
225
  /**
172
226
  * Deposits a BRC-20 token into the BRC2.0 programmable module by creating an inscription with the transfer operation and sending it to the OP_RETURN output. The function takes the token tick, amount, fee rate, and optional payment parameters, creates an inscription with the transfer operation, mints it, and then sends it to an OP_RETURN output with a specific format. It also allows for a dry run mode where the transaction hexes are returned without broadcasting.
173
227
  *
@@ -1,6 +1,6 @@
1
1
  import { WalletInfo } from '../types/wallet';
2
- export { getAllBalanceDetails, getCardinalBalance, getEndpoints, getOrdinalsWallet, getPaymentWallet, getProviders, getSession, sendBTC, sendInscription, setEndpoints, setNetwork, setProviders, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from '../core/bis';
3
- export type { AccountChangeEvent, Endpoints, EndpointsConfig, NetworkProviders, ProvidersConfig, } from '../core/bis';
2
+ export { getAllBalanceDetails, getCardinalBalance, getCardinalBalances, getEndpoints, getOrdinalsWallet, getPaymentWallet, getProviders, getSession, sendBTC, sendInscription, setEndpoints, setNetwork, setProviders, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from '../core/bis';
3
+ export type { AccountChangeEvent, CardinalBalances, Endpoints, EndpointsConfig, NetworkProviders, ProvidersConfig, } 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';
@@ -3,7 +3,8 @@ import { SendInscriptionResult } from '../types/inscription';
3
3
  import { WalletInfo } from '../types/wallet';
4
4
  export { getProviders, setProviders } from './chain-providers';
5
5
  export type { NetworkProviders, ProvidersConfig } from './chain-providers';
6
- export { getAllBalanceDetails, getCardinalBalance } from './helpers';
6
+ export { getAllBalanceDetails, getCardinalBalance, getCardinalBalances } from './helpers';
7
+ export type { CardinalBalances } from './helpers';
7
8
  export { getOrdinalsWallet, getPaymentWallet, sendBTC, signMessage, signMessageLocalVerify, signMessageLocalVerifyDeterministic, subscribeToAccountChanges, WalletAccountChangedError, } from './providers';
8
9
  export type { AccountChangeEvent } from './providers';
9
10
  export { getWalletInfo as getSession } from './store';
@@ -1,7 +1,9 @@
1
- import { SignProgressOptions } from './sign-progress';
2
1
  import { InscriptionDetails } from '../types/inscription';
2
+ import { SignProgressOptions } from './sign-progress';
3
3
  import { WalletInfo } from '../types/wallet';
4
+ import { GAS_PER_BYTE } from './brc20';
4
5
  import { assertFeeRate } from './mint';
6
+ export { GAS_PER_BYTE };
5
7
  /** The transactions of one inscribe-and-send step. */
6
8
  export interface Brc20SendPart {
7
9
  commitTxId: string;
@@ -34,7 +36,7 @@ export interface Brc20SendQuote {
34
36
  feeRate: number;
35
37
  steps: Brc20SendStepQuote[];
36
38
  }
37
- export type Brc20SendStepName = 'brc20Transfer' | 'progWithdraw' | 'progDeposit' | 'progTransfer' | 'frBtcWrap' | 'frBtcUnwrap';
39
+ export type Brc20SendStepName = 'brc20Transfer' | 'progWithdraw' | 'progDeposit' | 'progTransfer' | 'frBtcWrap' | 'frBtcUnwrap' | 'progTransact';
38
40
  /** An output the send transaction carries right after the target, at vout 1, 2, …. */
39
41
  export interface ChainExtraOutput {
40
42
  wallet: WalletInfo;
@@ -0,0 +1,58 @@
1
+ import { InscriptionDetails } from '../types/inscription';
2
+ import { Brc20SendPart, Brc20SendQuote } from './brc20-send';
3
+ import { SignProgressOptions } from './sign-progress';
4
+ /** Largest inscription content, in bytes, a transact inscription may be padded to. */
5
+ export declare const MAX_TRANSACT_CONTENT_BYTES = 350000;
6
+ /** The BRC2.0 EVM chain ID of the current network (signet and testnet share one). */
7
+ export declare function getBrc20ProgChainId(): bigint;
8
+ export interface ParsedLegacyTx {
9
+ /** `keccak256(rawTx)`, lowercase with `0x`. This is the BRC2.0 transaction hash. */
10
+ hash: string;
11
+ /** Recovered signer, lowercase with `0x`. */
12
+ from: string;
13
+ nonce: number;
14
+ /** Recipient, or null for a contract creation. */
15
+ to: string | null;
16
+ gasLimit: bigint;
17
+ chainId: bigint;
18
+ }
19
+ /**
20
+ * Parses a signed legacy (type 0) EVM transaction carrying the EIP-155 chain ID of the current
21
+ * network's BRC2.0 chain.
22
+ *
23
+ * The checks mirror what the BRC2.0 module accepts and executes: a canonical RLP encoding, a
24
+ * low-s signature, a value of 0 (the module runs every transaction with value 0), and no zero
25
+ * address recipient (the module treats it as a contract creation).
26
+ *
27
+ * @param rawTx Hex of the signed transaction, with or without `0x`, any case.
28
+ * @throws If the input is not valid hex, is unsigned, is not legacy, is not canonically encoded,
29
+ * has a high-s signature, targets another chain, carries a non-zero value, or sends to the zero
30
+ * address.
31
+ */
32
+ export declare function parseLegacyRawTx(rawTx: string): ParsedLegacyTx;
33
+ /**
34
+ * Builds a `brc20-prog` transact inscription for a signed legacy raw transaction. BRC2.0 grants
35
+ * `content bytes × GAS_PER_BYTE` gas, so the content is padded with spaces until it covers the
36
+ * transaction's gas limit.
37
+ */
38
+ export declare function transactInscription(rawTx: string): Promise<InscriptionDetails>;
39
+ export interface TransactArgs extends SignProgressOptions {
40
+ /** Signed legacy (type 0) EVM transaction, hex with or without 0x. */
41
+ rawTx: string;
42
+ feeRate: number;
43
+ dryRun: boolean;
44
+ }
45
+ export interface TransactResult {
46
+ /** The transact inscription's commit, reveal and send transactions. */
47
+ transact: Brc20SendPart;
48
+ /** BRC2.0 tx hash, keccak256(rawTx). */
49
+ txHash: string;
50
+ /** Every broadcast transaction id, in chain order. */
51
+ txIds: string[];
52
+ }
53
+ /**
54
+ * Inscribes a pre-signed legacy EVM transaction as a BRC2.0 `transact` op. The send transaction
55
+ * moves the inscription to `OP_RETURN "BRC20PROG"`, where the module executes the embedded
56
+ * transaction.
57
+ */
58
+ export declare function transact(args: TransactArgs): Promise<Brc20SendQuote | TransactResult>;
@@ -1,3 +1,5 @@
1
+ /** BRC2.0 grants each inscription `content bytes × GAS_PER_BYTE` gas. */
2
+ export declare const GAS_PER_BYTE = 12000;
1
3
  /**
2
4
  * Compresses the input hex string using both Zstd and Nada compression algorithms, and returns the shortest result encoded in base64 without padding.
3
5
  *
@@ -22,7 +24,6 @@ export declare function getEvmAddressFromPkScript(pkscript: string): string;
22
24
  *
23
25
  * @param inputHex - The input data for the smart contract deployment, represented as a hexadecimal string. This data will be compressed and included in the inscription.
24
26
  * @param estimatedGas - The estimated gas required for the smart contract deployment, used to determine if padding is needed for the inscription content.
25
- * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
26
27
  * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the deployment process.
27
28
  * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
28
29
  * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
@@ -31,7 +32,7 @@ export declare function getEvmAddressFromPkScript(pkscript: string): string;
31
32
  *
32
33
  * @returns An object containing details of the deployment process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
33
34
  */
34
- export declare function deploySmartContract(inputHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
35
+ export declare function deploySmartContract(inputHex: string, estimatedGas: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
35
36
  commitTxId: string;
36
37
  signedCommitTxHex: string;
37
38
  revealTxId: string;
@@ -49,7 +50,6 @@ export declare function deploySmartContract(inputHex: string, estimatedGas: numb
49
50
  * @param abi - The ABI of the smart contract, used to encode the deployment data along with the bytecode.
50
51
  * @param params - An array of parameters to be passed to the contract constructor, which will be encoded along with the bytecode using the ABI.
51
52
  * @param estimatedGas - The estimated gas required for the smart contract deployment, used to determine if padding is needed for the inscription content.
52
- * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
53
53
  * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the deployment process.
54
54
  * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
55
55
  * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
@@ -58,7 +58,7 @@ export declare function deploySmartContract(inputHex: string, estimatedGas: numb
58
58
  *
59
59
  * @returns An object containing details of the deployment process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
60
60
  */
61
- export declare function deploySmartContractAbi(bytecode: string, abi: any, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
61
+ export declare function deploySmartContractAbi(bytecode: string, abi: any, params: any, estimatedGas: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
62
62
  commitTxId: string;
63
63
  signedCommitTxHex: string;
64
64
  revealTxId: string;
@@ -75,7 +75,6 @@ export declare function deploySmartContractAbi(bytecode: string, abi: any, param
75
75
  * @param smartContractContractAddr - The address of the smart contract to call, represented as a string. This address will be included in the inscription content to indicate which contract function is being called.
76
76
  * @param inputHex - The input data for the smart contract function call, represented as a hexadecimal string. This data will be compressed and included in the inscription.
77
77
  * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
78
- * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
79
78
  * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
80
79
  * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
81
80
  * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
@@ -84,7 +83,7 @@ export declare function deploySmartContractAbi(bytecode: string, abi: any, param
84
83
  *
85
84
  * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
86
85
  */
87
- export declare function callSmartContract(smartContractContractAddr: string, inputHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
86
+ export declare function callSmartContract(smartContractContractAddr: string, inputHex: string, estimatedGas: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
88
87
  commitTxId: string;
89
88
  signedCommitTxHex: string;
90
89
  revealTxId: string;
@@ -103,7 +102,6 @@ export declare function callSmartContract(smartContractContractAddr: string, inp
103
102
  * @param funcName - The name of the function to call on the smart contract, represented as a string. This will be used along with the ABI to encode the function call data.
104
103
  * @param params - An array of parameters to be passed to the contract function, which will be encoded using the ABI along with the function name.
105
104
  * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
106
- * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
107
105
  * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
108
106
  * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
109
107
  * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
@@ -112,7 +110,7 @@ export declare function callSmartContract(smartContractContractAddr: string, inp
112
110
  *
113
111
  * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
114
112
  */
115
- export declare function callSmartContractAbi(smartContractContractAddr: string, abi: any, funcName: string, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
113
+ export declare function callSmartContractAbi(smartContractContractAddr: string, abi: any, funcName: string, params: any, estimatedGas: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
116
114
  commitTxId: string;
117
115
  signedCommitTxHex: string;
118
116
  revealTxId: string;
@@ -129,7 +127,6 @@ export declare function callSmartContractAbi(smartContractContractAddr: string,
129
127
  * @param smartContractContractAddr - The address of the smart contract to call, represented as a string. This address will be included in the inscription content to indicate which contract function is being called.
130
128
  * @param inputHex - The input data for the smart contract function call, represented as a hexadecimal string. This data will be compressed and included in the inscription.
131
129
  * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
132
- * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
133
130
  * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
134
131
  * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
135
132
  * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
@@ -139,7 +136,7 @@ export declare function callSmartContractAbi(smartContractContractAddr: string,
139
136
  * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
140
137
  * @throws Will throw an error if the wallet is not connected, if the input parameters are of incorrect types, or if there is a failure in creating or sending the inscription.
141
138
  */
142
- export declare function callSmartContractFromPaymentWallet(smartContractContractAddr: string, inputHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
139
+ export declare function callSmartContractFromPaymentWallet(smartContractContractAddr: string, inputHex: string, estimatedGas: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
143
140
  commitTxId: string;
144
141
  signedCommitTxHex: string;
145
142
  revealTxId: string;
@@ -158,7 +155,6 @@ export declare function callSmartContractFromPaymentWallet(smartContractContract
158
155
  * @param funcName - The name of the function to call on the smart contract, represented as a string. This will be used along with the ABI to encode the function call data.
159
156
  * @param params - An array of parameters to be passed to the contract function, which will be encoded using the ABI along with the function name.
160
157
  * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
161
- * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
162
158
  * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
163
159
  * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
164
160
  * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
@@ -167,7 +163,7 @@ export declare function callSmartContractFromPaymentWallet(smartContractContract
167
163
  *
168
164
  * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
169
165
  */
170
- export declare function callSmartContractAbiFromPaymentWallet(smartContractContractAddr: string, abi: any, funcName: string, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
166
+ export declare function callSmartContractAbiFromPaymentWallet(smartContractContractAddr: string, abi: any, funcName: string, params: any, estimatedGas: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
171
167
  commitTxId: string;
172
168
  signedCommitTxHex: string;
173
169
  revealTxId: string;
@@ -173,6 +173,30 @@ export declare function fetchCardinalUtxos(addr: string): Promise<Utxo[]>;
173
173
  * @returns The total balance of the address in satoshis.
174
174
  */
175
175
  export declare function getCardinalBalance(address: string): Promise<number>;
176
+ /** An address's spendable BTC, split by where it sits; see {@link getCardinalBalances}. */
177
+ export interface CardinalBalances {
178
+ /** Sats on cardinal UTXOs without inscriptions. */
179
+ plain: number;
180
+ /**
181
+ * Sats a transaction can take from the one UTXO with used BRC-20 inscriptions it would spend:
182
+ * what follows that UTXO's last inscribed sat, beyond a dust-sized set-aside output. 0 when no
183
+ * such UTXO has any.
184
+ */
185
+ recoverable: number;
186
+ /** The UTXO `recoverable` comes from, or `null`. */
187
+ recoverableUtxo: CardinalUtxoInfo | null;
188
+ }
189
+ /**
190
+ * Reads an address's spendable BTC as the transaction builders can spend it, with the saved extra
191
+ * transactions applied as in `getCardinalUtxos`: the cardinal UTXOs without inscriptions, plus the
192
+ * recoverable part of the single UTXO with used BRC-20 inscriptions a transaction would add when
193
+ * those run short. The inscribed sats themselves are never spendable, and the spending inputs' own
194
+ * fees are not subtracted.
195
+ *
196
+ * @param address The address for which to read the balances.
197
+ * @returns The plain and recoverable sats.
198
+ */
199
+ export declare function getCardinalBalances(address: string): Promise<CardinalBalances>;
176
200
  export interface AllBalanceDetails {
177
201
  confirmed_balance: number;
178
202
  mempool_balance: number;
@@ -59,7 +59,7 @@ interface BuildTransactionResult {
59
59
  */
60
60
  output_index: number[];
61
61
  }
62
- export declare function buildTransaction(utxoInfos: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, opReturnWallets: WalletInfo[], outputWallet: WalletInfo | null, changeWallet: WalletInfo, feeRate: number, amount: number, paymentWallet: WalletInfo | null, payment: number | null): BuildTransactionResult;
62
+ export declare function buildTransaction(utxoInfos: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, opReturnWallets: WalletInfo[], outputWallet: WalletInfo | null, changeWallet: WalletInfo, feeRate: number, amount: number, paymentWallet: WalletInfo | null, payment: number | null, minChange?: number): BuildTransactionResult;
63
63
  interface TransactionInOuts {
64
64
  ins: {
65
65
  hash: Buffer;
@@ -445,10 +445,11 @@ export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFe
445
445
  * @param payment - amount to pay (if payment is not null)
446
446
  * @param dryRun - if true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection
447
447
  * @param signFunc - function to sign the transactions
448
+ * @param minChange - change, in sats, the commit should leave for a later transaction (see `buildTransaction`)
448
449
  *
449
450
  * @returns an object containing the commit transaction ID, signed commit transaction hex, reveal transaction ID, signed reveal transaction hex, inscription ID, postage used, and the secret token used for minting
450
451
  */
451
- export declare function mintWithExtraInputInCommitAll(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean, signFunc: SignFunction): Promise<InscribeResult>;
452
+ export declare function mintWithExtraInputInCommitAll(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean, signFunc: SignFunction, minChange?: number): Promise<InscribeResult>;
452
453
  /**
453
454
  * Checks the fees for minting an inscription with extra input UTXOs included in the commit transaction by building the commit and reveal transactions without signing or broadcasting them. This function is useful for users who want to estimate the fees before actually minting the inscription with extra inputs. It returns the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used.
454
455
  *
@@ -459,8 +460,9 @@ export declare function mintWithExtraInputInCommitAll(inscriptionDetails: Inscri
459
460
  * @param paymentAddr - address to send the payment to (if payment is not null)
460
461
  * @param payment - amount to pay (if payment is not null)
461
462
  * @param fetchedCardinalUtxos - the payer's `fetchCardinalUtxos` response to fund the commit from in place of a new fetch
463
+ * @param minChange - change, in sats, the commit should leave for a later transaction (see `buildTransaction`)
462
464
  *
463
465
  * @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
464
466
  */
465
- export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: Utxo[]): Promise<InscribeCheckFeesResult>;
467
+ export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, fetchedCardinalUtxos?: Utxo[], minChange?: number): Promise<InscribeCheckFeesResult>;
466
468
  export {};
@@ -56,3 +56,20 @@ export declare function inscriptionsByOutput(inputs: {
56
56
  at: InscriptionAt[];
57
57
  whole: boolean;
58
58
  }[];
59
+ /** The dust limit of an output with this Bitcoin Core script type, in sats. */
60
+ export declare function dustForScriptType(scriptType?: string): number;
61
+ /**
62
+ * The BTC an output with used inscriptions can give a transaction, in sats: what follows its last
63
+ * inscribed sat, once a set-aside output (at least `dust`) has taken every inscribed sat. 0 for an
64
+ * output without inscriptions, with an inscription whose satpoint is unknown, or whose inscriptions
65
+ * reach its end. The spending input's own fee is not subtracted.
66
+ */
67
+ export declare function recoverableSats(utxo: InscribedFields, dust: number): number;
68
+ /**
69
+ * The output with used inscriptions that gives the most recoverable BTC (see `recoverableSats`), or
70
+ * `null` when none gives any. A transaction spends at most this one of them, so the clean BTC of
71
+ * the others never ends up behind its set-aside output.
72
+ */
73
+ export declare function bestRecoverable<T extends InscribedFields & {
74
+ script_type?: string;
75
+ }>(utxos: T[]): T | null;
package/dist/vue.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ref as s, onScopeDispose as u, watch as i } from "vue";
2
- import { e as r, Z as c, l as a } from "./helpers-BwuYuc7j.js";
2
+ import { f as r, _ as c, m as f } from "./helpers-DhmRTIg0.js";
3
3
  function w() {
4
- const o = s(r()), t = c((e) => {
5
- o.value !== e && (o.value = e);
4
+ const e = s(r()), t = c((o) => {
5
+ e.value !== o && (e.value = o);
6
6
  });
7
- return u(t, !0), i(o, (e) => {
8
- e !== r() && a(e);
9
- }), o;
7
+ return u(t, !0), i(e, (o) => {
8
+ o !== r() && f(o);
9
+ }), e;
10
10
  }
11
11
  export {
12
12
  w as useNetwork
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bestinslot/wallet-kit",
3
3
  "type": "module",
4
- "version": "0.15.0-rc.7",
4
+ "version": "0.15.0",
5
5
  "private": false,
6
6
  "description": "A lightweight JavaScript library for connecting Bitcoin wallets with a unified API.",
7
7
  "license": "MIT",