@arkade-os/sdk 0.4.32 → 0.4.34

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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/adapters/indexedDB.cjs +5 -5
  7. package/dist/adapters/indexedDB.js +4 -4
  8. package/dist/{ark-ibLW4Hte.d.cts → ark-Dsv5Jq4E.d.cts} +81 -10
  9. package/dist/{ark-ibLW4Hte.d.ts → ark-Dsv5Jq4E.d.ts} +81 -10
  10. package/dist/{asyncStorageTaskQueue-BEOFPNc0.d.ts → asyncStorageTaskQueue-BH-zuth5.d.ts} +1 -1
  11. package/dist/{asyncStorageTaskQueue-VGHXWR9F.d.cts → asyncStorageTaskQueue-D92ch8yI.d.cts} +1 -1
  12. package/dist/{chunk-ABWRLTX5.js → chunk-5WDBHWX3.js} +4 -4
  13. package/dist/{chunk-ABWRLTX5.js.map → chunk-5WDBHWX3.js.map} +1 -1
  14. package/dist/{chunk-GIGILVVP.cjs → chunk-CCLNFHJ5.cjs} +11 -11
  15. package/dist/{chunk-GIGILVVP.cjs.map → chunk-CCLNFHJ5.cjs.map} +1 -1
  16. package/dist/{chunk-WMIPYZSB.cjs → chunk-CMPJR3HS.cjs} +42 -9
  17. package/dist/chunk-CMPJR3HS.cjs.map +1 -0
  18. package/dist/{chunk-YA4G7RFB.js → chunk-CUSABEUQ.js} +166 -38
  19. package/dist/chunk-CUSABEUQ.js.map +1 -0
  20. package/dist/{chunk-6FLL2Q36.cjs → chunk-FSAXPBGP.cjs} +9 -9
  21. package/dist/chunk-FSAXPBGP.cjs.map +1 -0
  22. package/dist/{chunk-6NWNOLL3.js → chunk-FXFBPXV3.js} +4 -4
  23. package/dist/chunk-FXFBPXV3.js.map +1 -0
  24. package/dist/{chunk-IEO3XDKI.cjs → chunk-GUTKJMSF.cjs} +190 -58
  25. package/dist/chunk-GUTKJMSF.cjs.map +1 -0
  26. package/dist/{chunk-XROGFOPX.js → chunk-HFXEUW55.js} +740 -175
  27. package/dist/chunk-HFXEUW55.js.map +1 -0
  28. package/dist/{chunk-TU3LVAPX.js → chunk-OUVTG72A.js} +43 -11
  29. package/dist/chunk-OUVTG72A.js.map +1 -0
  30. package/dist/{chunk-SHEBNWOQ.js → chunk-VVGD3JIP.js} +3 -3
  31. package/dist/{chunk-SHEBNWOQ.js.map → chunk-VVGD3JIP.js.map} +1 -1
  32. package/dist/{chunk-KQK4PP6L.cjs → chunk-XCHBQVMK.cjs} +879 -314
  33. package/dist/chunk-XCHBQVMK.cjs.map +1 -0
  34. package/dist/{chunk-I2UIKZM5.cjs → chunk-ZS3OZHC7.cjs} +7 -7
  35. package/dist/{chunk-I2UIKZM5.cjs.map → chunk-ZS3OZHC7.cjs.map} +1 -1
  36. package/dist/contracts/handlers/index.cjs +10 -6
  37. package/dist/contracts/handlers/index.d.cts +3 -3
  38. package/dist/contracts/handlers/index.d.ts +3 -3
  39. package/dist/contracts/handlers/index.js +2 -2
  40. package/dist/{delegate-BvNTw44a.d.cts → delegate-BaS5SCIW.d.cts} +10 -2
  41. package/dist/{delegate-BXaR1RNG.d.ts → delegate-Baz_hb83.d.ts} +10 -2
  42. package/dist/{index-BusKawmy.d.ts → index-FwXZveaX.d.ts} +63 -3
  43. package/dist/{index-C-5Tw7VA.d.cts → index-lNZ6qaO3.d.cts} +63 -3
  44. package/dist/index.cjs +143 -127
  45. package/dist/index.d.cts +89 -16
  46. package/dist/index.d.ts +89 -16
  47. package/dist/index.js +4 -4
  48. package/dist/repositories/realm/index.cjs +13 -13
  49. package/dist/repositories/realm/index.d.cts +1 -1
  50. package/dist/repositories/realm/index.d.ts +1 -1
  51. package/dist/repositories/realm/index.js +4 -4
  52. package/dist/repositories/sqlite/index.cjs +13 -13
  53. package/dist/repositories/sqlite/index.d.cts +1 -1
  54. package/dist/repositories/sqlite/index.d.ts +1 -1
  55. package/dist/repositories/sqlite/index.js +4 -4
  56. package/dist/{taskRunner-B1igKGAo.d.ts → taskRunner-B1NUWyWR.d.ts} +1 -1
  57. package/dist/{taskRunner-By92TQ1m.d.cts → taskRunner-vFRA3F9b.d.cts} +1 -1
  58. package/dist/wallet/expo/background.cjs +14 -14
  59. package/dist/wallet/expo/background.d.cts +3 -3
  60. package/dist/wallet/expo/background.d.ts +3 -3
  61. package/dist/wallet/expo/background.js +6 -6
  62. package/dist/wallet/expo/index.cjs +14 -14
  63. package/dist/wallet/expo/index.cjs.map +1 -1
  64. package/dist/wallet/expo/index.d.cts +5 -5
  65. package/dist/wallet/expo/index.d.ts +5 -5
  66. package/dist/wallet/expo/index.js +6 -6
  67. package/dist/wallet/expo/index.js.map +1 -1
  68. package/dist/{wallet-B_rxgQTu.d.cts → wallet-By9HIo0Q.d.cts} +160 -5
  69. package/dist/{wallet-CyM4F7Bs.d.ts → wallet-D6uoBLmS.d.ts} +160 -5
  70. package/dist/worker/expo/index.cjs +9 -9
  71. package/dist/worker/expo/index.d.cts +4 -4
  72. package/dist/worker/expo/index.d.ts +4 -4
  73. package/dist/worker/expo/index.js +5 -5
  74. package/package.json +4 -4
  75. package/dist/chunk-6FLL2Q36.cjs.map +0 -1
  76. package/dist/chunk-6NWNOLL3.js.map +0 -1
  77. package/dist/chunk-IEO3XDKI.cjs.map +0 -1
  78. package/dist/chunk-KQK4PP6L.cjs.map +0 -1
  79. package/dist/chunk-TU3LVAPX.js.map +0 -1
  80. package/dist/chunk-WMIPYZSB.cjs.map +0 -1
  81. package/dist/chunk-XROGFOPX.js.map +0 -1
  82. package/dist/chunk-YA4G7RFB.js.map +0 -1
