@arkade-os/sdk 0.4.48 → 0.4.49

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 (77) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +3 -3
  5. package/dist/adapters/indexedDB.cjs +5 -5
  6. package/dist/adapters/indexedDB.js +4 -4
  7. package/dist/{ark-CjE0KkGp.d.cts → ark-nkSiPYNf.d.cts} +86 -24
  8. package/dist/{ark-CjE0KkGp.d.ts → ark-nkSiPYNf.d.ts} +86 -24
  9. package/dist/{asyncStorageTaskQueue-D9SOPMPC.d.ts → asyncStorageTaskQueue-DCaEE83p.d.ts} +1 -1
  10. package/dist/{asyncStorageTaskQueue-CeLZhZFU.d.cts → asyncStorageTaskQueue-DdxhsEz6.d.cts} +1 -1
  11. package/dist/{chunk-ENZ4YPR2.cjs → chunk-2LAJ3RTH.cjs} +491 -418
  12. package/dist/chunk-2LAJ3RTH.cjs.map +1 -0
  13. package/dist/{chunk-NYR5H6GR.js → chunk-5QVBJUOG.js} +154 -81
  14. package/dist/chunk-5QVBJUOG.js.map +1 -0
  15. package/dist/{chunk-SYDANBJI.cjs → chunk-6UI5BFE7.cjs} +9 -9
  16. package/dist/{chunk-SYDANBJI.cjs.map → chunk-6UI5BFE7.cjs.map} +1 -1
  17. package/dist/{chunk-G6J6AEMH.js → chunk-BLJQV3N4.js} +4 -4
  18. package/dist/{chunk-G6J6AEMH.js.map → chunk-BLJQV3N4.js.map} +1 -1
  19. package/dist/{chunk-BHHLRZCS.js → chunk-CPO2UB7L.js} +4 -4
  20. package/dist/{chunk-BHHLRZCS.js.map → chunk-CPO2UB7L.js.map} +1 -1
  21. package/dist/{chunk-7TXSPRN5.cjs → chunk-E7HB3GKK.cjs} +31 -2
  22. package/dist/chunk-E7HB3GKK.cjs.map +1 -0
  23. package/dist/{chunk-ZDDBTFVO.js → chunk-EFNLTS6Q.js} +29 -3
  24. package/dist/chunk-EFNLTS6Q.js.map +1 -0
  25. package/dist/{chunk-XFMGIFBL.js → chunk-HN25T276.js} +4 -4
  26. package/dist/{chunk-XFMGIFBL.js.map → chunk-HN25T276.js.map} +1 -1
  27. package/dist/{chunk-5XMVTK5S.cjs → chunk-LJQ2VQBE.cjs} +211 -230
  28. package/dist/chunk-LJQ2VQBE.cjs.map +1 -0
  29. package/dist/{chunk-4VVTRPH3.js → chunk-MBSYQ3WX.js} +183 -201
  30. package/dist/chunk-MBSYQ3WX.js.map +1 -0
  31. package/dist/{chunk-EB3ALGTM.cjs → chunk-QDXQULVM.cjs} +13 -13
  32. package/dist/{chunk-EB3ALGTM.cjs.map → chunk-QDXQULVM.cjs.map} +1 -1
  33. package/dist/{chunk-ENDNQPZA.cjs → chunk-XOLH3LFO.cjs} +17 -17
  34. package/dist/{chunk-ENDNQPZA.cjs.map → chunk-XOLH3LFO.cjs.map} +1 -1
  35. package/dist/contracts/handlers/index.cjs +8 -8
  36. package/dist/contracts/handlers/index.d.cts +3 -3
  37. package/dist/contracts/handlers/index.d.ts +3 -3
  38. package/dist/contracts/handlers/index.js +2 -2
  39. package/dist/{delegate-D3dY-2vS.d.cts → delegate-Cqqw1T1J.d.cts} +1 -1
  40. package/dist/{delegate-DhGZk1r2.d.ts → delegate-D6Orvyq7.d.ts} +1 -1
  41. package/dist/{index-DK4_iWYy.d.ts → index-CWoogah0.d.ts} +2 -2
  42. package/dist/{index-D6RQROds.d.cts → index-Yd4hecbM.d.cts} +2 -2
  43. package/dist/index.cjs +181 -181
  44. package/dist/index.d.cts +8 -8
  45. package/dist/index.d.ts +8 -8
  46. package/dist/index.js +4 -4
  47. package/dist/repositories/realm/index.cjs +19 -19
  48. package/dist/repositories/realm/index.d.cts +2 -2
  49. package/dist/repositories/realm/index.d.ts +2 -2
  50. package/dist/repositories/realm/index.js +5 -5
  51. package/dist/repositories/sqlite/index.cjs +18 -18
  52. package/dist/repositories/sqlite/index.d.cts +2 -2
  53. package/dist/repositories/sqlite/index.d.ts +2 -2
  54. package/dist/repositories/sqlite/index.js +5 -5
  55. package/dist/{taskRunner-Brnak0Rc.d.cts → taskRunner-BjB5QINR.d.cts} +1 -1
  56. package/dist/{taskRunner-B-2MHCYG.d.ts → taskRunner-Dw7xs60Q.d.ts} +1 -1
  57. package/dist/wallet/expo/background.cjs +14 -14
  58. package/dist/wallet/expo/background.d.cts +3 -3
  59. package/dist/wallet/expo/background.d.ts +3 -3
  60. package/dist/wallet/expo/background.js +6 -6
  61. package/dist/wallet/expo/index.cjs +14 -14
  62. package/dist/wallet/expo/index.d.cts +4 -4
  63. package/dist/wallet/expo/index.d.ts +4 -4
  64. package/dist/wallet/expo/index.js +5 -5
  65. package/dist/{wallet-B5bwixQa.d.ts → wallet-CGkWu3xV.d.cts} +2 -2
  66. package/dist/{wallet-DiOrtYic.d.cts → wallet-DyUHrPyN.d.ts} +2 -2
  67. package/dist/worker/expo/index.cjs +9 -9
  68. package/dist/worker/expo/index.d.cts +4 -4
  69. package/dist/worker/expo/index.d.ts +4 -4
  70. package/dist/worker/expo/index.js +5 -5
  71. package/package.json +1 -1
  72. package/dist/chunk-4VVTRPH3.js.map +0 -1
  73. package/dist/chunk-5XMVTK5S.cjs.map +0 -1
  74. package/dist/chunk-7TXSPRN5.cjs.map +0 -1
  75. package/dist/chunk-ENZ4YPR2.cjs.map +0 -1
  76. package/dist/chunk-NYR5H6GR.js.map +0 -1
  77. package/dist/chunk-ZDDBTFVO.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { Transaction, setArkPsbtField, PrevArkTxField, ConditionWitness, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, craftToSpendTx, getArkPsbtFields, CosignerPublicKey, BufferReader, BufferWriter, OP_RETURN_EMPTY_PKSCRIPT, VtxoTaprootTree, baseFetch, Intent, rateGate, maybeArkError, isArkError, ArkErrorName, ProviderUnavailableError, FetchError, isFetchTimeoutError, AssetRef, isEventSourceError, RestArkProvider, RestIndexerProvider, ArkError } from './chunk-BHHLRZCS.js';
