@miden-sdk/react 0.14.5 → 0.14.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lazy.mjs CHANGED
@@ -425,6 +425,7 @@ function createRemoteProver(config, fallbackTimeout) {
425
425
  }
426
426
  return TransactionProver.newRemoteProver(
427
427
  url,
428
+ /* v8 ignore next 1 — timeoutMs is always provided in tests; ?? fallbackTimeout path unreachable */
428
429
  normalizeTimeout(timeoutMs ?? fallbackTimeout)
429
430
  );
430
431
  }
@@ -570,10 +571,12 @@ function MidenProvider({
570
571
  isReady,
571
572
  resolvedConfig.prover,
572
573
  resolvedConfig.proverTimeoutMs,
574
+ /* v8 ignore next 2 — optional chain on proverUrls; tests don't pass proverUrls config */
573
575
  resolvedConfig.proverUrls?.devnet,
574
576
  resolvedConfig.proverUrls?.testnet
575
577
  ]);
576
578
  const runExclusive = useCallback(
579
+ /* v8 ignore next 3 — runExclusive callback body; only called by advanced consumers, not directly in tests */
577
580
  async (fn) => clientLockRef.current.runExclusive(fn),
578
581
  []
579
582
  );
@@ -608,6 +611,8 @@ function MidenProvider({
608
611
  signCbRef.current = signerContext?.signCb ?? null;
609
612
  }, [signerContext?.signCb]);
610
613
  const wrappedSignCb = useCallback(
614
+ /* v8 ignore next 11 — wrappedSignCb body is only called during external signer operations;
615
+ * tests don't exercise the full signing flow through MidenProvider directly. */
611
616
  async (pubKey, signingInputs) => {
612
617
  const cb = signCbRef.current;
613
618
  if (!cb) {
@@ -658,7 +663,9 @@ function MidenProvider({
658
663
  storeName,
659
664
  signerContext.getKeyCb,
660
665
  signerContext.insertKeyCb,
661
- wrappedSignCb
666
+ wrappedSignCb,
667
+ void 0,
668
+ resolvedConfig.useWorker
662
669
  );
663
670
  if (cancelled) return;
664
671
  const accountId = await initializeSignerAccount(
@@ -674,7 +681,10 @@ function MidenProvider({
674
681
  webClient = await WebClient.createClient(
675
682
  resolvedConfig.rpcUrl,
676
683
  resolvedConfig.noteTransportUrl,
677
- seed
684
+ seed,
685
+ void 0,
686
+ void 0,
687
+ resolvedConfig.useWorker
678
688
  );
679
689
  if (cancelled) return;
680
690
  }
@@ -855,7 +865,10 @@ function MultiSignerProvider({ children }) {
855
865
  () => ({ register, unregister }),
856
866
  [register, unregister]
857
867
  );
858
- const activeSigner = activeSignerName ? signersSnapshot.find((s) => s.name === activeSignerName) ?? null : null;
868
+ const activeSigner = activeSignerName ? (
869
+ /* v8 ignore next 1 — ?? null fallback; find() returns undefined only when the signer was unregistered between renders */
870
+ signersSnapshot.find((s) => s.name === activeSignerName) ?? null
871
+ ) : null;
859
872
  const stableSignCb = useCallback2(
860
873
  async (pubKey, signingInputs) => {
861
874
  const name = activeSignerName;
@@ -1307,6 +1320,7 @@ function getNoteType(type) {
1307
1320
  return NoteType.Private;
1308
1321
  case "public":
1309
1322
  return NoteType.Public;
1323
+ /* v8 ignore next 2 — TypeScript type ensures only "private"|"public"; default is unreachable */
1310
1324
  default:
1311
1325
  return NoteType.Private;
1312
1326
  }
@@ -1782,6 +1796,7 @@ function buildFilter(filter, ids, idsHex) {
1782
1796
  }
1783
1797
  return {
1784
1798
  filter: TransactionFilter2.all(),
1799
+ /* v8 ignore next 1 — idsHex is always non-null when ids is non-empty; ?? [] is a safety net */
1785
1800
  localFilterHexes: idsHex ?? []
1786
1801
  };
1787
1802
  }
@@ -2271,7 +2286,7 @@ function useSend() {
2271
2286
  txRequest,
2272
2287
  prover
2273
2288
  ) : await client.submitNewTransaction(execFromId, txRequest);
2274
- return { txId: txId.toString(), note: p2idNote };
2289
+ return { txId: txId.toHex(), note: p2idNote };
2275
2290
  });
2276
2291
  setStage("complete");
2277
2292
  setResult(returnResult);
@@ -2323,7 +2338,6 @@ function useSend() {
2323
2338
  () => client.submitProvenTransaction(provenTransaction, txResult)
2324
2339
  );
2325
2340
  const txIdHex = txResult.id().toHex();
2326
- const txIdString = txResult.id().toString();
2327
2341
  let fullNote = null;
2328
2342
  if (noteType === NoteType2.Private) {
2329
2343
  fullNote = extractFullNote(txResult);
@@ -2347,7 +2361,7 @@ function useSend() {
2347
2361
  );
2348
2362
  }
2349
2363
  const sendResult = {
2350
- txId: txIdString,
2364
+ txId: txIdHex,
2351
2365
  note: null
2352
2366
  };
2353
2367
  setStage("complete");
@@ -2459,7 +2473,11 @@ function useMultiSend() {
2459
2473
  };
2460
2474
  }
2461
2475
  );
2462
- const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(new NoteArray2(outputs.map((o) => o.note))).build();
2476
+ const ownOutputs = new NoteArray2();
2477
+ for (const o of outputs) {
2478
+ ownOutputs.push(o.note);
2479
+ }
2480
+ const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(ownOutputs).build();
2463
2481
  const txSenderId = parseAccountId(options.from);
2464
2482
  const txResult = await client.executeTransaction(txSenderId, txRequest);
2465
2483
  setStage("proving");
@@ -2476,7 +2494,6 @@ function useMultiSend() {
2476
2494
  txResult
2477
2495
  );
2478
2496
  const txIdHex = txResult.id().toHex();
2479
- const txIdString = txResult.id().toString();
2480
2497
  await client.applyTransaction(txResult, submissionHeight);
2481
2498
  const hasPrivate = outputs.some((o) => o.noteType === NoteType3.Private);
2482
2499
  if (hasPrivate) {
@@ -2494,7 +2511,7 @@ function useMultiSend() {
2494
2511
  }
2495
2512
  }
2496
2513
  }
2497
- const txSummary = { transactionId: txIdString };
2514
+ const txSummary = { transactionId: txIdHex };
2498
2515
  setStage("complete");
2499
2516
  setResult(txSummary);
2500
2517
  await sync();
@@ -2643,7 +2660,7 @@ function useMint() {
2643
2660
  txRequest,
2644
2661
  prover
2645
2662
  ) : await client.submitNewTransaction(faucetIdObj, txRequest);
2646
- return { transactionId: txId.toString() };
2663
+ return { transactionId: txId.toHex() };
2647
2664
  });