package/README.md CHANGED
@@ -228,7 +228,7 @@ If you don't pass a provider explicitly, `OnchainWallet` and `Wallet.create({ ..
228
228
 
229
229
  #### Default URLs
230
230
 
231
- The SDK ships with reachable defaults for each network — bitcoin, signet, and mutinynet point at Ark Labs–operated deployments; testnet falls back to mempool.space; regtest assumes a local nigiri stack.
231
+ The SDK ships with reachable defaults for each network — bitcoin, signet, and mutinynet point at Ark Labs–operated deployments; testnet falls back to mempool.space; regtest assumes a local [arkade-regtest](https://github.com/ArkLabsHQ/arkade-regtest) stack (esplora API on `http://localhost:3000/api`).
232
232
 
233
233
  ```typescript
234
234
  import {
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkGIGILVVP_cjs = require('../chunk-GIGILVVP.cjs');
4
- require('../chunk-6FLL2Q36.cjs');
5
- require('../chunk-WMIPYZSB.cjs');
3
+ var chunkCCLNFHJ5_cjs = require('../chunk-CCLNFHJ5.cjs');
4
+ require('../chunk-FSAXPBGP.cjs');
5
+ require('../chunk-CMPJR3HS.cjs');
6
6
  require('../chunk-5BLDMQED.cjs');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "ExpoArkProvider", {
11
11
  enumerable: true,
12
- get: function () { return chunkGIGILVVP_cjs.ExpoArkProvider; }
12
+ get: function () { return chunkCCLNFHJ5_cjs.ExpoArkProvider; }
13
13
  });
14
14
  Object.defineProperty(exports, "ExpoIndexerProvider", {
15
15
  enumerable: true,
16
- get: function () { return chunkGIGILVVP_cjs.ExpoIndexerProvider; }
16
+ get: function () { return chunkCCLNFHJ5_cjs.ExpoIndexerProvider; }
17
17
  });
18
18
  //# sourceMappingURL=expo.cjs.map
19
19
  //# sourceMappingURL=expo.cjs.map
@@ -1,5 +1,5 @@
1
- import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-ibLW4Hte.cjs';
2
- export { m as ArkProvider, n as IndexerProvider } from '../ark-ibLW4Hte.cjs';
1
+ import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-Dsv5Jq4E.cjs';
2
+ export { m as ArkProvider, n as IndexerProvider } from '../ark-Dsv5Jq4E.cjs';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
@@ -1,5 +1,5 @@
1
- import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-ibLW4Hte.js';
2
- export { m as ArkProvider, n as IndexerProvider } from '../ark-ibLW4Hte.js';
1
+ import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-Dsv5Jq4E.js';
2
+ export { m as ArkProvider, n as IndexerProvider } from '../ark-Dsv5Jq4E.js';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
@@ -1,6 +1,6 @@
1
- export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-ABWRLTX5.js';
2
- import '../chunk-6NWNOLL3.js';
3
- import '../chunk-TU3LVAPX.js';
1
+ export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-5WDBHWX3.js';
2
+ import '../chunk-FXFBPXV3.js';
3
+ import '../chunk-OUVTG72A.js';
4
4
  import '../chunk-NSBPE2FW.js';
5
5
  //# sourceMappingURL=expo.js.map
6
6
  //# sourceMappingURL=expo.js.map
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkKQK4PP6L_cjs = require('../chunk-KQK4PP6L.cjs');
4
- require('../chunk-6FLL2Q36.cjs');
5
- require('../chunk-IEO3XDKI.cjs');
6
- require('../chunk-WMIPYZSB.cjs');
3
+ var chunkXCHBQVMK_cjs = require('../chunk-XCHBQVMK.cjs');
4
+ require('../chunk-FSAXPBGP.cjs');
5
+ require('../chunk-GUTKJMSF.cjs');
6
+ require('../chunk-CMPJR3HS.cjs');
7
7
  require('../chunk-5BLDMQED.cjs');
8
8
 
9
9
  // src/storage/indexedDB.ts
@@ -11,7 +11,7 @@ var IndexedDBStorageAdapter = class {
11
11
  dbName;
12
12
  version;
13
13
  db = null;
14
- constructor(dbName, version = chunkKQK4PP6L_cjs.DB_VERSION) {
14
+ constructor(dbName, version = chunkXCHBQVMK_cjs.DB_VERSION) {
15
15
  this.dbName = dbName;
16
16
  this.version = version;
17
17
  }
@@ -1,7 +1,7 @@
1
- import { DB_VERSION } from '../chunk-XROGFOPX.js';
2
- import '../chunk-6NWNOLL3.js';
3
- import '../chunk-YA4G7RFB.js';
4
- import '../chunk-TU3LVAPX.js';
1
+ import { DB_VERSION } from '../chunk-HFXEUW55.js';
2
+ import '../chunk-FXFBPXV3.js';
3
+ import '../chunk-CUSABEUQ.js';
4
+ import '../chunk-OUVTG72A.js';
5
5
  import '../chunk-NSBPE2FW.js';
6
6
 
7
7
  // src/storage/indexedDB.ts
@@ -153,14 +153,27 @@ interface SignRequest {
153
153
  * should implement this interface to reduce the number of confirmation popups
154
154
  * from N+1 to 1 during Arkade send transactions.
155
155
  *
156
- * Contract: implementations MUST return exactly one `Transaction` per request,
157
- * in the same order as the input array. The SDK validates this at runtime and
158
- * will throw if the lengths do not match.
156
+ * Contract:
157
+ * - Implementations MUST return exactly one `Transaction` per request, in the
158
+ * same order as the input array. The SDK validates this at runtime and will
159
+ * throw if the lengths do not match.
160
+ * - Implementations MUST preserve any partial signatures already present on the
161
+ * input PSBTs and only ADD their own — never drop, replace, or normalize away
162
+ * foreign signatures. The pending-tx recovery path
163
+ * (`Wallet.finalizePendingTxs`) hands `signMultiple` checkpoint PSBTs that
164
+ * already carry the server's `tapScriptSig` and relies on that server
165
+ * signature surviving alongside the freshly added user signature. A provider
166
+ * that discards the pre-existing server sig produces checkpoints that fail
167
+ * server-side finalization, stranding the transaction in the pending state.
159
168
  */
160
169
  interface BatchSignableIdentity extends Identity {
161
170
  /**
162
171
  * Sign multiple transactions in a single wallet interaction.
163
172
  *
173
+ * Must preserve pre-existing partial signatures on each input PSBT (see the
174
+ * interface-level contract) and return one signed `Transaction` per request,
175
+ * in request order.
176
+ *
164
177
  * @param requests - Transactions and optional input indexes to sign
165
178
  * @returns Signed transactions in the same order as the input requests
166
179
  */
@@ -441,6 +454,12 @@ declare class VtxoScript {
441
454
  /**
442
455
  * Create a virtual output script from its tapleaf scripts.
443
456
  *
457
+ * The Taproot script tree is assembled using btcd's algorithm
458
+ * (`txscript.AssembleTaprootScriptTree`) so the derived taproot output
459
+ * key agrees with arkd for any leaf count. `@scure/btc-signer`'s
460
+ * default `taprootListToTree` is a Huffman builder that only agrees
461
+ * with arkd for power-of-2 leaf counts.
462
+ *
444
463
  * @param scripts - Raw tapscript bytes for each leaf
445
464
  * @throws Error if the provided leaves cannot produce a valid Taproot tree
446
465
  */
@@ -880,16 +899,12 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
880
899
  private getBoardingTimelock;
881
900
  /** Returns the TapLeafScript for the boarding tapscript's exit (CSV) path. */
882
901
  private getBoardingExitLeaf;
883
- /** Returns the pkScript (output script) of the boarding tapscript. */
884
- private getBoardingOutputScript;
885
902
  /** Returns the onchain provider for fee estimation and broadcasting. */
886
903
  private getOnchainProvider;
887
904
  /** Returns the Ark provider for intent fee and server info lookups. */
888
905
  private getArkProvider;
889
906
  /** Returns the Bitcoin network configuration from the wallet. */
890
907
  private getNetwork;
891
- /** Returns the wallet's identity for transaction signing. */
892
- private getIdentity;
893
908
  private initializeSubscription;
894
909
  /**
895
910
  * VTXO_ALREADY_SPENT means the server's authoritative view of VTXO state
@@ -981,8 +996,8 @@ declare const networks: {
981
996
  * Mainnet, mutinynet, and signet point at Ark Labs–operated
982
997
  * mempool deployments (mempool.space-compatible esplora API).
983
998
  * Testnet falls back to the public mempool.space deployment
984
- * because Ark doesn't host it. Regtest assumes a local nigiri
985
- * stack on the standard port.
999
+ * because Ark doesn't host it. Regtest assumes a local arkade-regtest
1000
+ * stack exposing mempool's esplora API on the standard port.
986
1001
  */
987
1002
  declare const ESPLORA_URL: Record<NetworkName, string>;
988
1003
  type ExplorerTransaction = {
@@ -1268,6 +1283,14 @@ interface ScanResult {
1268
1283
  interface ScanContractsOptions {
1269
1284
  /** Default 20. A non-positive / non-integer value throws. */
1270
1285
  gapLimit?: number;
1286
+ /**
1287
+ * Number of HD indices probed concurrently per window (default
1288
+ * {@link DEFAULT_SCAN_BATCH}). Pure latency knob: the gap loop stays
1289
+ * gap-limit bounded and the discovered set is identical regardless of
1290
+ * batch size. A non-positive / non-integer value throws. Ignored when
1291
+ * `hd` is false (the static pass probes only index 0).
1292
+ */
1293
+ batchSize?: number;
1271
1294
  /** HD mode → unbounded gap loop guided by the gap counter; false → probe only index 0 (single static pass). */
1272
1295
  hd: boolean;
1273
1296
  /**
@@ -1568,6 +1591,19 @@ declare class ContractManager implements IContractManager {
1568
1591
  * other handler hit it).
1569
1592
  * - `persistAndWatchContract` rejecting is operational/fatal and
1570
1593
  * propagates (only `discoverAt` is guarded).
1594
+ * - Within an index the handler probes run concurrently (independent
1595
+ * network reads); their hits are persisted sequentially in
1596
+ * `discoverables` order to preserve the first-wins collision tie-break.
1597
+ * - Indices are probed `batchSize` at a time (a second concurrency layer
1598
+ * over the per-index probes), but each window is CAPPED to
1599
+ * `gapLimit - unused` indices — the most a serial scan could still reach
1600
+ * before the gap window is guaranteed to close. So every index probed in
1601
+ * a window is one a one-index-at-a-time scan would also reach: nothing is
1602
+ * over-scanned, nothing is discarded, and `materialize`/`discoverAt` are
1603
+ * invoked on exactly the same index set. The window's hits are still
1604
+ * processed strictly in ascending index order, so the discovered set,
1605
+ * persisted rows, `lastIndexUsed`, and `handlerErrors` are byte-for-byte
1606
+ * identical to the serial path — only the wall-clock differs.
1571
1607
  */
1572
1608
  scanContracts(opts: ScanContractsOptions): Promise<ScanResult>;
1573
1609
  /**
@@ -1945,12 +1981,47 @@ interface DiscoveredContract {
1945
1981
  interface DiscoveryDeps {
1946
1982
  indexerProvider: IndexerProvider;
1947
1983
  onchainProvider: OnchainProvider;
1984
+ /**
1985
+ * Ark-address network data. The `{ hrp }` shape is all the L2
1986
+ * (`default`/`delegate`) discovery path needs to render an Ark address.
1987
+ */
1948
1988
  network: {
1949
1989
  hrp: string;
1950
1990
  };
1991
+ /**
1992
+ * Full Bitcoin network descriptor for on-chain (P2TR) address
1993
+ * rendering. Required by the boarding discovery probe, which derives an
1994
+ * on-chain Taproot address via {@link VtxoScript.onchainAddress} — the
1995
+ * `{ hrp }`-only {@link DiscoveryDeps.network} lacks the `bech32` data
1996
+ * that needs. Absent only when no boarding discovery is plumbed (e.g.
1997
+ * the scanner unit harness), in which case boarding `discoverAt` no-ops.
1998
+ */
1999
+ onchainNetwork?: Network;
2000
+ /**
2001
+ * The server's **current** signer key (x-only, 32 bytes), taken from a
2002
+ * fresh server-info snapshot at restore time. L2 (`default`/`delegate`)
2003
+ * discovery probes this key first.
2004
+ */
1951
2005
  serverPubKey: Uint8Array;
2006
+ /**
2007
+ * The server's **deprecated** signer keys (x-only, 32 bytes) from the same
2008
+ * snapshot. A VTXO minted under a now-rotated signer is anchored to a
2009
+ * different script; L2 discovery scans these keys alongside
2010
+ * {@link DiscoveryDeps.serverPubKey} so signer rotation does not strand
2011
+ * funds. Empty/absent when the server advertises no deprecated signers.
2012
+ * Boarding discovery does not consult this set (current UTXO set only).
2013
+ */
2014
+ deprecatedSignerPubKeys?: Uint8Array[];
1952
2015
  /** Relative timelocks the wallet treats as its baseline matrix. */
1953
2016
  csvTimelocks: RelativeTimelock[];
2017
+ /**
2018
+ * Boarding-exit CSV timelock. Distinct from {@link DiscoveryDeps.csvTimelocks}
2019
+ * (the unilateral-exit matrix): boarding scripts source their CSV from the
2020
+ * server's boarding-exit delay. Present only when boarding discovery is
2021
+ * plumbed; when absent, boarding `discoverAt` no-ops (so the scanner unit
2022
+ * harness, which never sets it, is unaffected).
2023
+ */
2024
+ boardingTimelock?: RelativeTimelock;
1954
2025
  /** Present only for delegate wallets. */
1955
2026
  delegatePubKey?: Uint8Array;
1956
2027
  }
@@ -3906,4 +3977,4 @@ declare namespace ProtoTypes {
3906
3977
  export { };
3907
3978
  }
3908
3979
 
3909
- export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type HandlerError as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type Asset as aA, type AssetMetadata as aB, type BaseWalletConfig as aC, type BatchInfo as aD, type BatchSignableIdentity as aE, CLTVMultisigTapscript as aF, ChainTxType as aG, type CommitmentTx as aH, ConditionCSVMultisigTapscript as aI, ConditionMultisigTapscript as aJ, type ContractBalance as aK, type ContractEventCallback as aL, type ContractHandler as aM, type ContractManagerConfig as aN, type ContractState as aO, type ContractVtxo as aP, ContractWatcher as aQ, DelegateManagerImpl as aR, type DelegateOptions as aS, DelegatorManagerImpl as aT, type DelegatorProvider as aU, type Discoverable as aV, type DiscoveredContract as aW, type DiscoveryDeps as aX, ESPLORA_URL as aY, EsploraProvider as aZ, type ExtendedContractVtxo as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type RenewVtxosOptions as al, type ContractWithVtxos as am, type PathSelection as an, type ContractEvent as ao, type AssetDetails as ap, type IssuanceResult as aq, type DelegateInfo as ar, type StorageConfig as as, type IVtxoManager as at, type ExplorerTransaction as au, type EncodedVtxoScript as av, type Status as aw, type Outpoint as ax, type ChainTx as ay, type ArkTapscript as az, type WalletConfig as b, type IDelegatorManager as b0, IndexerTxType as b1, type KnownMetadata as b2, MultisigTapscript as b3, type Nonces as b4, type Output as b5, type PageResponse as b6, type PaginationOptions as b7, PartialSig as b8, type PathContext as b9, getSequence as bA, isBatchSignable as bB, isDiscoverable as bC, isExpired as bD, isRecoverable as bE, isSpendable as bF, isSubdust as bG, isVtxoExpiringSoon as bH, networks as bI, type ProviderClass as ba, RestDelegateProvider as bb, RestDelegatorProvider as bc, type ScanContractsOptions as bd, type ScanResult as be, type ScheduledSession as bf, SettlementEventType as bg, type SignRequest as bh, type SubscriptionEvent as bi, type SubscriptionHeartbeat as bj, type TapLeaves as bk, TapTreeCoder as bl, TapscriptType as bm, type TreeNonces as bn, type TreePartialSigs as bo, type Tx as bp, type TxHistoryRecord as bq, type TxKey as br, type TxTreeNode as bs, TxType as bt, type VirtualStatus as bu, type Vtxo as bv, type VtxoChain as bw, type VtxoType as bx, type WalletMode as by, decodeTapscript as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };
3980
+ export { type SignerSession as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type DescriptorProvider as D, type ExtendedVirtualCoin as E, type IReadonlyWallet as F, type GetVtxosFilter as G, type ReadonlyIdentity as H, type IWallet as I, type DelegateProvider as J, type ReadonlyWalletConfig as K, type IReadonlyAssetManager as L, type NetworkName as M, type Network as N, type OnchainProvider as O, type ArkInfo as P, ArkAddress as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type Coin as U, VtxoScript as V, type WalletRepository as W, ContractManager as X, CSVMultisigTapscript as Y, type SettlementConfig as Z, VtxoManager as _, type Identity as a, type ExtendedContractVtxo as a$, type SignedIntent as a0, Intent as a1, type VtxoRepositoryKey as a2, type WalletState as a3, type ContractFilter as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type ArkTapscript as aA, type Asset as aB, type AssetMetadata as aC, type BaseWalletConfig as aD, type BatchInfo as aE, type BatchSignableIdentity as aF, CLTVMultisigTapscript as aG, ChainTxType as aH, type CommitmentTx as aI, ConditionCSVMultisigTapscript as aJ, ConditionMultisigTapscript as aK, type ContractBalance as aL, type ContractEventCallback as aM, type ContractHandler as aN, type ContractManagerConfig as aO, type ContractState as aP, type ContractVtxo as aQ, ContractWatcher as aR, DelegateManagerImpl as aS, type DelegateOptions as aT, DelegatorManagerImpl as aU, type DelegatorProvider as aV, type Discoverable as aW, type DiscoveredContract as aX, type DiscoveryDeps as aY, ESPLORA_URL as aZ, EsploraProvider as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type RenewVtxosOptions as al, type ContractWithVtxos as am, type PathSelection as an, type ContractEvent as ao, type AssetDetails as ap, type IssuanceResult as aq, type DelegateInfo as ar, type StorageConfig as as, type IVtxoManager as at, type ExplorerTransaction as au, type EncodedVtxoScript as av, type Status as aw, type Outpoint as ax, type ChainTx as ay, type PathContext as az, type WalletConfig as b, type HandlerError as b0, type IDelegatorManager as b1, IndexerTxType as b2, type KnownMetadata as b3, MultisigTapscript as b4, type Nonces as b5, type Output as b6, type PageResponse as b7, type PaginationOptions as b8, PartialSig as b9, getSequence as bA, isBatchSignable as bB, isDiscoverable as bC, isExpired as bD, isRecoverable as bE, isSpendable as bF, isSubdust as bG, isVtxoExpiringSoon as bH, networks as bI, type ProviderClass as ba, RestDelegateProvider as bb, RestDelegatorProvider as bc, type ScanContractsOptions as bd, type ScanResult as be, type ScheduledSession as bf, SettlementEventType as bg, type SignRequest as bh, type SubscriptionEvent as bi, type SubscriptionHeartbeat as bj, type TapLeaves as bk, TapTreeCoder as bl, TapscriptType as bm, type TreeNonces as bn, type TreePartialSigs as bo, type Tx as bp, type TxHistoryRecord as bq, type TxKey as br, type TxTreeNode as bs, TxType as bt, type VirtualStatus as bu, type Vtxo as bv, type VtxoChain as bw, type VtxoType as bx, type WalletMode as by, decodeTapscript as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type TreeSigningStartedEvent as s, TxTree as t, type TreeNoncesEvent as u, type BatchFinalizationEvent as v, type BatchFinalizedEvent as w, type BatchFailedEvent as x, type TreeTxEvent as y, type TreeSignatureEvent as z };
@@ -153,14 +153,27 @@ interface SignRequest {
153
153
  * should implement this interface to reduce the number of confirmation popups
154
154
  * from N+1 to 1 during Arkade send transactions.
155
155
  *
156
- * Contract: implementations MUST return exactly one `Transaction` per request,
157
- * in the same order as the input array. The SDK validates this at runtime and
158
- * will throw if the lengths do not match.
156
+ * Contract:
157
+ * - Implementations MUST return exactly one `Transaction` per request, in the
158
+ * same order as the input array. The SDK validates this at runtime and will
159
+ * throw if the lengths do not match.
160
+ * - Implementations MUST preserve any partial signatures already present on the
161
+ * input PSBTs and only ADD their own — never drop, replace, or normalize away
162
+ * foreign signatures. The pending-tx recovery path
163
+ * (`Wallet.finalizePendingTxs`) hands `signMultiple` checkpoint PSBTs that
164
+ * already carry the server's `tapScriptSig` and relies on that server
165
+ * signature surviving alongside the freshly added user signature. A provider
166
+ * that discards the pre-existing server sig produces checkpoints that fail
167
+ * server-side finalization, stranding the transaction in the pending state.
159
168
  */
160
169
  interface BatchSignableIdentity extends Identity {
161
170
  /**
162
171
  * Sign multiple transactions in a single wallet interaction.
163
172
  *
173
+ * Must preserve pre-existing partial signatures on each input PSBT (see the
174
+ * interface-level contract) and return one signed `Transaction` per request,
175
+ * in request order.
176
+ *
164
177
  * @param requests - Transactions and optional input indexes to sign
165
178
  * @returns Signed transactions in the same order as the input requests
166
179
  */
@@ -441,6 +454,12 @@ declare class VtxoScript {
441
454
  /**
442
455
  * Create a virtual output script from its tapleaf scripts.
443
456
  *
457
+ * The Taproot script tree is assembled using btcd's algorithm
458
+ * (`txscript.AssembleTaprootScriptTree`) so the derived taproot output
459
+ * key agrees with arkd for any leaf count. `@scure/btc-signer`'s
460
+ * default `taprootListToTree` is a Huffman builder that only agrees
461
+ * with arkd for power-of-2 leaf counts.
462
+ *
444
463
  * @param scripts - Raw tapscript bytes for each leaf
445
464
  * @throws Error if the provided leaves cannot produce a valid Taproot tree
446
465
  */
@@ -880,16 +899,12 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
880
899
  private getBoardingTimelock;
881
900
  /** Returns the TapLeafScript for the boarding tapscript's exit (CSV) path. */
882
901
  private getBoardingExitLeaf;
883
- /** Returns the pkScript (output script) of the boarding tapscript. */
884
- private getBoardingOutputScript;
885
902
  /** Returns the onchain provider for fee estimation and broadcasting. */
886
903
  private getOnchainProvider;
887
904
  /** Returns the Ark provider for intent fee and server info lookups. */
888
905
  private getArkProvider;
889
906
  /** Returns the Bitcoin network configuration from the wallet. */
890
907
  private getNetwork;
891
- /** Returns the wallet's identity for transaction signing. */
892
- private getIdentity;
893
908
  private initializeSubscription;
894
909
  /**
895
910
  * VTXO_ALREADY_SPENT means the server's authoritative view of VTXO state
@@ -981,8 +996,8 @@ declare const networks: {
981
996
  * Mainnet, mutinynet, and signet point at Ark Labs–operated
982
997
  * mempool deployments (mempool.space-compatible esplora API).
983
998
  * Testnet falls back to the public mempool.space deployment
984
- * because Ark doesn't host it. Regtest assumes a local nigiri
985
- * stack on the standard port.
999
+ * because Ark doesn't host it. Regtest assumes a local arkade-regtest
1000
+ * stack exposing mempool's esplora API on the standard port.
986
1001
  */
987
1002
  declare const ESPLORA_URL: Record<NetworkName, string>;
988
1003
  type ExplorerTransaction = {
@@ -1268,6 +1283,14 @@ interface ScanResult {
1268
1283
  interface ScanContractsOptions {
1269
1284
  /** Default 20. A non-positive / non-integer value throws. */
1270
1285
  gapLimit?: number;
1286
+ /**
1287
+ * Number of HD indices probed concurrently per window (default
1288
+ * {@link DEFAULT_SCAN_BATCH}). Pure latency knob: the gap loop stays
1289
+ * gap-limit bounded and the discovered set is identical regardless of
1290
+ * batch size. A non-positive / non-integer value throws. Ignored when
1291
+ * `hd` is false (the static pass probes only index 0).
1292
+ */
1293
+ batchSize?: number;
1271
1294
  /** HD mode → unbounded gap loop guided by the gap counter; false → probe only index 0 (single static pass). */
1272
1295
  hd: boolean;
1273
1296
  /**
@@ -1568,6 +1591,19 @@ declare class ContractManager implements IContractManager {
1568
1591
  * other handler hit it).
1569
1592
  * - `persistAndWatchContract` rejecting is operational/fatal and
1570
1593
  * propagates (only `discoverAt` is guarded).
1594
+ * - Within an index the handler probes run concurrently (independent
1595
+ * network reads); their hits are persisted sequentially in
1596
+ * `discoverables` order to preserve the first-wins collision tie-break.
1597
+ * - Indices are probed `batchSize` at a time (a second concurrency layer
1598
+ * over the per-index probes), but each window is CAPPED to
1599
+ * `gapLimit - unused` indices — the most a serial scan could still reach
1600
+ * before the gap window is guaranteed to close. So every index probed in
1601
+ * a window is one a one-index-at-a-time scan would also reach: nothing is
1602
+ * over-scanned, nothing is discarded, and `materialize`/`discoverAt` are
1603
+ * invoked on exactly the same index set. The window's hits are still
1604
+ * processed strictly in ascending index order, so the discovered set,
1605
+ * persisted rows, `lastIndexUsed`, and `handlerErrors` are byte-for-byte
1606
+ * identical to the serial path — only the wall-clock differs.
1571
1607
  */
1572
1608
  scanContracts(opts: ScanContractsOptions): Promise<ScanResult>;
1573
1609
  /**
@@ -1945,12 +1981,47 @@ interface DiscoveredContract {
1945
1981
  interface DiscoveryDeps {
1946
1982
  indexerProvider: IndexerProvider;
1947
1983
  onchainProvider: OnchainProvider;
1984
+ /**
1985
+ * Ark-address network data. The `{ hrp }` shape is all the L2
1986
+ * (`default`/`delegate`) discovery path needs to render an Ark address.
1987
+ */
1948
1988
  network: {
1949
1989
  hrp: string;
1950
1990
  };
1991
+ /**
1992
+ * Full Bitcoin network descriptor for on-chain (P2TR) address
1993
+ * rendering. Required by the boarding discovery probe, which derives an
1994
+ * on-chain Taproot address via {@link VtxoScript.onchainAddress} — the
1995
+ * `{ hrp }`-only {@link DiscoveryDeps.network} lacks the `bech32` data
1996
+ * that needs. Absent only when no boarding discovery is plumbed (e.g.
1997
+ * the scanner unit harness), in which case boarding `discoverAt` no-ops.
1998
+ */
1999
+ onchainNetwork?: Network;
2000
+ /**
2001
+ * The server's **current** signer key (x-only, 32 bytes), taken from a
2002
+ * fresh server-info snapshot at restore time. L2 (`default`/`delegate`)
2003
+ * discovery probes this key first.
2004
+ */
1951
2005
  serverPubKey: Uint8Array;
2006
+ /**
2007
+ * The server's **deprecated** signer keys (x-only, 32 bytes) from the same
2008
+ * snapshot. A VTXO minted under a now-rotated signer is anchored to a
2009
+ * different script; L2 discovery scans these keys alongside
2010
+ * {@link DiscoveryDeps.serverPubKey} so signer rotation does not strand
2011
+ * funds. Empty/absent when the server advertises no deprecated signers.
2012
+ * Boarding discovery does not consult this set (current UTXO set only).
2013
+ */
2014
+ deprecatedSignerPubKeys?: Uint8Array[];
1952
2015
  /** Relative timelocks the wallet treats as its baseline matrix. */
1953
2016
  csvTimelocks: RelativeTimelock[];
2017
+ /**
2018
+ * Boarding-exit CSV timelock. Distinct from {@link DiscoveryDeps.csvTimelocks}
2019
+ * (the unilateral-exit matrix): boarding scripts source their CSV from the
2020
+ * server's boarding-exit delay. Present only when boarding discovery is
2021
+ * plumbed; when absent, boarding `discoverAt` no-ops (so the scanner unit
2022
+ * harness, which never sets it, is unaffected).
2023
+ */
2024
+ boardingTimelock?: RelativeTimelock;
1954
2025
  /** Present only for delegate wallets. */
1955
2026
  delegatePubKey?: Uint8Array;
1956
2027
  }
@@ -3906,4 +3977,4 @@ declare namespace ProtoTypes {
3906
3977
  export { };
3907
3978
  }
3908
3979
 
3909
- export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type HandlerError as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type Asset as aA, type AssetMetadata as aB, type BaseWalletConfig as aC, type BatchInfo as aD, type BatchSignableIdentity as aE, CLTVMultisigTapscript as aF, ChainTxType as aG, type CommitmentTx as aH, ConditionCSVMultisigTapscript as aI, ConditionMultisigTapscript as aJ, type ContractBalance as aK, type ContractEventCallback as aL, type ContractHandler as aM, type ContractManagerConfig as aN, type ContractState as aO, type ContractVtxo as aP, ContractWatcher as aQ, DelegateManagerImpl as aR, type DelegateOptions as aS, DelegatorManagerImpl as aT, type DelegatorProvider as aU, type Discoverable as aV, type DiscoveredContract as aW, type DiscoveryDeps as aX, ESPLORA_URL as aY, EsploraProvider as aZ, type ExtendedContractVtxo as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type RenewVtxosOptions as al, type ContractWithVtxos as am, type PathSelection as an, type ContractEvent as ao, type AssetDetails as ap, type IssuanceResult as aq, type DelegateInfo as ar, type StorageConfig as as, type IVtxoManager as at, type ExplorerTransaction as au, type EncodedVtxoScript as av, type Status as aw, type Outpoint as ax, type ChainTx as ay, type ArkTapscript as az, type WalletConfig as b, type IDelegatorManager as b0, IndexerTxType as b1, type KnownMetadata as b2, MultisigTapscript as b3, type Nonces as b4, type Output as b5, type PageResponse as b6, type PaginationOptions as b7, PartialSig as b8, type PathContext as b9, getSequence as bA, isBatchSignable as bB, isDiscoverable as bC, isExpired as bD, isRecoverable as bE, isSpendable as bF, isSubdust as bG, isVtxoExpiringSoon as bH, networks as bI, type ProviderClass as ba, RestDelegateProvider as bb, RestDelegatorProvider as bc, type ScanContractsOptions as bd, type ScanResult as be, type ScheduledSession as bf, SettlementEventType as bg, type SignRequest as bh, type SubscriptionEvent as bi, type SubscriptionHeartbeat as bj, type TapLeaves as bk, TapTreeCoder as bl, TapscriptType as bm, type TreeNonces as bn, type TreePartialSigs as bo, type Tx as bp, type TxHistoryRecord as bq, type TxKey as br, type TxTreeNode as bs, TxType as bt, type VirtualStatus as bu, type Vtxo as bv, type VtxoChain as bw, type VtxoType as bx, type WalletMode as by, decodeTapscript as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };
3980
+ export { type SignerSession as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type DescriptorProvider as D, type ExtendedVirtualCoin as E, type IReadonlyWallet as F, type GetVtxosFilter as G, type ReadonlyIdentity as H, type IWallet as I, type DelegateProvider as J, type ReadonlyWalletConfig as K, type IReadonlyAssetManager as L, type NetworkName as M, type Network as N, type OnchainProvider as O, type ArkInfo as P, ArkAddress as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type Coin as U, VtxoScript as V, type WalletRepository as W, ContractManager as X, CSVMultisigTapscript as Y, type SettlementConfig as Z, VtxoManager as _, type Identity as a, type ExtendedContractVtxo as a$, type SignedIntent as a0, Intent as a1, type VtxoRepositoryKey as a2, type WalletState as a3, type ContractFilter as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type ArkTapscript as aA, type Asset as aB, type AssetMetadata as aC, type BaseWalletConfig as aD, type BatchInfo as aE, type BatchSignableIdentity as aF, CLTVMultisigTapscript as aG, ChainTxType as aH, type CommitmentTx as aI, ConditionCSVMultisigTapscript as aJ, ConditionMultisigTapscript as aK, type ContractBalance as aL, type ContractEventCallback as aM, type ContractHandler as aN, type ContractManagerConfig as aO, type ContractState as aP, type ContractVtxo as aQ, ContractWatcher as aR, DelegateManagerImpl as aS, type DelegateOptions as aT, DelegatorManagerImpl as aU, type DelegatorProvider as aV, type Discoverable as aW, type DiscoveredContract as aX, type DiscoveryDeps as aY, ESPLORA_URL as aZ, EsploraProvider as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type RenewVtxosOptions as al, type ContractWithVtxos as am, type PathSelection as an, type ContractEvent as ao, type AssetDetails as ap, type IssuanceResult as aq, type DelegateInfo as ar, type StorageConfig as as, type IVtxoManager as at, type ExplorerTransaction as au, type EncodedVtxoScript as av, type Status as aw, type Outpoint as ax, type ChainTx as ay, type PathContext as az, type WalletConfig as b, type HandlerError as b0, type IDelegatorManager as b1, IndexerTxType as b2, type KnownMetadata as b3, MultisigTapscript as b4, type Nonces as b5, type Output as b6, type PageResponse as b7, type PaginationOptions as b8, PartialSig as b9, getSequence as bA, isBatchSignable as bB, isDiscoverable as bC, isExpired as bD, isRecoverable as bE, isSpendable as bF, isSubdust as bG, isVtxoExpiringSoon as bH, networks as bI, type ProviderClass as ba, RestDelegateProvider as bb, RestDelegatorProvider as bc, type ScanContractsOptions as bd, type ScanResult as be, type ScheduledSession as bf, SettlementEventType as bg, type SignRequest as bh, type SubscriptionEvent as bi, type SubscriptionHeartbeat as bj, type TapLeaves as bk, TapTreeCoder as bl, TapscriptType as bm, type TreeNonces as bn, type TreePartialSigs as bo, type Tx as bp, type TxHistoryRecord as bq, type TxKey as br, type TxTreeNode as bs, TxType as bt, type VirtualStatus as bu, type Vtxo as bv, type VtxoChain as bw, type VtxoType as bx, type WalletMode as by, decodeTapscript as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type TreeSigningStartedEvent as s, TxTree as t, type TreeNoncesEvent as u, type BatchFinalizationEvent as v, type BatchFinalizedEvent as w, type BatchFailedEvent as x, type TreeTxEvent as y, type TreeSignatureEvent as z };
@@ -1,4 +1,4 @@
1
- import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-B1igKGAo.js';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-B1NUWyWR.js';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -1,4 +1,4 @@
1
- import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-By92TQ1m.cjs';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-vFRA3F9b.cjs';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -1,5 +1,5 @@
1
- import { RestArkProvider, isFetchTimeoutError, RestIndexerProvider } from './chunk-6NWNOLL3.js';
2
- import { DEFAULT_ARKADE_SERVER_URL } from './chunk-TU3LVAPX.js';
1
+ import { RestArkProvider, isFetchTimeoutError, RestIndexerProvider } from './chunk-FXFBPXV3.js';
2
+ import { DEFAULT_ARKADE_SERVER_URL } from './chunk-OUVTG72A.js';
3
3
 
4
4
  // src/providers/expoUtils.ts
5
5
  async function getExpoFetch(options) {
@@ -206,5 +206,5 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
206
206
  };
207
207
 
208
208
  export { ExpoArkProvider, ExpoIndexerProvider };
209
- //# sourceMappingURL=chunk-ABWRLTX5.js.map
210
- //# sourceMappingURL=chunk-ABWRLTX5.js.map
209
+ //# sourceMappingURL=chunk-5WDBHWX3.js.map
210
+ //# sourceMappingURL=chunk-5WDBHWX3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAIA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,OAAO,eAAA,CAAgB,KAAA;AAAA,EAC3B,SAAS,KAAA,EAAO;AAQZ,IAAA,OAAA,CAAQ,IAAA;AAAA,MACJ,wGAAA;AAAA,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B,kBAAA,EAAmB;AAAA,UACrC,CAAC,IAAA,KAAsC;AAEnC,YAAA,IAAI,IAAA,CAAK,cAAc,KAAA,CAAA,EAAW;AAE9B,cAAA,OAAO,IAAA;AAAA,YACX;AAEA,YAAA,IAAI,KAAK,KAAA,EAAO;AACZ,cAAA,OAAO;AAAA,gBACH,IAAA,EAAM,KAAK,KAAA,CAAM,IAAA;AAAA,gBACjB,OAAA,EAAS,IAAA,CAAK,KAAA,CAAM,OAAA,IAAW,EAAC;AAAA,gBAChC,WAAW,IAAA,CAAK,KAAA,CAAM,YAAY,EAAC,EAAG,IAAI,WAAW,CAAA;AAAA,gBACrD,aAAa,IAAA,CAAK,KAAA,CAAM,cAAc,EAAC,EAAG,IAAI,WAAW,CAAA;AAAA,gBACzD,aAAa,IAAA,CAAK,KAAA,CAAM,cAAc,EAAC,EAAG,IAAI,WAAW,CAAA;AAAA,gBACzD,EAAA,EAAI,KAAK,KAAA,CAAM,EAAA;AAAA,gBACf,aAAA,EAAe,KAAK,KAAA,CAAM;AAAA,eAC9B;AAAA,YACJ;AACA,YAAA,OAAO,IAAA;AAAA,UACX;AAAA,SACJ;AAAA,MACJ,SAAS,KAAA,EAAO;AACZ,QAAA,IAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,YAAA,EAAc;AACvD,UAAA;AAAA,QACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-ABWRLTX5.js","sourcesContent":["/**\n * Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n return expoFetchModule.fetch as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotification, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{\n commitmentTx?: TxNotification;\n arkTx?: TxNotification;\n }> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse, Vtxo } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { VirtualCoin } from \"../wallet\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n// Helper function to convert Vtxo to VirtualCoin (same as in indexer.ts)\nfunction convertVtxo(vtxo: Vtxo): VirtualCoin {\n return {\n txid: vtxo.outpoint.txid,\n vout: vtxo.outpoint.vout,\n value: Number(vtxo.amount),\n status: {\n confirmed: !vtxo.isSwept && !vtxo.isPreconfirmed,\n isLeaf: !vtxo.isPreconfirmed,\n },\n virtualStatus: {\n state: vtxo.isSwept ? \"swept\" : vtxo.isPreconfirmed ? \"preconfirmed\" : \"settled\",\n commitmentTxIds: vtxo.commitmentTxids,\n batchExpiry: vtxo.expiresAt ? Number(vtxo.expiresAt) * 1000 : undefined,\n },\n spentBy: vtxo.spentBy ?? \"\",\n settledBy: vtxo.settledBy,\n arkTxId: vtxo.arkTxid,\n createdAt: new Date(Number(vtxo.createdAt) * 1000),\n isUnrolled: vtxo.isUnrolled,\n isSpent: vtxo.isSpent,\n script: vtxo.script,\n assets: vtxo.assets?.map((a) => ({\n assetId: a.assetId,\n amount: BigInt(a.amount),\n })),\n };\n}\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAIA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,OAAO,eAAA,CAAgB,KAAA;AAAA,EAC3B,SAAS,KAAA,EAAO;AAQZ,IAAA,OAAA,CAAQ,IAAA;AAAA,MACJ,wGAAA;AAAA,MAEA;AAAA,KACJ;AACA,IAAA,OAAO,KAAA;AAAA,EACX;AACJ;AAYA,gBAAuB,iBAAA,CACnB,GAAA,EACA,WAAA,EACA,OAAA,EACA,SACA,SAAA,EACgC;AAChC,EAAA,MAAM,eAAA,GAAkB,IAAI,eAAA,EAAgB;AAC5C,EAAA,MAAM,OAAA,GAAU,MAAM,eAAA,CAAgB,KAAA,EAAM;AAC5C,EAAA,WAAA,EAAa,iBAAiB,OAAA,EAAS,OAAA,EAAS,EAAE,IAAA,EAAM,MAAM,CAAA;AAE9D,EAAA,IAAI;AACA,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,GAAA,EAAK;AAAA,MAChC,OAAA,EAAS;AAAA,QACL,MAAA,EAAQ,mBAAA;AAAA,QACR,GAAG;AAAA,OACP;AAAA,MACA,QAAQ,eAAA,CAAgB;AAAA,KAC3B,CAAA;AAED,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kBAAA,EAAqB,QAAA,CAAS,MAAM,CAAA,yBAAA,CAA2B,CAAA;A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A,UACX;AAAA,SACJ;AAAA,MACJ,SAAS,KAAA,EAAO;AACZ,QAAA,IAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,YAAA,EAAc;AACvD,UAAA;AAAA,QACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-5WDBHWX3.js","sourcesContent":["/**\n * Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n return expoFetchModule.fetch as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotification, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{\n commitmentTx?: TxNotification;\n arkTx?: TxNotification;\n }> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse, Vtxo } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { VirtualCoin } from \"../wallet\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n// Helper function to convert Vtxo to VirtualCoin (same as in indexer.ts)\nfunction convertVtxo(vtxo: Vtxo): VirtualCoin {\n return {\n txid: vtxo.outpoint.txid,\n vout: vtxo.outpoint.vout,\n value: Number(vtxo.amount),\n status: {\n confirmed: !vtxo.isSwept && !vtxo.isPreconfirmed,\n isLeaf: !vtxo.isPreconfirmed,\n },\n virtualStatus: {\n state: vtxo.isSwept ? \"swept\" : vtxo.isPreconfirmed ? \"preconfirmed\" : \"settled\",\n commitmentTxIds: vtxo.commitmentTxids,\n batchExpiry: vtxo.expiresAt ? Number(vtxo.expiresAt) * 1000 : undefined,\n },\n spentBy: vtxo.spentBy ?? \"\",\n settledBy: vtxo.settledBy,\n arkTxId: vtxo.arkTxid,\n createdAt: new Date(Number(vtxo.createdAt) * 1000),\n isUnrolled: vtxo.isUnrolled,\n isSpent: vtxo.isSpent,\n script: vtxo.script,\n assets: vtxo.assets?.map((a) => ({\n assetId: a.assetId,\n amount: BigInt(a.amount),\n })),\n };\n}\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}