2
- import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, DefaultVtxo, DEFAULT_PAGE_SIZE, DelegateVtxo, WALLET_RECEIVE_SOURCE, deriveDescriptorLeafPubKey, BoardingContractHandler } from './chunk-4VVTRPH3.js';
3
- import { VtxoScript, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, hasTerminalSpend, getNormalizedVtxos, isVirtualCoin, ArkAddress, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, timelockToSequence, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, canSpendOffchain, toVirtualStatus, resolveTimeHeight, parseLegacyExpiry, networks as networks$1, isExpired, DEFAULT_ARKADE_SERVER_URL, isPastExpiry } from './chunk-ZDDBTFVO.js';
1
+ import { Transaction, setArkPsbtField, PrevArkTxField, ConditionWitness, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, craftToSpendTx, getArkPsbtFields, CosignerPublicKey, BufferReader, BufferWriter, OP_RETURN_EMPTY_PKSCRIPT, VtxoTaprootTree, baseFetch, Intent, rateGate, maybeArkError, isArkError, ArkErrorName, ProviderUnavailableError, FetchError, isFetchTimeoutError, AssetRef, isEventSourceError, RestArkProvider, RestIndexerProvider, ArkError } from './chunk-CPO2UB7L.js';
2
+ import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, DefaultVtxo, DelegateVtxo, WALLET_RECEIVE_SOURCE, deriveDescriptorLeafPubKey, BoardingContractHandler } from './chunk-MBSYQ3WX.js';
3
+ import { VtxoScript, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, hasTerminalSpend, getNormalizedVtxos, isVirtualCoin, ArkAddress, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, timelockToSequence, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, canSpendOffchain, toVirtualStatus, resolveTimeHeight, parseLegacyExpiry, networks as networks$1, isExpired, DEFAULT_ARKADE_SERVER_URL, isPastExpiry } from './chunk-EFNLTS6Q.js';
4
4
  import { __export } from './chunk-NSBPE2FW.js';