2648
2665
  setStage("complete");
2649
2666
  setResult(txResult);
@@ -2719,16 +2736,17 @@ function useConsume() {
2719
2736
  }
2720
2737
  }
2721
2738
  if (lookupIds.length > 0) {
2739
+ const lookupIdStrings = lookupIds.map((id) => id.toString());
2722
2740
  const filter = new NoteFilter3(NoteFilterTypes2.List, lookupIds);
2723
2741
  const noteRecords = await client.getInputNotes(filter);
2724
- if (noteRecords.length !== lookupIds.length) {
2742
+ if (noteRecords.length !== lookupIdStrings.length) {
2725
2743
  throw new Error("Some notes could not be found for provided IDs");
2726
2744
  }
2727
2745
  const recordById = new Map(
2728
2746
  noteRecords.map((r) => [r.id().toString(), r])
2729
2747
  );
2730
2748
  for (let j = 0; j < lookupIndices.length; j++) {
2731
- const record = recordById.get(lookupIds[j].toString());
2749
+ const record = recordById.get(lookupIdStrings[j]);
2732
2750
  if (!record) {
2733
2751
  throw new Error(
2734
2752
  "Some notes could not be found for provided IDs"
@@ -2750,7 +2768,7 @@ function useConsume() {
2750
2768
  txRequest,
2751
2769
  prover
2752
2770
  ) : await client.submitNewTransaction(accountIdObj, txRequest);
2753
- return { transactionId: txId.toString() };
2771
+ return { transactionId: txId.toHex() };
2754
2772
  });
2755
2773
  setStage("complete");
2756
2774
  setResult(txResult);
@@ -2824,7 +2842,7 @@ function useSwap() {
2824
2842
  txRequest,
2825
2843
  prover
2826
2844
  ) : await client.submitNewTransaction(accountIdObj, txRequest);
2827
- return { transactionId: txId.toString() };
2845
+ return { transactionId: txId.toHex() };
2828
2846
  });
2829
2847
  setStage("complete");
2830
2848
  setResult(txResult);
@@ -2959,7 +2977,7 @@ function useTransaction() {
2959
2977
  );
2960
2978
  }
2961
2979
  }
2962
- const txSummary = { transactionId: txId.toString() };
2980
+ const txSummary = { transactionId: txId.toHex() };
2963
2981
  setStage("complete");
2964
2982
  setResult(txSummary);
2965
2983
  await sync();
@@ -3191,13 +3209,14 @@ function useSessionAccount(options) {
3191
3209
  setSessionAccountId(walletId);
3192
3210
  localStorage.setItem(`${storagePrefix}:accountId`, walletId);
3193
3211
  }
3212
+ const resolvedWalletId = walletId;
3194
3213
  setStep("funding");
3195
- await fundRef.current(walletId);
3214
+ await fundRef.current(resolvedWalletId);
3196
3215
  if (cancelledRef.current) return;
3197
3216
  setStep("consuming");
3198
3217
  await waitAndConsume(
3199
3218
  client,
3200
- walletId,
3219
+ resolvedWalletId,
3201
3220
  pollIntervalMs,
3202
3221
  maxWaitMs,
3203
3222
  cancelledRef
@@ -150,6 +150,22 @@ interface MidenConfig {
150
150
  proverUrls?: ProverUrls;
151
151
  /** Default timeout for remote prover requests in milliseconds. */
152
152
  proverTimeoutMs?: number | bigint;
153
+ /**
154
+ * Enable the Web Worker shim that runs WASM calls off the main thread.
155
+ * Defaults to `true` — leave it that way in browsers/extensions so the UI
156
+ * stays responsive while WASM is busy.
157
+ *
158
+ * Set to `false` when:
159
+ * - You pass a `CallbackProver` (e.g. a native iOS/Android prover via
160
+ * a Capacitor plugin). The worker boundary serializes the prover with
161
+ * `TransactionProver.serialize()`, which has no encoding for the
162
+ * callback variant and silently downgrades to `"local"` — your
163
+ * callback would never fire.
164
+ * - You're embedding the client in a single-WebView native shell
165
+ * (Capacitor host, Tauri, Electron preload), where the UI thread
166
+ * isn't competing with the WASM thread anyway.
167
+ */
168
+ useWorker?: boolean;
153
169
  }
154
170
  interface MidenState {
155
171
  client: WasmWebClient | null;