5
5
  import { sha256, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
6
6
  import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
@@ -8096,6 +8096,9 @@ var ContractWatcher = class {
8096
8096
  reconnectAttempts = 0;
8097
8097
  reconnectTimeoutId;
8098
8098
  failsafePollIntervalId;
8099
+ /** See {@link withCoalescedSubscription}. */
8100
+ subscriptionBatchDepth = 0;
8101
+ subscriptionUpdateDeferred = false;
8099
8102
  /**
8100
8103
  * Create a contract watcher with the given providers and polling settings.
8101
8104
  *
@@ -8405,7 +8408,40 @@ var ContractWatcher = class {
8405
8408
  console.error("ContractWatcher poll failed:", error);
8406
8409
  }
8407
8410
  }
8411
+ /**
8412
+ * Run `fn` with subscription updates coalesced into a single
8413
+ * `subscribeForScripts` on the way out.
8414
+ *
8415
+ * {@link addContract} re-subscribes eagerly (the watcher may already be
8416
+ * running), and every subscribe posts the *whole* accumulated script list —
8417
+ * so a restore scan that discovers N contracts sends N growing POSTs,
8418
+ * quadratic in script-slots. Inside this scope those updates are only
8419
+ * marked dirty, flushed once on the way out (success and error path alike).
8420
+ *
8421
+ * A contract added inside the scope is therefore not streaming until the
8422
+ * flush. Nothing in the watcher closes that window — the failsafe poll
8423
+ * replays repository state and cannot see VTXOs no one has fetched yet. The
8424
+ * one caller, `scanContracts`, is covered because `Wallet.restore` follows
8425
+ * it with a bulk `refreshVtxos`. A new caller must provide its own
8426
+ * equivalent catch-up, or keep the scope short enough not to need one.
8427
+ */
8428
+ async withCoalescedSubscription(fn) {
8429
+ this.subscriptionBatchDepth++;
8430
+ try {
8431
+ return await fn();
8432
+ } finally {
8433
+ this.subscriptionBatchDepth--;
8434
+ if (this.subscriptionBatchDepth === 0 && this.subscriptionUpdateDeferred) {
8435
+ this.subscriptionUpdateDeferred = false;
8436
+ if (this.isWatching) await this.tryUpdateSubscription();
8437
+ }
8438
+ }
8439
+ }
8408
8440
  async tryUpdateSubscription() {
8441
+ if (this.subscriptionBatchDepth > 0) {
8442
+ this.subscriptionUpdateDeferred = true;
8443
+ return;
8444
+ }
8409
8445
  const hadSubscription = this.subscriptionId !== void 0;
8410
8446
  try {
8411
8447
  await this.updateSubscription();
@@ -8886,21 +8922,27 @@ var ContractManager = class _ContractManager {
8886
8922
  * Safety-critical invariants (spec §2.C / §4):
8887
8923
  * - `opts.materialize(i)` throwing is structural/fatal: it is NOT
8888
8924
  * wrapped — it propagates and aborts the scan.
8889
- * - A `discoverAt` rejection is collected into `handlerErrors` and makes
8890
- * its index *indeterminate*: it does NOT advance the gap counter, and
8891
- * the scan stops verifying there, reporting `truncatedAt`. Only an index
8925
+ * - A discovery rejection is collected into `handlerErrors` and makes its
8926
+ * index *indeterminate*: it does NOT advance the gap counter, and the
8927
+ * scan stops verifying there, reporting `truncatedAt`. Only an index
8892
8928
  * every handler answered for can be a confirmed miss.
8893
8929
  * - `persistAndWatchContract` rejecting is operational/fatal and
8894
- * propagates (only `discoverAt` is guarded).
8895
- * - Within an index the handler probes run concurrently (independent
8896
- * network reads); their hits are persisted sequentially in
8897
- * `discoverables` order to preserve the first-wins collision tie-break.
8898
- * - Indices are probed `batchSize` at a time (a second concurrency layer
8899
- * over the per-index probes), but each window is CAPPED to
8930
+ * propagates (only the handler calls are guarded).
8931
+ * - A handler exposing {@link Discoverable.discoverRange} is asked for the
8932
+ * whole window in ONE call instead of one per index — the batching that
8933
+ * keeps a large restore from bursting into an operator's rate limiter.
8934
+ * Its failures are therefore range-wide: every index in the window goes
8935
+ * indeterminate and truncation lands on the window's first index. Its
8936
+ * answer must cover every requested index; an incomplete map is treated
8937
+ * as a rejection (see `Discoverable.discoverRange`).
8938
+ * - Handlers are probed concurrently (independent network reads); their
8939
+ * hits are persisted sequentially in `discoverables` order to preserve
8940
+ * the first-wins collision tie-break.
8941
+ * - Indices are probed `batchSize` at a time, but each window is CAPPED to
8900
8942
  * `gapLimit - unused` indices — the most a serial scan could still reach
8901
8943
  * before the gap window is guaranteed to close. So every index probed in
8902
8944
  * a window is one a one-index-at-a-time scan would also reach: nothing is
8903
- * over-scanned, nothing is discarded, and `materialize`/`discoverAt` are
8945
+ * over-scanned, nothing is discarded, and `materialize`/discovery are
8904
8946
  * invoked on exactly the same index set. The window's hits are still
8905
8947
  * processed strictly in ascending index order, so the discovered set,
8906
8948
  * persisted rows, `highestConfirmedUsedIndex`, and `handlerErrors` are
@@ -8909,8 +8951,14 @@ var ContractManager = class _ContractManager {
8909
8951
  * can surface hits above the failed index that a serial scan would never
8910
8952
  * have reached, so a truncated batched scan discovers a superset — never
8911
8953
  * a subset — of the serial one.
8954
+ * - The whole scan runs inside one coalesced subscription scope, so N
8955
+ * discovered contracts cost ONE `subscribeForScripts` instead of N
8956
+ * growing ones (see {@link ContractWatcher.withCoalescedSubscription}).
8912
8957
  */
8913
- async scanContracts(opts) {
8958
+ scanContracts(opts) {
8959
+ return this.watcher.withCoalescedSubscription(() => this.runScan(opts));
8960
+ }
8961
+ async runScan(opts) {
8914
8962
  const gapLimit = opts.gapLimit ?? 20;
8915
8963
  if (!Number.isInteger(gapLimit) || gapLimit <= 0) {
8916
8964
  throw new Error(
@@ -8934,43 +8982,80 @@ var ContractManager = class _ContractManager {
8934
8982
  let truncatedAt;
8935
8983
  let unused = 0;
8936
8984
  let i = 0;
8937
- const probeIndex = async (index) => {
8938
- const descriptor = opts.materialize(index);
8939
- return Promise.all(
8940
- discoverables.map(async (h) => {
8941
- try {
8942
- return {
8943
- ok: true,
8944
- found: await h.discoverAt(index, descriptor, opts.deps)
8945
- };
8946
- } catch (error) {
8947
- return { ok: false, error };
8948
- }
8949
- })
8950
- );
8985
+ const probeHandler = async (h, entries) => {
8986
+ const probe = {
8987
+ found: /* @__PURE__ */ new Map(),
8988
+ indeterminate: /* @__PURE__ */ new Set(),
8989
+ // Keyed by the index the failure is ANCHORED at, so errors stay
8990
+ // reported in ascending-index order below, exactly as the
8991
+ // per-index path reports them.
8992
+ errors: /* @__PURE__ */ new Map()
8993
+ };
8994
+ if (!h.discoverRange) {
8995
+ await Promise.all(
8996
+ entries.map(async ({ index, descriptor }) => {
8997
+ try {
8998
+ probe.found.set(
8999
+ index,
9000
+ await h.discoverAt(index, descriptor, opts.deps)
9001
+ );
9002
+ } catch (error) {
9003
+ probe.indeterminate.add(index);
9004
+ probe.errors.set(index, { handler: h.type, index, error });
9005
+ }
9006
+ })
9007
+ );
9008
+ return probe;
9009
+ }
9010
+ const from = entries[0].index;
9011
+ const to = entries[entries.length - 1].index;
9012
+ const failRange = (error) => {
9013
+ for (const e of entries) probe.indeterminate.add(e.index);
9014
+ probe.errors.set(from, {
9015
+ handler: h.type,
9016
+ index: from,
9017
+ ...to > from && { toIndex: to },
9018
+ error
9019
+ });
9020
+ };
9021
+ let ranged;
9022
+ try {
9023
+ ranged = await h.discoverRange(entries, opts.deps);
9024
+ } catch (error) {
9025
+ failRange(error);
9026
+ return probe;
9027
+ }
9028
+ for (const e of entries) {
9029
+ const found = ranged.get(e.index);
9030
+ if (found) probe.found.set(e.index, found);
9031
+ }
9032
+ const missing = entries.find((e) => !ranged.has(e.index));
9033
+ if (missing) {
9034
+ failRange(
9035
+ new Error(
9036
+ `${h.type}.discoverRange resolved without index ${missing.index} of the requested range [${from}..${to}]`
9037
+ )
9038
+ );
9039
+ }
9040
+ return probe;
8951
9041
  };
8952
9042
  while (i <= maxIdx && unused < gapLimit) {
8953
9043
  const windowEnd = Math.min(maxIdx, i + Math.min(batchSize, gapLimit - unused) - 1);
8954
- const windowIndices = [];
8955
- for (let idx = i; idx <= windowEnd; idx++) windowIndices.push(idx);
8956
- const windowProbes = await Promise.all(windowIndices.map(probeIndex));
8957
- for (let w = 0; w < windowIndices.length; w++) {
8958
- const index = windowIndices[w];
8959
- const probes = windowProbes[w];
9044
+ const entries = [];
9045
+ for (let idx = i; idx <= windowEnd; idx++) {
9046
+ entries.push({ index: idx, descriptor: opts.materialize(idx) });
9047
+ }
9048
+ const windowProbes = await Promise.all(
9049
+ discoverables.map((h) => probeHandler(h, entries))
9050
+ );
9051
+ for (const { index } of entries) {
8960
9052
  let hitAtThisIndex = false;
8961
9053
  let indeterminate = false;
8962
- for (let h = 0; h < discoverables.length; h++) {
8963
- const probe = probes[h];
8964
- if (!probe.ok) {
8965
- handlerErrors.push({
8966
- handler: discoverables[h].type,
8967
- index,
8968
- error: probe.error
8969
- });
8970
- indeterminate = true;
8971
- continue;
8972
- }
8973
- for (const c of probe.found) {
9054
+ for (const probe of windowProbes) {
9055
+ const error = probe.errors.get(index);
9056
+ if (error) handlerErrors.push(error);
9057
+ if (probe.indeterminate.has(index)) indeterminate = true;
9058
+ for (const c of probe.found.get(index) ?? []) {
8974
9059
  await this.persistAndWatchContract(c);
8975
9060
  hitAtThisIndex = true;
8976
9061
  }
@@ -9337,12 +9422,12 @@ var ContractManager = class _ContractManager {
9337
9422
  * window (e.g. a spend that hasn't settled yet).
9338
9423
  */
9339
9424
  async reconcilePendingFrontier(contracts) {
9340
- const scripts = contracts.map((c) => c.script);
9341
9425
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
9342
- const { vtxos } = await getNormalizedVtxos(this.config.indexerProvider, {
9343
- scripts,
9344
- pendingOnly: true
9345
- });
9426
+ const vtxos = await getAllNormalizedVtxos(
9427
+ this.config.indexerProvider,
9428
+ contracts.map((c) => c.script),
9429
+ { pendingOnly: true }
9430
+ );
9346
9431
  const owned = vtxos.filter((v) => scriptToContract.has(v.script));
9347
9432
  const annotated = await this.annotateVtxos(owned);
9348
9433
  const byContract = /* @__PURE__ */ new Map();
@@ -9418,7 +9503,6 @@ var ContractManager = class _ContractManager {
9418
9503
  const result = new Map(
9419
9504
  contracts.map((c) => [c.script, []])
9420
9505
  );
9421
- const scripts = contracts.map((c) => c.script);
9422
9506
  const windowOpts = syncWindow ? {
9423
9507
  ...syncWindow.after !== void 0 && {
9424
9508
  after: syncWindow.after
@@ -9427,26 +9511,18 @@ var ContractManager = class _ContractManager {
9427
9511
  before: syncWindow.before
9428
9512
  }
9429
9513
  } : {};
9430
- let pageIndex = 0;
9431
- let hasMore = true;
9432
- while (hasMore) {
9433
- const { vtxos, page } = await getNormalizedVtxos(this.config.indexerProvider, {
9434
- scripts,
9435
- ...windowOpts,
9436
- pageIndex,
9437
- pageSize
9514
+ const vtxos = await getAllNormalizedVtxos(
9515
+ this.config.indexerProvider,
9516
+ contracts.map((c) => c.script),
9517
+ { ...windowOpts, pageSize }
9518
+ );
9519
+ const owned = vtxos.filter((v) => scriptToContract.has(v.script));
9520
+ const annotated = await this.annotateVtxos(owned);
9521
+ for (const vtxo of annotated) {
9522
+ result.get(vtxo.script).push({
9523
+ ...vtxo,
9524
+ contractScript: vtxo.script
9438
9525
  });
9439
- const owned = vtxos.filter((v) => scriptToContract.has(v.script));
9440
- const annotated = await this.annotateVtxos(owned);
9441
- for (const vtxo of annotated) {
9442
- result.get(vtxo.script).push({
9443
- ...vtxo,
9444
- contractScript: vtxo.script
9445
- });
9446
- }
9447
- hasMore = page ? vtxos.length === pageSize : false;
9448
- pageIndex++;
9449
- if (hasMore) await new Promise((r) => setTimeout(r, 500));
9450
9526
  }
9451
9527
  return result;
9452
9528
  }
@@ -11142,9 +11218,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
11142
11218
  /** Fetch Arkade transaction ids that are still pending final settlement. */
11143
11219
  async fetchPendingTxs() {
11144
11220
  const scripts = await this.getWalletScripts();
11145
- let { vtxos } = await getNormalizedVtxos(this.indexerProvider, {
11146
- scripts
11147
- });
11221
+ const vtxos = await getAllNormalizedVtxos(this.indexerProvider, scripts);
11148
11222
  return vtxos.filter(
11149
11223
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
11150
11224
  ).map((_) => _.arkTxId);
@@ -11820,7 +11894,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11820
11894
  if (hd && result.highestConfirmedUsedIndex >= 0) {
11821
11895
  await provider.advanceLastIndexUsed(result.highestConfirmedUsedIndex);
11822
11896
  }
11823
- await manager.refreshVtxos({ includeInactive: true });
11897
+ await manager.refreshVtxos({ includeInactive: true, after: 0 });
11824
11898
  const causes = result.handlerErrors.map(
11825
11899
  (e) => e.error instanceof Error ? e.error : new Error(String(e.error))
11826
11900
  );
@@ -12728,10 +12802,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12728
12802
  if (!vtxos || vtxos.length === 0) {
12729
12803
  const scriptMap = await this.getScriptMap();
12730
12804
  const allExtended = [];
12731
- const allScripts = [...scriptMap.keys()];
12732
- const { vtxos: fetchedVtxos } = await getNormalizedVtxos(this.indexerProvider, {
12733
- scripts: allScripts
12734
- });
12805
+ const fetchedVtxos = await getAllNormalizedVtxos(this.indexerProvider, [
12806
+ ...scriptMap.keys()
12807
+ ]);
12735
12808
  for (const vtxo of fetchedVtxos) {
12736
12809
  const vtxoScript = scriptMap.get(vtxo.script);
12737
12810
  if (!vtxoScript) continue;
@@ -19814,5 +19887,5 @@ function isArkContract(str) {
19814
19887
  }
19815
19888
 
19816
19889
  export { ARKADE_MAGIC, ActivityRegistry, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP322, Batch, ChainedTxType, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, RestEmulatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, arkade_exports, assertIntentIdUnique, boardingResolver, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createAssetPacket, createDefaultActivityRegistry, createExitChainResolver, decodeArkContract, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, intentMatchesFilter, intentPageBounds, isArkContract, isBatchSignable, isCooperativelyMigratable, isDiscoverable, isRetryableProviderError, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, mergeChainedTxType, migrateWalletRepository, openDatabase, requiresMigration, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
19817
- //# sourceMappingURL=chunk-NYR5H6GR.js.map
19818
- //# sourceMappingURL=chunk-NYR5H6GR.js.map
19890
+ //# sourceMappingURL=chunk-5QVBJUOG.js.map
19891
+ //# sourceMappingURL=chunk-5QVBJUOG.js.map