@miden-sdk/react 0.15.0-alpha.4 → 0.15.0-alpha.6

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.
@@ -1,102 +1,16 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- AuthScheme: () => import_miden_sdk4.AuthScheme,
34
- DEFAULTS: () => DEFAULTS,
35
- MidenError: () => MidenError,
36
- MidenProvider: () => MidenProvider,
37
- MultiSignerProvider: () => MultiSignerProvider,
38
- SignerContext: () => SignerContext,
39
- SignerSlot: () => SignerSlot,
40
- accountIdsEqual: () => accountIdsEqual,
41
- bigIntToBytes: () => bigIntToBytes,
42
- bytesToBigInt: () => bytesToBigInt,
43
- clearMidenStorage: () => clearMidenStorage,
44
- concatBytes: () => concatBytes,
45
- createMidenStorage: () => createMidenStorage,
46
- createNoteAttachment: () => createNoteAttachment,
47
- ensureAccountBech32: () => ensureAccountBech32,
48
- formatAssetAmount: () => formatAssetAmount,
49
- formatNoteSummary: () => formatNoteSummary,
50
- getNoteSummary: () => getNoteSummary,
51
- installAccountBech32: () => installAccountBech32,
52
- migrateStorage: () => migrateStorage,
53
- normalizeAccountId: () => normalizeAccountId,
54
- parseAssetAmount: () => parseAssetAmount,
55
- readNoteAttachment: () => readNoteAttachment,
56
- toBech32AccountId: () => toBech32AccountId,
57
- useAccount: () => useAccount,
58
- useAccounts: () => useAccounts,
59
- useAssetMetadata: () => useAssetMetadata,
60
- useCompile: () => useCompile,
61
- useConsume: () => useConsume,
62
- useCreateFaucet: () => useCreateFaucet,
63
- useCreateWallet: () => useCreateWallet,
64
- useExecuteProgram: () => useExecuteProgram,
65
- useExportNote: () => useExportNote,
66
- useExportStore: () => useExportStore,
67
- useImportAccount: () => useImportAccount,
68
- useImportNote: () => useImportNote,
69
- useImportStore: () => useImportStore,
70
- useMiden: () => useMiden,
71
- useMidenClient: () => useMidenClient,
72
- useMint: () => useMint,
73
- useMultiSend: () => useMultiSend,
74
- useMultiSigner: () => useMultiSigner,
75
- useNoteStream: () => useNoteStream,
76
- useNotes: () => useNotes,
77
- useSend: () => useSend,
78
- useSessionAccount: () => useSessionAccount,
79
- useSigner: () => useSigner,
80
- useSwap: () => useSwap,
81
- useSyncControl: () => useSyncControl,
82
- useSyncState: () => useSyncState,
83
- useTransaction: () => useTransaction,
84
- useTransactionHistory: () => useTransactionHistory,
85
- useWaitForCommit: () => useWaitForCommit,
86
- useWaitForNotes: () => useWaitForNotes,
87
- waitForWalletDetection: () => waitForWalletDetection,
88
- wrapWasmError: () => wrapWasmError
89
- });
90
- module.exports = __toCommonJS(index_exports);
91
-
92
1
  // src/types/augmentations.ts
93
- var import_miden_sdk = require("@miden-sdk/miden-sdk");
2
+ import "@miden-sdk/miden-sdk/mt";
94
3
 
95
4
  // src/utils/accountBech32.ts
96
- var import_miden_sdk3 = require("@miden-sdk/miden-sdk");
5
+ import {
6
+ Account,
7
+ AccountInterface,
8
+ Address as Address2,
9
+ NetworkId
10
+ } from "@miden-sdk/miden-sdk/mt";
97
11
 
98
12
  // src/store/MidenStore.ts
99
- var import_zustand = require("zustand");
13
+ import { create } from "zustand";
100
14
  var initialSyncState = {
101
15
  syncHeight: 0,
102
16
  isSyncing: false,
@@ -128,7 +42,7 @@ function freshState() {
128
42
  ...freshCachedState()
129
43
  };
130
44
  }
131
- var useMidenStore = (0, import_zustand.create)()((set) => ({
45
+ var useMidenStore = create()((set) => ({
132
46
  ...freshState(),
133
47
  setClient: (client) => set({
134
48
  client,
@@ -240,19 +154,19 @@ var useAssetMetadataStore = () => useMidenStore((state) => state.assetMetadata);
240
154
  var useNoteFirstSeenStore = () => useMidenStore((state) => state.noteFirstSeen);
241
155
 
242
156
  // src/utils/accountParsing.ts
243
- var import_miden_sdk2 = require("@miden-sdk/miden-sdk");
157
+ import { AccountId, Address } from "@miden-sdk/miden-sdk/mt";
244
158
  var normalizeAccountIdInput = (value) => value.trim().replace(/^miden:/i, "");
245
159
  var isBech32Input = (value) => value.startsWith("m") || value.startsWith("M");
246
160
  var normalizeHexInput = (value) => value.startsWith("0x") || value.startsWith("0X") ? value : `0x${value}`;
247
161
  var parseAccountIdFromString = (value) => {
248
162
  if (isBech32Input(value)) {
249
163
  try {
250
- return import_miden_sdk2.Address.fromBech32(value).accountId();
164
+ return Address.fromBech32(value).accountId();
251
165
  } catch {
252
- return import_miden_sdk2.AccountId.fromBech32(value);
166
+ return AccountId.fromBech32(value);
253
167
  }
254
168
  }
255
- return import_miden_sdk2.AccountId.fromHex(normalizeHexInput(value));
169
+ return AccountId.fromHex(normalizeHexInput(value));
256
170
  };
257
171
  var parseAccountId = (value) => {
258
172
  if (typeof value === "string") {
@@ -279,49 +193,49 @@ function isFaucetId(accountId) {
279
193
  var parseAddress = (value, accountId) => {
280
194
  if (typeof value !== "string") {
281
195
  const resolvedId = accountId ?? parseAccountId(value);
282
- return import_miden_sdk2.Address.fromAccountId(resolvedId, "BasicWallet");
196
+ return Address.fromAccountId(resolvedId, "BasicWallet");
283
197
  }
284
198
  const normalized = normalizeAccountIdInput(value);
285
199
  if (isBech32Input(normalized)) {
286
200
  try {
287
- return import_miden_sdk2.Address.fromBech32(normalized);
201
+ return Address.fromBech32(normalized);
288
202
  } catch {
289
- const resolvedAccountId2 = accountId ?? import_miden_sdk2.AccountId.fromBech32(normalized);
290
- return import_miden_sdk2.Address.fromAccountId(resolvedAccountId2, "BasicWallet");
203
+ const resolvedAccountId2 = accountId ?? AccountId.fromBech32(normalized);
204
+ return Address.fromAccountId(resolvedAccountId2, "BasicWallet");
291
205
  }
292
206
  }
293
- const resolvedAccountId = accountId ?? import_miden_sdk2.AccountId.fromHex(normalizeHexInput(normalized));
294
- return import_miden_sdk2.Address.fromAccountId(resolvedAccountId, "BasicWallet");
207
+ const resolvedAccountId = accountId ?? AccountId.fromHex(normalizeHexInput(normalized));
208
+ return Address.fromAccountId(resolvedAccountId, "BasicWallet");
295
209
  };
296
210
 
297
211
  // src/utils/accountBech32.ts
298
212
  var inferNetworkId = () => {
299
213
  const { rpcUrl } = useMidenStore.getState().config;
300
214
  if (!rpcUrl) {
301
- return import_miden_sdk3.NetworkId.testnet();
215
+ return NetworkId.testnet();
302
216
  }
303
217
  const url = rpcUrl.toLowerCase();
304
218
  if (url.includes("devnet") || url.includes("mdev")) {
305
- return import_miden_sdk3.NetworkId.devnet();
219
+ return NetworkId.devnet();
306
220
  }
307
221
  if (url.includes("mainnet")) {
308
- return import_miden_sdk3.NetworkId.mainnet();
222
+ return NetworkId.mainnet();
309
223
  }
310
224
  if (url.includes("testnet") || url.includes("mtst")) {
311
- return import_miden_sdk3.NetworkId.testnet();
225
+ return NetworkId.testnet();
312
226
  }
313
- return import_miden_sdk3.NetworkId.testnet();
227
+ return NetworkId.testnet();
314
228
  };
315
229
  var toBech32FromAccountId = (id) => {
316
230
  try {
317
- const address = import_miden_sdk3.Address.fromAccountId(id, "BasicWallet");
231
+ const address = Address2.fromAccountId(id, "BasicWallet");
318
232
  return address.toBech32(inferNetworkId());
319
233
  } catch {
320
234
  }
321
235
  try {
322
236
  const maybeBech32 = id.toBech32?.(
323
237
  inferNetworkId(),
324
- import_miden_sdk3.AccountInterface.BasicWallet
238
+ AccountInterface.BasicWallet
325
239
  );
326
240
  if (typeof maybeBech32 === "string") {
327
241
  return maybeBech32;
@@ -351,7 +265,7 @@ var defineBech32 = (target) => {
351
265
  }
352
266
  };
353
267
  var installAccountBech32 = () => {
354
- const proto = import_miden_sdk3.Account.prototype;
268
+ const proto = Account.prototype;
355
269
  if (proto.bech32id) {
356
270
  return;
357
271
  }
@@ -383,18 +297,26 @@ var toBech32AccountId = (accountId) => {
383
297
  };
384
298
 
385
299
  // src/context/MidenProvider.tsx
386
- var import_react2 = require("react");
387
- var import_miden_sdk6 = require("@miden-sdk/miden-sdk");
300
+ import {
301
+ createContext as createContext2,
302
+ useContext as useContext2,
303
+ useEffect,
304
+ useRef,
305
+ useCallback,
306
+ useMemo,
307
+ useState
308
+ } from "react";
309
+ import { WasmWebClient as WebClient } from "@miden-sdk/miden-sdk/mt";
388
310
 
389
311
  // src/types/index.ts
390
- var import_miden_sdk4 = require("@miden-sdk/miden-sdk");
312
+ import { AuthScheme } from "@miden-sdk/miden-sdk/mt";
391
313
  var DEFAULTS = {
392
314
  RPC_URL: void 0,
393
315
  // Will use SDK's testnet default
394
316
  AUTO_SYNC_INTERVAL: 15e3,
395
317
  STORAGE_MODE: "private",
396
318
  WALLET_MUTABLE: true,
397
- AUTH_SCHEME: import_miden_sdk4.AuthScheme.AuthRpoFalcon512,
319
+ AUTH_SCHEME: AuthScheme.AuthRpoFalcon512,
398
320
  NOTE_TYPE: "private",
399
321
  FAUCET_DECIMALS: 8
400
322
  };
@@ -438,7 +360,7 @@ function resolveRpcUrl(rpcUrl) {
438
360
  }
439
361
 
440
362
  // src/utils/prover.ts
441
- var import_miden_sdk5 = require("@miden-sdk/miden-sdk");
363
+ import { TransactionProver } from "@miden-sdk/miden-sdk/mt";
442
364
  var DEFAULT_PROVER_URLS = {
443
365
  devnet: "https://tx-prover.devnet.miden.io",
444
366
  testnet: "https://tx-prover.testnet.miden.io"
@@ -477,16 +399,16 @@ function resolveProverTarget(target, config) {
477
399
  if (typeof target === "string") {
478
400
  const normalized = target.trim().toLowerCase();
479
401
  if (normalized === "local" || normalized === "localhost") {
480
- return import_miden_sdk5.TransactionProver.newLocalProver();
402
+ return TransactionProver.newLocalProver();
481
403
  }
482
404
  if (normalized === "devnet" || normalized === "testnet") {
483
405
  const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized];
484
- return import_miden_sdk5.TransactionProver.newRemoteProver(
406
+ return TransactionProver.newRemoteProver(
485
407
  url,
486
408
  normalizeTimeout(config.proverTimeoutMs)
487
409
  );
488
410
  }
489
- return import_miden_sdk5.TransactionProver.newRemoteProver(
411
+ return TransactionProver.newRemoteProver(
490
412
  target,
491
413
  normalizeTimeout(config.proverTimeoutMs)
492
414
  );
@@ -498,7 +420,7 @@ function createRemoteProver(config, fallbackTimeout) {
498
420
  if (!url) {
499
421
  throw new Error("Remote prover requires a URL");
500
422
  }
501
- return import_miden_sdk5.TransactionProver.newRemoteProver(
423
+ return TransactionProver.newRemoteProver(
502
424
  url,
503
425
  normalizeTimeout(timeoutMs ?? fallbackTimeout)
504
426
  );
@@ -514,35 +436,28 @@ function normalizeTimeout(timeoutMs) {
514
436
  }
515
437
 
516
438
  // src/context/SignerContext.ts
517
- var import_react = require("react");
518
- var SignerContext = (0, import_react.createContext)(null);
439
+ import { createContext, useContext } from "react";
440
+ var SignerContext = createContext(null);
519
441
  function useSigner() {
520
- return (0, import_react.useContext)(SignerContext);
442
+ return useContext(SignerContext);
521
443
  }
522
444
 
523
445
  // src/utils/signerAccount.ts
524
- var WASM_ACCOUNT_TYPE = {
525
- FungibleFaucet: 0,
526
- NonFungibleFaucet: 1,
527
- RegularAccountImmutableCode: 2,
528
- RegularAccountUpdatableCode: 3
529
- };
530
- function getAccountType(accountType) {
531
- return WASM_ACCOUNT_TYPE[accountType] ?? WASM_ACCOUNT_TYPE.RegularAccountImmutableCode;
532
- }
533
446
  function isPrivateStorageMode(storageMode) {
534
447
  return storageMode.toString() === "private";
535
448
  }
536
449
  async function initializeSignerAccount(client, config) {
537
- const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk");
450
+ const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk/mt");
538
451
  await client.syncState();
539
452
  if (config.importAccountId) {
540
453
  const accountId2 = parseAccountId(config.importAccountId);
541
454
  try {
542
455
  await client.importAccountById(accountId2);
543
456
  } catch (e) {
544
- const msg = e instanceof Error ? e.message : String(e);
545
- if (!msg.includes("already being tracked")) {
457
+ const code = e?.code;
458
+ const isFreshAccount = code === "ACCOUNT_NOT_FOUND_ON_CHAIN";
459
+ const isAlreadyTracked = code === "ACCOUNT_ALREADY_TRACKED";
460
+ if (!isAlreadyTracked && !isFreshAccount) {
546
461
  throw e;
547
462
  }
548
463
  }
@@ -551,13 +466,12 @@ async function initializeSignerAccount(client, config) {
551
466
  }
552
467
  const commitmentWord = Word2.deserialize(config.publicKeyCommitment);
553
468
  const seed = config.accountSeed ?? crypto.getRandomValues(new Uint8Array(32));
554
- const accountType = getAccountType(config.accountType);
555
469
  let builder = new AccountBuilder(seed).withAuthComponent(
556
470
  AccountComponent.createAuthComponentFromCommitment(
557
471
  commitmentWord,
558
472
  AuthScheme2.AuthEcdsaK256Keccak
559
473
  )
560
- ).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
474
+ ).storageMode(config.storageMode).withBasicWalletComponent();
561
475
  if (config.customComponents?.length) {
562
476
  for (const component of config.customComponents) {
563
477
  if (component == null || typeof component.getProcedures !== "function") {
@@ -593,8 +507,8 @@ async function initializeSignerAccount(client, config) {
593
507
  }
594
508
 
595
509
  // src/context/MidenProvider.tsx
596
- var import_jsx_runtime = require("react/jsx-runtime");
597
- var MidenContext = (0, import_react2.createContext)(null);
510
+ import { Fragment, jsx } from "react/jsx-runtime";
511
+ var MidenContext = createContext2(null);
598
512
  function MidenProvider({
599
513
  children,
600
514
  config = {},
@@ -614,34 +528,39 @@ function MidenProvider({
614
528
  setSyncState,
615
529
  setSignerConnected
616
530
  } = useMidenStore();
617
- const syncIntervalRef = (0, import_react2.useRef)(null);
618
- const isInitializedRef = (0, import_react2.useRef)(false);
619
- const clientLockRef = (0, import_react2.useRef)(new AsyncLock());
620
- const currentStoreNameRef = (0, import_react2.useRef)(null);
621
- const signCbRef = (0, import_react2.useRef)(null);
531
+ const syncIntervalRef = useRef(null);
532
+ const isInitializedRef = useRef(false);
533
+ const clientLockRef = useRef(new AsyncLock());
534
+ const currentStoreNameRef = useRef(null);
535
+ const signCbRef = useRef(null);
622
536
  const signerContext = useSigner();
623
- const [signerAccountId, setSignerAccountId] = (0, import_react2.useState)(null);
624
- const resolvedConfig = (0, import_react2.useMemo)(
537
+ const [signerAccountId, setSignerAccountId] = useState(null);
538
+ const resolvedConfig = useMemo(
625
539
  () => ({
626
540
  ...config,
627
541
  rpcUrl: resolveRpcUrl(config.rpcUrl)
628
542
  }),
629
543
  [config]
630
544
  );
631
- const defaultProver = (0, import_react2.useMemo)(
632
- () => resolveTransactionProver(resolvedConfig),
633
- [
634
- resolvedConfig.prover,
635
- resolvedConfig.proverTimeoutMs,
636
- resolvedConfig.proverUrls?.devnet,
637
- resolvedConfig.proverUrls?.testnet
638
- ]
639
- );
640
- const runExclusive = (0, import_react2.useCallback)(
545
+ const [defaultProver, setDefaultProver] = useState(null);
546
+ useEffect(() => {
547
+ if (!isReady) {
548
+ setDefaultProver(null);
549
+ return;
550
+ }
551
+ setDefaultProver(resolveTransactionProver(resolvedConfig));
552
+ }, [
553
+ isReady,
554
+ resolvedConfig.prover,
555
+ resolvedConfig.proverTimeoutMs,
556
+ resolvedConfig.proverUrls?.devnet,
557
+ resolvedConfig.proverUrls?.testnet
558
+ ]);
559
+ const runExclusive = useCallback(
641
560
  async (fn) => clientLockRef.current.runExclusive(fn),
642
561
  []
643
562
  );
644
- const sync = (0, import_react2.useCallback)(async () => {
563
+ const sync = useCallback(async () => {
645
564
  if (!client || !isReady) return;
646
565
  const store = useMidenStore.getState();
647
566
  if (store.sync.isSyncing) return;
@@ -668,10 +587,10 @@ function MidenProvider({
668
587
  const signerStoreName = signerContext?.storeName ?? null;
669
588
  const signerAccountType = signerContext?.accountConfig?.accountType ?? null;
670
589
  const signerStorageMode = signerContext?.accountConfig?.storageMode?.toString() ?? null;
671
- (0, import_react2.useEffect)(() => {
590
+ useEffect(() => {
672
591
  signCbRef.current = signerContext?.signCb ?? null;
673
592
  }, [signerContext?.signCb]);
674
- const wrappedSignCb = (0, import_react2.useCallback)(
593
+ const wrappedSignCb = useCallback(
675
594
  async (pubKey, signingInputs) => {
676
595
  const cb = signCbRef.current;
677
596
  if (!cb) {
@@ -681,7 +600,7 @@ function MidenProvider({
681
600
  },
682
601
  []
683
602
  );
684
- (0, import_react2.useEffect)(() => {
603
+ useEffect(() => {
685
604
  if (signerIsConnected === null && isInitializedRef.current) return;
686
605
  if (signerIsConnected === false) {
687
606
  const store = useMidenStore.getState();
@@ -715,14 +634,16 @@ function MidenProvider({
715
634
  if (signerContext && signerIsConnected === true) {
716
635
  const storeName = `MidenClientDB_${signerContext.storeName}`;
717
636
  signCbRef.current = signerContext.signCb;
718
- webClient = await import_miden_sdk6.WasmWebClient.createClientWithExternalKeystore(
637
+ webClient = await WebClient.createClientWithExternalKeystore(
719
638
  resolvedConfig.rpcUrl,
720
639
  resolvedConfig.noteTransportUrl,
721
640
  resolvedConfig.seed,
722
641
  storeName,
723
642
  signerContext.getKeyCb,
724
643
  signerContext.insertKeyCb,
725
- wrappedSignCb
644
+ wrappedSignCb,
645
+ void 0,
646
+ resolvedConfig.useWorker
726
647
  );
727
648
  if (cancelled) return;
728
649
  const accountId = await initializeSignerAccount(
@@ -735,10 +656,13 @@ function MidenProvider({
735
656
  currentStoreNameRef.current = signerContext.storeName;
736
657
  } else {
737
658
  const seed = resolvedConfig.seed;
738
- webClient = await import_miden_sdk6.WasmWebClient.createClient(
659
+ webClient = await WebClient.createClient(
739
660
  resolvedConfig.rpcUrl,
740
661
  resolvedConfig.noteTransportUrl,
741
- seed
662
+ seed,
663
+ void 0,
664
+ void 0,
665
+ resolvedConfig.useWorker
742
666
  );
743
667
  if (cancelled) return;
744
668
  }
@@ -804,7 +728,7 @@ function MidenProvider({
804
728
  // signCb changes are handled by the dedicated useEffect + signCbRef above,
805
729
  // not by this effect.
806
730
  ]);
807
- (0, import_react2.useEffect)(() => {
731
+ useEffect(() => {
808
732
  if (!isReady || !client) return;
809
733
  const interval = config.autoSyncInterval ?? DEFAULTS.AUTO_SYNC_INTERVAL;
810
734
  if (interval <= 0) return;
@@ -820,7 +744,7 @@ function MidenProvider({
820
744
  }
821
745
  };
822
746
  }, [isReady, client, config.autoSyncInterval, sync]);
823
- (0, import_react2.useEffect)(() => {
747
+ useEffect(() => {
824
748
  if (!isReady || !client) return;
825
749
  const unsubscribe = client.onStateChanged?.(async () => {
826
750
  try {
@@ -835,13 +759,13 @@ function MidenProvider({
835
759
  };
836
760
  }, [isReady, client, setSyncState]);
837
761
  if (isInitializing && loadingComponent) {
838
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: loadingComponent });
762
+ return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
839
763
  }
840
764
  if (initError && errorComponent) {
841
765
  if (typeof errorComponent === "function") {
842
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: errorComponent(initError) });
766
+ return /* @__PURE__ */ jsx(Fragment, { children: errorComponent(initError) });
843
767
  }
844
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: errorComponent });
768
+ return /* @__PURE__ */ jsx(Fragment, { children: errorComponent });
845
769
  }
846
770
  const contextValue = {
847
771
  client,
@@ -854,10 +778,10 @@ function MidenProvider({
854
778
  signerAccountId,
855
779
  signerConnected
856
780
  };
857
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MidenContext.Provider, { value: contextValue, children });
781
+ return /* @__PURE__ */ jsx(MidenContext.Provider, { value: contextValue, children });
858
782
  }
859
783
  function useMiden() {
860
- const context = (0, import_react2.useContext)(MidenContext);
784
+ const context = useContext2(MidenContext);
861
785
  if (!context) {
862
786
  throw new Error("useMiden must be used within a MidenProvider");
863
787
  }
@@ -874,22 +798,30 @@ function useMidenClient() {
874
798
  }
875
799
 
876
800
  // src/context/MultiSignerProvider.tsx
877
- var import_react3 = require("react");
878
- var import_jsx_runtime2 = require("react/jsx-runtime");
879
- var MultiSignerRegistryContext = (0, import_react3.createContext)(null);
880
- var MultiSignerContext = (0, import_react3.createContext)(null);
801
+ import {
802
+ createContext as createContext3,
803
+ useContext as useContext3,
804
+ useEffect as useEffect2,
805
+ useRef as useRef2,
806
+ useState as useState2,
807
+ useCallback as useCallback2,
808
+ useMemo as useMemo2
809
+ } from "react";
810
+ import { jsx as jsx2 } from "react/jsx-runtime";
811
+ var MultiSignerRegistryContext = createContext3(null);
812
+ var MultiSignerContext = createContext3(null);
881
813
  function MultiSignerProvider({ children }) {
882
- const signersRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
883
- const [signersSnapshot, setSignersSnapshot] = (0, import_react3.useState)(
814
+ const signersRef = useRef2(/* @__PURE__ */ new Map());
815
+ const [signersSnapshot, setSignersSnapshot] = useState2(
884
816
  []
885
817
  );
886
- const [activeSignerName, setActiveSignerName] = (0, import_react3.useState)(null);
887
- const activeSignerNameRef = (0, import_react3.useRef)(null);
888
- const generationRef = (0, import_react3.useRef)(0);
889
- const updateSnapshot = (0, import_react3.useCallback)(() => {
818
+ const [activeSignerName, setActiveSignerName] = useState2(null);
819
+ const activeSignerNameRef = useRef2(null);
820
+ const generationRef = useRef2(0);
821
+ const updateSnapshot = useCallback2(() => {
890
822
  setSignersSnapshot(Array.from(signersRef.current.values()));
891
823
  }, []);
892
- const register = (0, import_react3.useCallback)(
824
+ const register = useCallback2(
893
825
  (value) => {
894
826
  const prev = signersRef.current.get(value.name);
895
827
  signersRef.current.set(value.name, value);
@@ -899,7 +831,7 @@ function MultiSignerProvider({ children }) {
899
831
  },
900
832
  [updateSnapshot]
901
833
  );
902
- const unregister = (0, import_react3.useCallback)(
834
+ const unregister = useCallback2(
903
835
  (name) => {
904
836
  signersRef.current.delete(name);
905
837
  setActiveSignerName((current) => current === name ? null : current);
@@ -907,12 +839,12 @@ function MultiSignerProvider({ children }) {
907
839
  },
908
840
  [updateSnapshot]
909
841
  );
910
- const registry = (0, import_react3.useMemo)(
842
+ const registry = useMemo2(
911
843
  () => ({ register, unregister }),
912
844
  [register, unregister]
913
845
  );
914
846
  const activeSigner = activeSignerName ? signersSnapshot.find((s) => s.name === activeSignerName) ?? null : null;
915
- const stableSignCb = (0, import_react3.useCallback)(
847
+ const stableSignCb = useCallback2(
916
848
  async (pubKey, signingInputs) => {
917
849
  const name = activeSignerName;
918
850
  if (!name) throw new Error("No active signer (signer was disconnected)");
@@ -922,21 +854,21 @@ function MultiSignerProvider({ children }) {
922
854
  },
923
855
  [activeSignerName]
924
856
  );
925
- const stableConnect = (0, import_react3.useCallback)(async () => {
857
+ const stableConnect = useCallback2(async () => {
926
858
  const name = activeSignerName;
927
859
  if (!name) throw new Error("No active signer (signer was disconnected)");
928
860
  const signer = signersRef.current.get(name);
929
861
  if (!signer) throw new Error(`Signer "${name}" not found in registry`);
930
862
  return signer.connect();
931
863
  }, [activeSignerName]);
932
- const stableDisconnect = (0, import_react3.useCallback)(async () => {
864
+ const stableDisconnect = useCallback2(async () => {
933
865
  const name = activeSignerName;
934
866
  if (!name) throw new Error("No active signer (signer was disconnected)");
935
867
  const signer = signersRef.current.get(name);
936
868
  if (!signer) throw new Error(`Signer "${name}" not found in registry`);
937
869
  return signer.disconnect();
938
870
  }, [activeSignerName]);
939
- const forwardedValue = (0, import_react3.useMemo)(() => {
871
+ const forwardedValue = useMemo2(() => {
940
872
  if (!activeSigner) return null;
941
873
  return {
942
874
  name: activeSigner.name,
@@ -956,11 +888,11 @@ function MultiSignerProvider({ children }) {
956
888
  stableConnect,
957
889
  stableDisconnect
958
890
  ]);
959
- const setActiveName = (0, import_react3.useCallback)((name) => {
891
+ const setActiveName = useCallback2((name) => {
960
892
  activeSignerNameRef.current = name;
961
893
  setActiveSignerName(name);
962
894
  }, []);
963
- const connectSigner = (0, import_react3.useCallback)(
895
+ const connectSigner = useCallback2(
964
896
  async (name) => {
965
897
  const currentName = activeSignerNameRef.current;
966
898
  const currentSigner = currentName ? signersRef.current.get(currentName) : null;
@@ -985,7 +917,7 @@ function MultiSignerProvider({ children }) {
985
917
  },
986
918
  [setActiveName]
987
919
  );
988
- const disconnectSigner = (0, import_react3.useCallback)(async () => {
920
+ const disconnectSigner = useCallback2(async () => {
989
921
  ++generationRef.current;
990
922
  const currentName = activeSignerNameRef.current;
991
923
  const signer = currentName ? signersRef.current.get(currentName) : null;
@@ -996,7 +928,7 @@ function MultiSignerProvider({ children }) {
996
928
  });
997
929
  }
998
930
  }, [setActiveName]);
999
- const multiSignerValue = (0, import_react3.useMemo)(
931
+ const multiSignerValue = useMemo2(
1000
932
  () => ({
1001
933
  signers: signersSnapshot,
1002
934
  activeSigner,
@@ -1005,18 +937,18 @@ function MultiSignerProvider({ children }) {
1005
937
  }),
1006
938
  [signersSnapshot, activeSigner, connectSigner, disconnectSigner]
1007
939
  );
1008
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SignerContext.Provider, { value: forwardedValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MultiSignerRegistryContext.Provider, { value: registry, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MultiSignerContext.Provider, { value: multiSignerValue, children }) }) });
940
+ return /* @__PURE__ */ jsx2(SignerContext.Provider, { value: forwardedValue, children: /* @__PURE__ */ jsx2(MultiSignerRegistryContext.Provider, { value: registry, children: /* @__PURE__ */ jsx2(MultiSignerContext.Provider, { value: multiSignerValue, children }) }) });
1009
941
  }
1010
942
  function SignerSlot() {
1011
943
  const signerValue = useSigner();
1012
- const registry = (0, import_react3.useContext)(MultiSignerRegistryContext);
1013
- const nameRef = (0, import_react3.useRef)();
1014
- (0, import_react3.useEffect)(() => {
944
+ const registry = useContext3(MultiSignerRegistryContext);
945
+ const nameRef = useRef2();
946
+ useEffect2(() => {
1015
947
  if (!signerValue || !registry) return;
1016
948
  nameRef.current = signerValue.name;
1017
949
  registry.register(signerValue);
1018
950
  }, [signerValue, registry]);
1019
- (0, import_react3.useEffect)(() => {
951
+ useEffect2(() => {
1020
952
  return () => {
1021
953
  if (nameRef.current && registry) {
1022
954
  registry.unregister(nameRef.current);
@@ -1026,18 +958,18 @@ function SignerSlot() {
1026
958
  return null;
1027
959
  }
1028
960
  function useMultiSigner() {
1029
- return (0, import_react3.useContext)(MultiSignerContext);
961
+ return useContext3(MultiSignerContext);
1030
962
  }
1031
963
 
1032
964
  // src/hooks/useAccounts.ts
1033
- var import_react4 = require("react");
965
+ import { useCallback as useCallback3, useEffect as useEffect3 } from "react";
1034
966
  function useAccounts() {
1035
967
  const { client, isReady } = useMiden();
1036
968
  const accounts = useAccountsStore();
1037
969
  const isLoadingAccounts = useMidenStore((state) => state.isLoadingAccounts);
1038
970
  const setLoadingAccounts = useMidenStore((state) => state.setLoadingAccounts);
1039
971
  const setAccounts = useMidenStore((state) => state.setAccounts);
1040
- const refetch = (0, import_react4.useCallback)(async () => {
972
+ const refetch = useCallback3(async () => {
1041
973
  if (!client || !isReady) return;
1042
974
  setLoadingAccounts(true);
1043
975
  try {
@@ -1049,7 +981,7 @@ function useAccounts() {
1049
981
  setLoadingAccounts(false);
1050
982
  }
1051
983
  }, [client, isReady, setAccounts, setLoadingAccounts]);
1052
- (0, import_react4.useEffect)(() => {
984
+ useEffect3(() => {
1053
985
  if (isReady && accounts.length === 0) {
1054
986
  refetch();
1055
987
  }
@@ -1075,11 +1007,15 @@ function useAccounts() {
1075
1007
  }
1076
1008
 
1077
1009
  // src/hooks/useAccount.ts
1078
- var import_react6 = require("react");
1010
+ import { useCallback as useCallback4, useEffect as useEffect5, useState as useState3, useMemo as useMemo4 } from "react";
1079
1011
 
1080
1012
  // src/hooks/useAssetMetadata.ts
1081
- var import_react5 = require("react");
1082
- var import_miden_sdk7 = require("@miden-sdk/miden-sdk");
1013
+ import { useEffect as useEffect4, useMemo as useMemo3 } from "react";
1014
+ import {
1015
+ BasicFungibleFaucetComponent,
1016
+ Endpoint,
1017
+ RpcClient
1018
+ } from "@miden-sdk/miden-sdk/mt";
1083
1019
  var inflight = /* @__PURE__ */ new Map();
1084
1020
  var rpcClients = /* @__PURE__ */ new Map();
1085
1021
  var getRpcClient = (rpcUrl) => {
@@ -1087,8 +1023,8 @@ var getRpcClient = (rpcUrl) => {
1087
1023
  const existing = rpcClients.get(key);
1088
1024
  if (existing) return existing;
1089
1025
  try {
1090
- const endpoint = rpcUrl ? new import_miden_sdk7.Endpoint(rpcUrl) : import_miden_sdk7.Endpoint.testnet();
1091
- const client = new import_miden_sdk7.RpcClient(endpoint);
1026
+ const endpoint = rpcUrl ? new Endpoint(rpcUrl) : Endpoint.testnet();
1027
+ const client = new RpcClient(endpoint);
1092
1028
  rpcClients.set(key, client);
1093
1029
  return client;
1094
1030
  } catch {
@@ -1102,7 +1038,7 @@ var fetchAssetMetadata = async (rpcClient, assetId) => {
1102
1038
  const fetched = await rpcClient.getAccountDetails(accountId);
1103
1039
  const account = fetched.account?.();
1104
1040
  if (!account) return null;
1105
- const faucet = import_miden_sdk7.BasicFungibleFaucetComponent.fromAccount(account);
1041
+ const faucet = BasicFungibleFaucetComponent.fromAccount(account);
1106
1042
  const symbol = faucet.symbol().toString();
1107
1043
  const decimals = faucet.decimals();
1108
1044
  return { assetId, symbol, decimals };
@@ -1114,12 +1050,12 @@ function useAssetMetadata(assetIds = []) {
1114
1050
  const assetMetadata = useAssetMetadataStore();
1115
1051
  const setAssetMetadata = useMidenStore((state) => state.setAssetMetadata);
1116
1052
  const rpcUrl = useMidenStore((state) => state.config.rpcUrl);
1117
- const rpcClient = (0, import_react5.useMemo)(() => getRpcClient(rpcUrl), [rpcUrl]);
1118
- const uniqueAssetIds = (0, import_react5.useMemo)(
1053
+ const rpcClient = useMemo3(() => getRpcClient(rpcUrl), [rpcUrl]);
1054
+ const uniqueAssetIds = useMemo3(
1119
1055
  () => Array.from(new Set(assetIds.filter(Boolean))),
1120
1056
  [assetIds]
1121
1057
  );
1122
- (0, import_react5.useEffect)(() => {
1058
+ useEffect4(() => {
1123
1059
  if (!rpcClient || uniqueAssetIds.length === 0) return;
1124
1060
  uniqueAssetIds.forEach((assetId) => {
1125
1061
  const existing = assetMetadata.get(assetId);
@@ -1142,15 +1078,15 @@ function useAccount(accountId) {
1142
1078
  const accountDetails = useMidenStore((state) => state.accountDetails);
1143
1079
  const setAccountDetails = useMidenStore((state) => state.setAccountDetails);
1144
1080
  const { lastSyncTime } = useSyncStateStore();
1145
- const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
1146
- const [error, setError] = (0, import_react6.useState)(null);
1147
- const accountIdStr = (0, import_react6.useMemo)(() => {
1081
+ const [isLoading, setIsLoading] = useState3(false);
1082
+ const [error, setError] = useState3(null);
1083
+ const accountIdStr = useMemo4(() => {
1148
1084
  if (!accountId) return void 0;
1149
1085
  if (typeof accountId === "string") return accountId;
1150
1086
  return parseAccountId(accountId).toString();
1151
1087
  }, [accountId]);
1152
1088
  const account = accountIdStr ? accountDetails.get(accountIdStr) ?? null : null;
1153
- const refetch = (0, import_react6.useCallback)(async () => {
1089
+ const refetch = useCallback4(async () => {
1154
1090
  if (!client || !isReady || !accountIdStr) return;
1155
1091
  setIsLoading(true);
1156
1092
  setError(null);
@@ -1167,16 +1103,16 @@ function useAccount(accountId) {
1167
1103
  setIsLoading(false);
1168
1104
  }
1169
1105
  }, [client, isReady, accountIdStr, setAccountDetails]);
1170
- (0, import_react6.useEffect)(() => {
1106
+ useEffect5(() => {
1171
1107
  if (isReady && accountIdStr && !account) {
1172
1108
  refetch();
1173
1109
  }
1174
1110
  }, [isReady, accountIdStr, account, refetch]);
1175
- (0, import_react6.useEffect)(() => {
1111
+ useEffect5(() => {
1176
1112
  if (!isReady || !accountIdStr || !lastSyncTime) return;
1177
1113
  refetch();
1178
1114
  }, [isReady, accountIdStr, lastSyncTime, refetch]);
1179
- const rawAssets = (0, import_react6.useMemo)(() => {
1115
+ const rawAssets = useMemo4(() => {
1180
1116
  if (!account) return [];
1181
1117
  try {
1182
1118
  const vault = account.vault();
@@ -1193,12 +1129,12 @@ function useAccount(accountId) {
1193
1129
  return [];
1194
1130
  }
1195
1131
  }, [account]);
1196
- const assetIds = (0, import_react6.useMemo)(
1132
+ const assetIds = useMemo4(
1197
1133
  () => rawAssets.map((asset) => asset.assetId),
1198
1134
  [rawAssets]
1199
1135
  );
1200
1136
  const { assetMetadata } = useAssetMetadata(assetIds);
1201
- const assets = (0, import_react6.useMemo)(
1137
+ const assets = useMemo4(
1202
1138
  () => rawAssets.map((asset) => {
1203
1139
  const metadata = assetMetadata.get(asset.assetId);
1204
1140
  return {
@@ -1209,7 +1145,7 @@ function useAccount(accountId) {
1209
1145
  }),
1210
1146
  [rawAssets, assetMetadata]
1211
1147
  );
1212
- const getBalance = (0, import_react6.useCallback)(
1148
+ const getBalance = useCallback4(
1213
1149
  (assetId) => {
1214
1150
  const asset = assets.find((a) => a.assetId === assetId);
1215
1151
  return asset?.amount ?? 0n;
@@ -1227,8 +1163,8 @@ function useAccount(accountId) {
1227
1163
  }
1228
1164
 
1229
1165
  // src/hooks/useNotes.ts
1230
- var import_react7 = require("react");
1231
- var import_miden_sdk9 = require("@miden-sdk/miden-sdk");
1166
+ import { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo5, useState as useState4 } from "react";
1167
+ import { NoteFilter } from "@miden-sdk/miden-sdk/mt";
1232
1168
 
1233
1169
  // src/utils/amounts.ts
1234
1170
  var formatAssetAmount = (amount, decimals) => {
@@ -1270,6 +1206,27 @@ var parseAssetAmount = (input, decimals) => {
1270
1206
  };
1271
1207
 
1272
1208
  // src/utils/notes.ts
1209
+ var resolveNoteInput = async (input, client) => {
1210
+ if (typeof input === "string") {
1211
+ const record2 = await client.getInputNote(input);
1212
+ if (!record2) {
1213
+ throw new Error(`Note not found: ${input}`);
1214
+ }
1215
+ return record2.toNote();
1216
+ }
1217
+ if (typeof input.toNote === "function") {
1218
+ return input.toNote();
1219
+ }
1220
+ if (typeof input.id === "function") {
1221
+ return input;
1222
+ }
1223
+ const hex = input.toString();
1224
+ const record = await client.getInputNote(hex);
1225
+ if (!record) {
1226
+ throw new Error(`Note not found: ${hex}`);
1227
+ }
1228
+ return record.toNote();
1229
+ };
1273
1230
  var getInputNoteRecord = (note) => {
1274
1231
  const maybeConsumable = note;
1275
1232
  if (typeof maybeConsumable.inputNoteRecord === "function") {
@@ -1280,7 +1237,9 @@ var getInputNoteRecord = (note) => {
1280
1237
  var getNoteSummary = (note, getAssetMetadata) => {
1281
1238
  try {
1282
1239
  const record = getInputNoteRecord(note);
1283
- const id = record.id().toString();
1240
+ const rawId = record.id();
1241
+ if (!rawId) return null;
1242
+ const id = rawId.toString();
1284
1243
  const assets = [];
1285
1244
  try {
1286
1245
  const details = record.details();
@@ -1333,30 +1292,34 @@ function accountIdsEqual(a, b) {
1333
1292
  }
1334
1293
 
1335
1294
  // src/utils/noteFilters.ts
1336
- var import_miden_sdk8 = require("@miden-sdk/miden-sdk");
1295
+ import {
1296
+ NoteFilterTypes,
1297
+ NoteType,
1298
+ TransactionFilter
1299
+ } from "@miden-sdk/miden-sdk/mt";
1337
1300
  function getNoteFilterType(status) {
1338
1301
  switch (status) {
1339
1302
  case "consumed":
1340
- return import_miden_sdk8.NoteFilterTypes.Consumed;
1303
+ return NoteFilterTypes.Consumed;
1341
1304
  case "committed":
1342
- return import_miden_sdk8.NoteFilterTypes.Committed;
1305
+ return NoteFilterTypes.Committed;
1343
1306
  case "expected":
1344
- return import_miden_sdk8.NoteFilterTypes.Expected;
1307
+ return NoteFilterTypes.Expected;
1345
1308
  case "processing":
1346
- return import_miden_sdk8.NoteFilterTypes.Processing;
1309
+ return NoteFilterTypes.Processing;
1347
1310
  case "all":
1348
1311
  default:
1349
- return import_miden_sdk8.NoteFilterTypes.All;
1312
+ return NoteFilterTypes.All;
1350
1313
  }
1351
1314
  }
1352
1315
  function getNoteType(type) {
1353
1316
  switch (type) {
1354
1317
  case "private":
1355
- return import_miden_sdk8.NoteType.Private;
1318
+ return NoteType.Private;
1356
1319
  case "public":
1357
- return import_miden_sdk8.NoteType.Public;
1320
+ return NoteType.Public;
1358
1321
  default:
1359
- return import_miden_sdk8.NoteType.Private;
1322
+ return NoteType.Private;
1360
1323
  }
1361
1324
  }
1362
1325
  async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWaitMs = 1e4, delayMs = 1e3) {
@@ -1365,7 +1328,7 @@ async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWa
1365
1328
  while (Date.now() < deadline) {
1366
1329
  await runExclusiveSafe(() => client.syncState());
1367
1330
  const records = await runExclusiveSafe(
1368
- () => client.getTransactions(import_miden_sdk8.TransactionFilter.all())
1331
+ () => client.getTransactions(TransactionFilter.all())
1369
1332
  );
1370
1333
  const record = records.find(
1371
1334
  (r) => normalizeHex(r.id().toHex()) === targetHex
@@ -1401,14 +1364,14 @@ function useNotes(options) {
1401
1364
  (state) => state.setConsumableNotesIfChanged
1402
1365
  );
1403
1366
  const { lastSyncTime } = useSyncStateStore();
1404
- const [error, setError] = (0, import_react7.useState)(null);
1405
- const refetch = (0, import_react7.useCallback)(async () => {
1367
+ const [error, setError] = useState4(null);
1368
+ const refetch = useCallback5(async () => {
1406
1369
  if (!client || !isReady) return;
1407
1370
  setLoadingNotes(true);
1408
1371
  setError(null);
1409
1372
  try {
1410
1373
  const filterType = getNoteFilterType(options?.status);
1411
- const filter = new import_miden_sdk9.NoteFilter(filterType);
1374
+ const filter = new NoteFilter(filterType);
1412
1375
  const fetchedNotes = await client.getInputNotes(filter);
1413
1376
  let fetchedConsumable;
1414
1377
  if (options?.accountId) {
@@ -1433,16 +1396,16 @@ function useNotes(options) {
1433
1396
  setNotesIfChanged,
1434
1397
  setConsumableNotesIfChanged
1435
1398
  ]);
1436
- (0, import_react7.useEffect)(() => {
1399
+ useEffect6(() => {
1437
1400
  if (isReady && notes.length === 0) {
1438
1401
  refetch();
1439
1402
  }
1440
1403
  }, [isReady, notes.length, refetch]);
1441
- (0, import_react7.useEffect)(() => {
1404
+ useEffect6(() => {
1442
1405
  if (!isReady || !lastSyncTime) return;
1443
1406
  refetch();
1444
1407
  }, [isReady, lastSyncTime, refetch]);
1445
- const noteAssetIds = (0, import_react7.useMemo)(() => {
1408
+ const noteAssetIds = useMemo5(() => {
1446
1409
  const ids = /* @__PURE__ */ new Set();
1447
1410
  const collect = (note) => {
1448
1411
  const summary = getNoteSummary(note);
@@ -1454,11 +1417,11 @@ function useNotes(options) {
1454
1417
  return Array.from(ids);
1455
1418
  }, [notes, consumableNotes]);
1456
1419
  const { assetMetadata } = useAssetMetadata(noteAssetIds);
1457
- const getMetadata = (0, import_react7.useCallback)(
1420
+ const getMetadata = useCallback5(
1458
1421
  (assetId) => assetMetadata.get(assetId),
1459
1422
  [assetMetadata]
1460
1423
  );
1461
- const normalizedSender = (0, import_react7.useMemo)(() => {
1424
+ const normalizedSender = useMemo5(() => {
1462
1425
  if (!options?.sender) return null;
1463
1426
  try {
1464
1427
  return normalizeAccountId(options.sender);
@@ -1466,11 +1429,11 @@ function useNotes(options) {
1466
1429
  return options.sender;
1467
1430
  }
1468
1431
  }, [options?.sender]);
1469
- const excludeIdsKey = (0, import_react7.useMemo)(() => {
1432
+ const excludeIdsKey = useMemo5(() => {
1470
1433
  if (!options?.excludeIds || options.excludeIds.length === 0) return "";
1471
1434
  return [...options.excludeIds].sort().join("\0");
1472
1435
  }, [options?.excludeIds]);
1473
- const filterBySender = (0, import_react7.useCallback)(
1436
+ const filterBySender = useCallback5(
1474
1437
  (summaries, target) => {
1475
1438
  const cache = /* @__PURE__ */ new Map();
1476
1439
  return summaries.filter((s) => {
@@ -1489,7 +1452,7 @@ function useNotes(options) {
1489
1452
  },
1490
1453
  []
1491
1454
  );
1492
- const noteSummaries = (0, import_react7.useMemo)(() => {
1455
+ const noteSummaries = useMemo5(() => {
1493
1456
  let summaries = notes.map((note) => getNoteSummary(note, getMetadata)).filter(Boolean);
1494
1457
  if (normalizedSender) {
1495
1458
  summaries = filterBySender(summaries, normalizedSender);
@@ -1500,7 +1463,7 @@ function useNotes(options) {
1500
1463
  }
1501
1464
  return summaries;
1502
1465
  }, [notes, getMetadata, normalizedSender, excludeIdsKey, filterBySender]);
1503
- const consumableNoteSummaries = (0, import_react7.useMemo)(() => {
1466
+ const consumableNoteSummaries = useMemo5(() => {
1504
1467
  let summaries = consumableNotes.map((note) => getNoteSummary(note, getMetadata)).filter(Boolean);
1505
1468
  if (normalizedSender) {
1506
1469
  summaries = filterBySender(summaries, normalizedSender);
@@ -1529,39 +1492,29 @@ function useNotes(options) {
1529
1492
  }
1530
1493
 
1531
1494
  // src/hooks/useNoteStream.ts
1532
- var import_react8 = require("react");
1533
- var import_miden_sdk11 = require("@miden-sdk/miden-sdk");
1495
+ import { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3, useState as useState5 } from "react";
1496
+ import { NoteFilter as NoteFilter2 } from "@miden-sdk/miden-sdk/mt";
1534
1497
 
1535
1498
  // src/utils/noteAttachment.ts
1536
- var import_miden_sdk10 = require("@miden-sdk/miden-sdk");
1499
+ import {
1500
+ NoteAttachment,
1501
+ NoteAttachmentScheme,
1502
+ Word
1503
+ } from "@miden-sdk/miden-sdk/mt";
1537
1504
  function readNoteAttachment(note) {
1538
1505
  try {
1539
- const metadata = note.metadata?.();
1540
- if (!metadata) return null;
1541
- const attachment = metadata.attachment?.();
1542
- if (!attachment) return null;
1543
- const kind = attachment.kind?.();
1544
- if (!kind) return null;
1545
- if (kind === import_miden_sdk10.NoteAttachmentKind.None) return null;
1546
- if (kind === import_miden_sdk10.NoteAttachmentKind.Word) {
1547
- const word = attachment.asWord?.();
1548
- if (!word) return null;
1549
- const u64s = word.toU64s();
1550
- const values = Array.from(u64s).map(
1551
- (v) => BigInt(v)
1552
- );
1553
- return { values, kind: "word" };
1554
- }
1555
- if (kind === import_miden_sdk10.NoteAttachmentKind.Array) {
1556
- const arr = attachment.asArray?.();
1557
- if (!arr) return null;
1558
- const u64s = arr.toU64s();
1559
- const values = Array.from(u64s).map(
1560
- (v) => BigInt(v)
1561
- );
1562
- return { values, kind: "array" };
1563
- }
1564
- return null;
1506
+ const attachments = note.attachments?.();
1507
+ if (!attachments || attachments.length === 0) return null;
1508
+ const words = attachments[0].toWords();
1509
+ if (words.length === 0) return null;
1510
+ const values = [];
1511
+ for (const word of words) {
1512
+ for (const value of word.toU64s()) {
1513
+ values.push(BigInt(value));
1514
+ }
1515
+ }
1516
+ if (values.every((value) => value === 0n)) return null;
1517
+ return { values, kind: words.length === 1 ? "word" : "array" };
1565
1518
  } catch {
1566
1519
  return null;
1567
1520
  }
@@ -1572,30 +1525,29 @@ function createNoteAttachment(values) {
1572
1525
  bigints.push(BigInt(values[i]));
1573
1526
  }
1574
1527
  if (bigints.length === 0) {
1575
- return new import_miden_sdk10.NoteAttachment();
1528
+ return emptyAttachment();
1576
1529
  }
1577
- const scheme = import_miden_sdk10.NoteAttachmentScheme.none();
1530
+ const scheme = NoteAttachmentScheme.none();
1578
1531
  if (bigints.length <= 4) {
1579
1532
  while (bigints.length < 4) {
1580
1533
  bigints.push(0n);
1581
1534
  }
1582
- const word = new import_miden_sdk10.Word(BigUint64Array.from(bigints));
1583
- return import_miden_sdk10.NoteAttachment.newWord(scheme, word);
1535
+ const word = new Word(BigUint64Array.from(bigints));
1536
+ return NoteAttachment.fromWord(scheme, word);
1584
1537
  }
1585
1538
  while (bigints.length % 4 !== 0) {
1586
1539
  bigints.push(0n);
1587
1540
  }
1588
1541
  const words = [];
1589
1542
  for (let i = 0; i < bigints.length; i += 4) {
1590
- words.push(new import_miden_sdk10.Word(BigUint64Array.from(bigints.slice(i, i + 4))));
1543
+ words.push(new Word(BigUint64Array.from(bigints.slice(i, i + 4))));
1591
1544
  }
1592
- const newArray = import_miden_sdk10.NoteAttachment["newArray"];
1593
- if (typeof newArray !== "function") {
1594
- throw new Error(
1595
- "NoteAttachment.newArray is not available. Ensure @miden-sdk/miden-sdk >= 0.13.1."
1596
- );
1597
- }
1598
- return newArray.call(import_miden_sdk10.NoteAttachment, scheme, words);
1545
+ return NoteAttachment.fromWords(scheme, words);
1546
+ }
1547
+ function emptyAttachment() {
1548
+ const scheme = NoteAttachmentScheme.none();
1549
+ const word = new Word(BigUint64Array.from([0n, 0n, 0n, 0n]));
1550
+ return NoteAttachment.fromWord(scheme, word);
1599
1551
  }
1600
1552
 
1601
1553
  // src/hooks/useNoteStream.ts
@@ -1605,32 +1557,32 @@ function useNoteStream(options = {}) {
1605
1557
  const noteFirstSeen = useNoteFirstSeenStore();
1606
1558
  const { lastSyncTime } = useSyncStateStore();
1607
1559
  const setNotesIfChanged = useMidenStore((state) => state.setNotesIfChanged);
1608
- const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
1609
- const [error, setError] = (0, import_react8.useState)(null);
1610
- const handledIdsRef = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
1611
- const [handledVersion, setHandledVersion] = (0, import_react8.useState)(0);
1560
+ const [isLoading, setIsLoading] = useState5(false);
1561
+ const [error, setError] = useState5(null);
1562
+ const handledIdsRef = useRef3(/* @__PURE__ */ new Set());
1563
+ const [handledVersion, setHandledVersion] = useState5(0);
1612
1564
  const status = options.status ?? "committed";
1613
1565
  const sender = options.sender ?? null;
1614
1566
  const since = options.since;
1615
- const amountFilterRef = (0, import_react8.useRef)(options.amountFilter);
1567
+ const amountFilterRef = useRef3(options.amountFilter);
1616
1568
  amountFilterRef.current = options.amountFilter;
1617
- const excludeIdsKey = (0, import_react8.useMemo)(() => {
1569
+ const excludeIdsKey = useMemo6(() => {
1618
1570
  if (!options.excludeIds) return "";
1619
1571
  if (options.excludeIds instanceof Set)
1620
1572
  return Array.from(options.excludeIds).sort().join("\0");
1621
1573
  return [...options.excludeIds].sort().join("\0");
1622
1574
  }, [options.excludeIds]);
1623
- const excludeIdSet = (0, import_react8.useMemo)(() => {
1575
+ const excludeIdSet = useMemo6(() => {
1624
1576
  if (!excludeIdsKey) return null;
1625
1577
  return new Set(excludeIdsKey.split("\0"));
1626
1578
  }, [excludeIdsKey]);
1627
- const refetch = (0, import_react8.useCallback)(async () => {
1579
+ const refetch = useCallback6(async () => {
1628
1580
  if (!client || !isReady) return;
1629
1581
  setIsLoading(true);
1630
1582
  setError(null);
1631
1583
  try {
1632
1584
  const filterType = getNoteFilterType(status);
1633
- const filter = new import_miden_sdk11.NoteFilter(filterType);
1585
+ const filter = new NoteFilter2(filterType);
1634
1586
  const fetched = await client.getInputNotes(filter);
1635
1587
  setNotesIfChanged(fetched);
1636
1588
  } catch (err) {
@@ -1639,12 +1591,12 @@ function useNoteStream(options = {}) {
1639
1591
  setIsLoading(false);
1640
1592
  }
1641
1593
  }, [client, isReady, status, setNotesIfChanged]);
1642
- (0, import_react8.useEffect)(() => {
1594
+ useEffect7(() => {
1643
1595
  if (isReady) {
1644
1596
  refetch();
1645
1597
  }
1646
1598
  }, [isReady, lastSyncTime, refetch]);
1647
- const streamedNotes = (0, import_react8.useMemo)(() => {
1599
+ const streamedNotes = useMemo6(() => {
1648
1600
  void handledVersion;
1649
1601
  const result = [];
1650
1602
  let normalizedSender = null;
@@ -1669,15 +1621,15 @@ function useNoteStream(options = {}) {
1669
1621
  result.sort((a, b) => a.firstSeenAt - b.firstSeenAt);
1670
1622
  return result;
1671
1623
  }, [allNotes, noteFirstSeen, excludeIdSet, sender, since, handledVersion]);
1672
- const latest = (0, import_react8.useMemo)(
1624
+ const latest = useMemo6(
1673
1625
  () => streamedNotes.length > 0 ? streamedNotes[streamedNotes.length - 1] : null,
1674
1626
  [streamedNotes]
1675
1627
  );
1676
- const markHandled = (0, import_react8.useCallback)((noteId) => {
1628
+ const markHandled = useCallback6((noteId) => {
1677
1629
  handledIdsRef.current = new Set(handledIdsRef.current).add(noteId);
1678
1630
  setHandledVersion((v) => v + 1);
1679
1631
  }, []);
1680
- const markAllHandled = (0, import_react8.useCallback)(() => {
1632
+ const markAllHandled = useCallback6(() => {
1681
1633
  const newSet = new Set(handledIdsRef.current);
1682
1634
  for (const note of streamedNotes) {
1683
1635
  newSet.add(note.id);
@@ -1685,7 +1637,7 @@ function useNoteStream(options = {}) {
1685
1637
  handledIdsRef.current = newSet;
1686
1638
  setHandledVersion((v) => v + 1);
1687
1639
  }, [streamedNotes]);
1688
- const snapshot = (0, import_react8.useCallback)(() => {
1640
+ const snapshot = useCallback6(() => {
1689
1641
  const ids = /* @__PURE__ */ new Set();
1690
1642
  for (const note of streamedNotes) {
1691
1643
  ids.add(note.id);
@@ -1704,7 +1656,9 @@ function useNoteStream(options = {}) {
1704
1656
  }
1705
1657
  function buildStreamedNote(record, noteFirstSeen) {
1706
1658
  try {
1707
- const id = record.id().toString();
1659
+ const rawId = record.id();
1660
+ if (!rawId) return null;
1661
+ const id = rawId.toString();
1708
1662
  const metadata = record.metadata?.();
1709
1663
  const senderHex = metadata?.sender?.()?.toString?.();
1710
1664
  const sender = senderHex ? toBech32AccountId(senderHex) : "";
@@ -1741,20 +1695,20 @@ function buildStreamedNote(record, noteFirstSeen) {
1741
1695
  }
1742
1696
 
1743
1697
  // src/hooks/useTransactionHistory.ts
1744
- var import_react9 = require("react");
1745
- var import_miden_sdk12 = require("@miden-sdk/miden-sdk");
1698
+ import { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
1699
+ import { TransactionFilter as TransactionFilter2 } from "@miden-sdk/miden-sdk/mt";
1746
1700
  function useTransactionHistory(options = {}) {
1747
1701
  const { client, isReady } = useMiden();
1748
1702
  const { lastSyncTime } = useSyncStateStore();
1749
- const [records, setRecords] = (0, import_react9.useState)([]);
1750
- const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
1751
- const [error, setError] = (0, import_react9.useState)(null);
1752
- const rawIds = (0, import_react9.useMemo)(() => {
1703
+ const [records, setRecords] = useState6([]);
1704
+ const [isLoading, setIsLoading] = useState6(false);
1705
+ const [error, setError] = useState6(null);
1706
+ const rawIds = useMemo7(() => {
1753
1707
  if (options.id) return [options.id];
1754
1708
  if (options.ids && options.ids.length > 0) return options.ids;
1755
1709
  return null;
1756
1710
  }, [options.id, options.ids]);
1757
- const idsHex = (0, import_react9.useMemo)(() => {
1711
+ const idsHex = useMemo7(() => {
1758
1712
  if (!rawIds) return null;
1759
1713
  return rawIds.map(
1760
1714
  (id) => normalizeHex2(typeof id === "string" ? id : id.toHex())
@@ -1762,7 +1716,7 @@ function useTransactionHistory(options = {}) {
1762
1716
  }, [rawIds]);
1763
1717
  const filter = options.filter;
1764
1718
  const refreshOnSync = options.refreshOnSync !== false;
1765
- const refetch = (0, import_react9.useCallback)(async () => {
1719
+ const refetch = useCallback7(async () => {
1766
1720
  if (!client || !isReady) return;
1767
1721
  setIsLoading(true);
1768
1722
  setError(null);
@@ -1783,19 +1737,19 @@ function useTransactionHistory(options = {}) {
1783
1737
  setIsLoading(false);
1784
1738
  }
1785
1739
  }, [client, isReady, filter, rawIds, idsHex]);
1786
- (0, import_react9.useEffect)(() => {
1740
+ useEffect8(() => {
1787
1741
  if (!isReady) return;
1788
1742
  refetch();
1789
1743
  }, [isReady, refetch]);
1790
- (0, import_react9.useEffect)(() => {
1744
+ useEffect8(() => {
1791
1745
  if (!isReady || !refreshOnSync || !lastSyncTime) return;
1792
1746
  refetch();
1793
1747
  }, [isReady, lastSyncTime, refreshOnSync, refetch]);
1794
- const record = (0, import_react9.useMemo)(() => {
1748
+ const record = useMemo7(() => {
1795
1749
  if (!idsHex || idsHex.length !== 1) return null;
1796
1750
  return records.find((item) => normalizeHex2(item.id().toHex()) === idsHex[0]) ?? null;
1797
1751
  }, [records, idsHex]);
1798
- const status = (0, import_react9.useMemo)(() => {
1752
+ const status = useMemo7(() => {
1799
1753
  if (!record) return null;
1800
1754
  const current = record.transactionStatus();
1801
1755
  if (current.isCommitted()) return "committed";
@@ -1817,14 +1771,14 @@ function buildFilter(filter, ids, idsHex) {
1817
1771
  return { filter };
1818
1772
  }
1819
1773
  if (!ids || ids.length === 0) {
1820
- return { filter: import_miden_sdk12.TransactionFilter.all() };
1774
+ return { filter: TransactionFilter2.all() };
1821
1775
  }
1822
1776
  const allTransactionIds = ids.every((id) => typeof id !== "string");
1823
1777
  if (allTransactionIds) {
1824
- return { filter: import_miden_sdk12.TransactionFilter.ids(ids) };
1778
+ return { filter: TransactionFilter2.ids(ids) };
1825
1779
  }
1826
1780
  return {
1827
- filter: import_miden_sdk12.TransactionFilter.all(),
1781
+ filter: TransactionFilter2.all(),
1828
1782
  localFilterHexes: idsHex ?? []
1829
1783
  };
1830
1784
  }
@@ -1835,11 +1789,11 @@ function normalizeHex2(value) {
1835
1789
  }
1836
1790
 
1837
1791
  // src/hooks/useSyncState.ts
1838
- var import_react10 = require("react");
1792
+ import { useCallback as useCallback8 } from "react";
1839
1793
  function useSyncState() {
1840
1794
  const { sync: triggerSync } = useMiden();
1841
1795
  const syncState = useSyncStateStore();
1842
- const sync = (0, import_react10.useCallback)(async () => {
1796
+ const sync = useCallback8(async () => {
1843
1797
  await triggerSync();
1844
1798
  }, [triggerSync]);
1845
1799
  return {
@@ -1849,8 +1803,8 @@ function useSyncState() {
1849
1803
  }
1850
1804
 
1851
1805
  // src/hooks/useCreateWallet.ts
1852
- var import_react11 = require("react");
1853
- var import_miden_sdk13 = require("@miden-sdk/miden-sdk");
1806
+ import { useCallback as useCallback9, useState as useState7 } from "react";
1807
+ import { AccountStorageMode } from "@miden-sdk/miden-sdk/mt";
1854
1808
 
1855
1809
  // src/utils/runExclusive.ts
1856
1810
  var runExclusiveDirect = async (fn) => fn();
@@ -1860,10 +1814,10 @@ function useCreateWallet() {
1860
1814
  const { client, isReady, runExclusive } = useMiden();
1861
1815
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
1862
1816
  const setAccounts = useMidenStore((state) => state.setAccounts);
1863
- const [wallet, setWallet] = (0, import_react11.useState)(null);
1864
- const [isCreating, setIsCreating] = (0, import_react11.useState)(false);
1865
- const [error, setError] = (0, import_react11.useState)(null);
1866
- const createWallet = (0, import_react11.useCallback)(
1817
+ const [wallet, setWallet] = useState7(null);
1818
+ const [isCreating, setIsCreating] = useState7(false);
1819
+ const [error, setError] = useState7(null);
1820
+ const createWallet = useCallback9(
1867
1821
  async (options = {}) => {
1868
1822
  if (!client || !isReady) {
1869
1823
  throw new Error("Miden client is not ready");
@@ -1900,7 +1854,7 @@ function useCreateWallet() {
1900
1854
  },
1901
1855
  [client, isReady, runExclusive, setAccounts]
1902
1856
  );
1903
- const reset = (0, import_react11.useCallback)(() => {
1857
+ const reset = useCallback9(() => {
1904
1858
  setWallet(null);
1905
1859
  setIsCreating(false);
1906
1860
  setError(null);
@@ -1916,27 +1870,25 @@ function useCreateWallet() {
1916
1870
  function getStorageMode(mode) {
1917
1871
  switch (mode) {
1918
1872
  case "private":
1919
- return import_miden_sdk13.AccountStorageMode.private();
1873
+ return AccountStorageMode.private();
1920
1874
  case "public":
1921
- return import_miden_sdk13.AccountStorageMode.public();
1922
- case "network":
1923
- return import_miden_sdk13.AccountStorageMode.network();
1875
+ return AccountStorageMode.public();
1924
1876
  default:
1925
- return import_miden_sdk13.AccountStorageMode.private();
1877
+ return AccountStorageMode.private();
1926
1878
  }
1927
1879
  }
1928
1880
 
1929
1881
  // src/hooks/useCreateFaucet.ts
1930
- var import_react12 = require("react");
1931
- var import_miden_sdk14 = require("@miden-sdk/miden-sdk");
1882
+ import { useCallback as useCallback10, useState as useState8 } from "react";
1883
+ import { AccountStorageMode as AccountStorageMode2 } from "@miden-sdk/miden-sdk/mt";
1932
1884
  function useCreateFaucet() {
1933
1885
  const { client, isReady, runExclusive } = useMiden();
1934
1886
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
1935
1887
  const setAccounts = useMidenStore((state) => state.setAccounts);
1936
- const [faucet, setFaucet] = (0, import_react12.useState)(null);
1937
- const [isCreating, setIsCreating] = (0, import_react12.useState)(false);
1938
- const [error, setError] = (0, import_react12.useState)(null);
1939
- const createFaucet = (0, import_react12.useCallback)(
1888
+ const [faucet, setFaucet] = useState8(null);
1889
+ const [isCreating, setIsCreating] = useState8(false);
1890
+ const [error, setError] = useState8(null);
1891
+ const createFaucet = useCallback10(
1940
1892
  async (options) => {
1941
1893
  if (!client || !isReady) {
1942
1894
  throw new Error("Miden client is not ready");
@@ -1954,6 +1906,7 @@ function useCreateFaucet() {
1954
1906
  storageMode,
1955
1907
  false,
1956
1908
  // nonFungible - currently only fungible faucets supported
1909
+ options.tokenName ?? options.tokenSymbol,
1957
1910
  options.tokenSymbol,
1958
1911
  decimals,
1959
1912
  BigInt(options.maxSupply),
@@ -1975,7 +1928,7 @@ function useCreateFaucet() {
1975
1928
  },
1976
1929
  [client, isReady, runExclusive, setAccounts]
1977
1930
  );
1978
- const reset = (0, import_react12.useCallback)(() => {
1931
+ const reset = useCallback10(() => {
1979
1932
  setFaucet(null);
1980
1933
  setIsCreating(false);
1981
1934
  setError(null);
@@ -1991,19 +1944,17 @@ function useCreateFaucet() {
1991
1944
  function getStorageMode2(mode) {
1992
1945
  switch (mode) {
1993
1946
  case "private":
1994
- return import_miden_sdk14.AccountStorageMode.private();
1947
+ return AccountStorageMode2.private();
1995
1948
  case "public":
1996
- return import_miden_sdk14.AccountStorageMode.public();
1997
- case "network":
1998
- return import_miden_sdk14.AccountStorageMode.network();
1949
+ return AccountStorageMode2.public();
1999
1950
  default:
2000
- return import_miden_sdk14.AccountStorageMode.private();
1951
+ return AccountStorageMode2.private();
2001
1952
  }
2002
1953
  }
2003
1954
 
2004
1955
  // src/hooks/useImportAccount.ts
2005
- var import_react13 = require("react");
2006
- var import_miden_sdk15 = require("@miden-sdk/miden-sdk");
1956
+ import { useCallback as useCallback11, useState as useState9 } from "react";
1957
+ import { AccountFile } from "@miden-sdk/miden-sdk/mt";
2007
1958
 
2008
1959
  // src/utils/errors.ts
2009
1960
  var MidenError = class extends Error {
@@ -2061,10 +2012,10 @@ function wrapWasmError(e) {
2061
2012
  function useImportAccount() {
2062
2013
  const { client, isReady, signerConnected } = useMiden();
2063
2014
  const setAccounts = useMidenStore((state) => state.setAccounts);
2064
- const [account, setAccount] = (0, import_react13.useState)(null);
2065
- const [isImporting, setIsImporting] = (0, import_react13.useState)(false);
2066
- const [error, setError] = (0, import_react13.useState)(null);
2067
- const importAccount = (0, import_react13.useCallback)(
2015
+ const [account, setAccount] = useState9(null);
2016
+ const [isImporting, setIsImporting] = useState9(false);
2017
+ const [error, setError] = useState9(null);
2018
+ const importAccount = useCallback11(
2068
2019
  async (options) => {
2069
2020
  if (!client || !isReady) {
2070
2021
  throw new Error("Miden client is not ready");
@@ -2160,7 +2111,7 @@ function useImportAccount() {
2160
2111
  },
2161
2112
  [client, isReady, setAccounts, signerConnected]
2162
2113
  );
2163
- const reset = (0, import_react13.useCallback)(() => {
2114
+ const reset = useCallback11(() => {
2164
2115
  setAccount(null);
2165
2116
  setIsImporting(false);
2166
2117
  setError(null);
@@ -2175,10 +2126,10 @@ function useImportAccount() {
2175
2126
  }
2176
2127
  async function resolveAccountFile(file) {
2177
2128
  if (file instanceof Uint8Array) {
2178
- return import_miden_sdk15.AccountFile.deserialize(file);
2129
+ return AccountFile.deserialize(file);
2179
2130
  }
2180
2131
  if (file instanceof ArrayBuffer) {
2181
- return import_miden_sdk15.AccountFile.deserialize(new Uint8Array(file));
2132
+ return AccountFile.deserialize(new Uint8Array(file));
2182
2133
  }
2183
2134
  return file;
2184
2135
  }
@@ -2207,17 +2158,24 @@ function bytesEqual(left, right) {
2207
2158
  }
2208
2159
 
2209
2160
  // src/hooks/useSend.ts
2210
- var import_react14 = require("react");
2211
- var import_miden_sdk16 = require("@miden-sdk/miden-sdk");
2161
+ import { useCallback as useCallback12, useRef as useRef4, useState as useState10 } from "react";
2162
+ import {
2163
+ FungibleAsset,
2164
+ Note,
2165
+ NoteAssets,
2166
+ NoteType as NoteType2,
2167
+ NoteArray,
2168
+ TransactionRequestBuilder
2169
+ } from "@miden-sdk/miden-sdk/mt";
2212
2170
  function useSend() {
2213
2171
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2214
2172
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2215
- const isBusyRef = (0, import_react14.useRef)(false);
2216
- const [result, setResult] = (0, import_react14.useState)(null);
2217
- const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
2218
- const [stage, setStage] = (0, import_react14.useState)("idle");
2219
- const [error, setError] = (0, import_react14.useState)(null);
2220
- const send = (0, import_react14.useCallback)(
2173
+ const isBusyRef = useRef4(false);
2174
+ const [result, setResult] = useState10(null);
2175
+ const [isLoading, setIsLoading] = useState10(false);
2176
+ const [stage, setStage] = useState10("idle");
2177
+ const [error, setError] = useState10(null);
2178
+ const send = useCallback12(
2221
2179
  async (options) => {
2222
2180
  if (!client || !isReady) {
2223
2181
  throw new Error("Miden client is not ready");
@@ -2275,26 +2233,26 @@ function useSend() {
2275
2233
  const fromId = parseAccountId(options.from);
2276
2234
  const toId = parseAccountId(options.to);
2277
2235
  const assetObj = parseAccountId(assetId);
2278
- const assets = new import_miden_sdk16.NoteAssets([
2279
- new import_miden_sdk16.FungibleAsset(assetObj, BigInt(amount))
2236
+ const assets = new NoteAssets([
2237
+ new FungibleAsset(assetObj, BigInt(amount))
2280
2238
  ]);
2281
- const p2idNote = import_miden_sdk16.Note.createP2IDNote(
2239
+ const p2idNote = Note.createP2IDNote(
2282
2240
  fromId,
2283
2241
  toId,
2284
2242
  assets,
2285
2243
  noteType,
2286
- new import_miden_sdk16.NoteAttachment()
2244
+ emptyAttachment()
2287
2245
  );
2288
- const ownOutputs = new import_miden_sdk16.NoteArray();
2246
+ const ownOutputs = new NoteArray();
2289
2247
  ownOutputs.push(p2idNote);
2290
- const txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
2248
+ const txRequest = new TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
2291
2249
  const execFromId = parseAccountId(options.from);
2292
2250
  const txId = prover ? await client.submitNewTransactionWithProver(
2293
2251
  execFromId,
2294
2252
  txRequest,
2295
2253
  prover
2296
2254
  ) : await client.submitNewTransaction(execFromId, txRequest);
2297
- return { txId: txId.toString(), note: p2idNote };
2255
+ return { txId: txId.toHex(), note: p2idNote };
2298
2256
  });
2299
2257
  setStage("complete");
2300
2258
  setResult(returnResult);
@@ -2308,17 +2266,17 @@ function useSend() {
2308
2266
  let txRequest;
2309
2267
  if (hasAttachment) {
2310
2268
  const attachment = createNoteAttachment(options.attachment);
2311
- const assets = new import_miden_sdk16.NoteAssets([
2312
- new import_miden_sdk16.FungibleAsset(assetIdObj, amount)
2269
+ const assets = new NoteAssets([
2270
+ new FungibleAsset(assetIdObj, amount)
2313
2271
  ]);
2314
- const note = import_miden_sdk16.Note.createP2IDNote(
2272
+ const note = Note.createP2IDNote(
2315
2273
  fromAccountId,
2316
2274
  toAccountId,
2317
2275
  assets,
2318
2276
  noteType,
2319
2277
  attachment
2320
2278
  );
2321
- txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk16.NoteArray([note])).build();
2279
+ txRequest = new TransactionRequestBuilder().withOwnOutputNotes(new NoteArray([note])).build();
2322
2280
  } else {
2323
2281
  txRequest = await client.newSendTransactionRequest(
2324
2282
  fromAccountId,
@@ -2346,15 +2304,14 @@ function useSend() {
2346
2304
  () => client.submitProvenTransaction(provenTransaction, txResult)
2347
2305
  );
2348
2306
  const txIdHex = txResult.id().toHex();
2349
- const txIdString = txResult.id().toString();
2350
2307
  let fullNote = null;
2351
- if (noteType === import_miden_sdk16.NoteType.Private) {
2308
+ if (noteType === NoteType2.Private) {
2352
2309
  fullNote = extractFullNote(txResult);
2353
2310
  }
2354
2311
  await runExclusiveSafe(
2355
2312
  () => client.applyTransaction(txResult, submissionHeight)
2356
2313
  );
2357
- if (noteType === import_miden_sdk16.NoteType.Private) {
2314
+ if (noteType === NoteType2.Private) {
2358
2315
  if (!fullNote) {
2359
2316
  throw new Error("Missing full note for private send");
2360
2317
  }
@@ -2370,7 +2327,7 @@ function useSend() {
2370
2327
  );
2371
2328
  }
2372
2329
  const sendResult = {
2373
- txId: txIdString,
2330
+ txId: txIdHex,
2374
2331
  note: null
2375
2332
  };
2376
2333
  setStage("complete");
@@ -2389,7 +2346,7 @@ function useSend() {
2389
2346
  },
2390
2347
  [client, isReady, prover, runExclusive, sync]
2391
2348
  );
2392
- const reset = (0, import_react14.useCallback)(() => {
2349
+ const reset = useCallback12(() => {
2393
2350
  setResult(null);
2394
2351
  setIsLoading(false);
2395
2352
  setStage("idle");
@@ -2416,16 +2373,23 @@ function extractFullNote(txResult) {
2416
2373
  }
2417
2374
 
2418
2375
  // src/hooks/useMultiSend.ts
2419
- var import_react15 = require("react");
2420
- var import_miden_sdk17 = require("@miden-sdk/miden-sdk");
2376
+ import { useCallback as useCallback13, useRef as useRef5, useState as useState11 } from "react";
2377
+ import {
2378
+ FungibleAsset as FungibleAsset2,
2379
+ Note as Note2,
2380
+ NoteAssets as NoteAssets2,
2381
+ NoteType as NoteType3,
2382
+ NoteArray as NoteArray2,
2383
+ TransactionRequestBuilder as TransactionRequestBuilder2
2384
+ } from "@miden-sdk/miden-sdk/mt";
2421
2385
  function useMultiSend() {
2422
2386
  const { client, isReady, sync, prover, signerConnected } = useMiden();
2423
- const isBusyRef = (0, import_react15.useRef)(false);
2424
- const [result, setResult] = (0, import_react15.useState)(null);
2425
- const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
2426
- const [stage, setStage] = (0, import_react15.useState)("idle");
2427
- const [error, setError] = (0, import_react15.useState)(null);
2428
- const sendMany = (0, import_react15.useCallback)(
2387
+ const isBusyRef = useRef5(false);
2388
+ const [result, setResult] = useState11(null);
2389
+ const [isLoading, setIsLoading] = useState11(false);
2390
+ const [stage, setStage] = useState11("idle");
2391
+ const [error, setError] = useState11(null);
2392
+ const sendMany = useCallback13(
2429
2393
  async (options) => {
2430
2394
  if (!client || !isReady) {
2431
2395
  throw new Error("Miden client is not ready");
@@ -2454,12 +2418,12 @@ function useMultiSend() {
2454
2418
  const iterSenderId = parseAccountId(options.from);
2455
2419
  const iterAssetId = parseAccountId(options.assetId);
2456
2420
  const receiverId = parseAccountId(to);
2457
- const assets = new import_miden_sdk17.NoteAssets([
2458
- new import_miden_sdk17.FungibleAsset(iterAssetId, BigInt(amount))
2421
+ const assets = new NoteAssets2([
2422
+ new FungibleAsset2(iterAssetId, BigInt(amount))
2459
2423
  ]);
2460
2424
  const resolvedNoteType = recipientNoteType ? getNoteType(recipientNoteType) : noteType;
2461
- const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new import_miden_sdk17.NoteAttachment();
2462
- const note = import_miden_sdk17.Note.createP2IDNote(
2425
+ const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : emptyAttachment();
2426
+ const note = Note2.createP2IDNote(
2463
2427
  iterSenderId,
2464
2428
  receiverId,
2465
2429
  assets,
@@ -2474,7 +2438,11 @@ function useMultiSend() {
2474
2438
  };
2475
2439
  }
2476
2440
  );
2477
- const txRequest = new import_miden_sdk17.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk17.NoteArray(outputs.map((o) => o.note))).build();
2441
+ const ownOutputs = new NoteArray2();
2442
+ for (const o of outputs) {
2443
+ ownOutputs.push(o.note);
2444
+ }
2445
+ const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(ownOutputs).build();
2478
2446
  const txSenderId = parseAccountId(options.from);
2479
2447
  const txResult = await client.executeTransaction(txSenderId, txRequest);
2480
2448
  setStage("proving");
@@ -2491,9 +2459,8 @@ function useMultiSend() {
2491
2459
  txResult
2492
2460
  );
2493
2461
  const txIdHex = txResult.id().toHex();
2494
- const txIdString = txResult.id().toString();
2495
2462
  await client.applyTransaction(txResult, submissionHeight);
2496
- const hasPrivate = outputs.some((o) => o.noteType === import_miden_sdk17.NoteType.Private);
2463
+ const hasPrivate = outputs.some((o) => o.noteType === NoteType3.Private);
2497
2464
  if (hasPrivate) {
2498
2465
  await waitForTransactionCommit(
2499
2466
  client,
@@ -2501,7 +2468,7 @@ function useMultiSend() {
2501
2468
  txIdHex
2502
2469
  );
2503
2470
  for (const output of outputs) {
2504
- if (output.noteType === import_miden_sdk17.NoteType.Private) {
2471
+ if (output.noteType === NoteType3.Private) {
2505
2472
  await client.sendPrivateNote(
2506
2473
  output.note,
2507
2474
  output.recipientAddress
@@ -2509,7 +2476,7 @@ function useMultiSend() {
2509
2476
  }
2510
2477
  }
2511
2478
  }
2512
- const txSummary = { transactionId: txIdString };
2479
+ const txSummary = { transactionId: txIdHex };
2513
2480
  setStage("complete");
2514
2481
  setResult(txSummary);
2515
2482
  await sync();
@@ -2526,7 +2493,7 @@ function useMultiSend() {
2526
2493
  },
2527
2494
  [client, isReady, prover, signerConnected, sync]
2528
2495
  );
2529
- const reset = (0, import_react15.useCallback)(() => {
2496
+ const reset = useCallback13(() => {
2530
2497
  setResult(null);
2531
2498
  setIsLoading(false);
2532
2499
  setStage("idle");
@@ -2543,11 +2510,11 @@ function useMultiSend() {
2543
2510
  }
2544
2511
 
2545
2512
  // src/hooks/useWaitForCommit.ts
2546
- var import_react16 = require("react");
2547
- var import_miden_sdk18 = require("@miden-sdk/miden-sdk");
2513
+ import { useCallback as useCallback14 } from "react";
2514
+ import { TransactionFilter as TransactionFilter3 } from "@miden-sdk/miden-sdk/mt";
2548
2515
  function useWaitForCommit() {
2549
2516
  const { client, isReady } = useMiden();
2550
- const waitForCommit = (0, import_react16.useCallback)(
2517
+ const waitForCommit = useCallback14(
2551
2518
  async (txId, options) => {
2552
2519
  if (!client || !isReady) {
2553
2520
  throw new Error("Miden client is not ready");
@@ -2561,7 +2528,7 @@ function useWaitForCommit() {
2561
2528
  while (Date.now() < deadline) {
2562
2529
  await client.syncState();
2563
2530
  const records = await client.getTransactions(
2564
- typeof txId === "string" ? import_miden_sdk18.TransactionFilter.all() : import_miden_sdk18.TransactionFilter.ids([txId])
2531
+ typeof txId === "string" ? TransactionFilter3.all() : TransactionFilter3.ids([txId])
2565
2532
  );
2566
2533
  const record = records.find(
2567
2534
  (item) => normalizeHex3(item.id().toHex()) === targetHex
@@ -2590,11 +2557,11 @@ function normalizeHex3(value) {
2590
2557
  }
2591
2558
 
2592
2559
  // src/hooks/useWaitForNotes.ts
2593
- var import_react17 = require("react");
2560
+ import { useCallback as useCallback15 } from "react";
2594
2561
  function useWaitForNotes() {
2595
2562
  const { client, isReady, runExclusive } = useMiden();
2596
2563
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2597
- const waitForConsumableNotes = (0, import_react17.useCallback)(
2564
+ const waitForConsumableNotes = useCallback15(
2598
2565
  async (options) => {
2599
2566
  if (!client || !isReady) {
2600
2567
  throw new Error("Miden client is not ready");
@@ -2625,15 +2592,15 @@ function useWaitForNotes() {
2625
2592
  }
2626
2593
 
2627
2594
  // src/hooks/useMint.ts
2628
- var import_react18 = require("react");
2595
+ import { useCallback as useCallback16, useState as useState12 } from "react";
2629
2596
  function useMint() {
2630
2597
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2631
2598
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2632
- const [result, setResult] = (0, import_react18.useState)(null);
2633
- const [isLoading, setIsLoading] = (0, import_react18.useState)(false);
2634
- const [stage, setStage] = (0, import_react18.useState)("idle");
2635
- const [error, setError] = (0, import_react18.useState)(null);
2636
- const mint = (0, import_react18.useCallback)(
2599
+ const [result, setResult] = useState12(null);
2600
+ const [isLoading, setIsLoading] = useState12(false);
2601
+ const [stage, setStage] = useState12("idle");
2602
+ const [error, setError] = useState12(null);
2603
+ const mint = useCallback16(
2637
2604
  async (options) => {
2638
2605
  if (!client || !isReady) {
2639
2606
  throw new Error("Miden client is not ready");
@@ -2658,7 +2625,7 @@ function useMint() {
2658
2625
  txRequest,
2659
2626
  prover
2660
2627
  ) : await client.submitNewTransaction(faucetIdObj, txRequest);
2661
- return { transactionId: txId.toString() };
2628
+ return { transactionId: txId.toHex() };
2662
2629
  });
2663
2630
  setStage("complete");
2664
2631
  setResult(txResult);
@@ -2675,7 +2642,7 @@ function useMint() {
2675
2642
  },
2676
2643
  [client, isReady, prover, runExclusive, sync]
2677
2644
  );
2678
- const reset = (0, import_react18.useCallback)(() => {
2645
+ const reset = useCallback16(() => {
2679
2646
  setResult(null);
2680
2647
  setIsLoading(false);
2681
2648
  setStage("idle");
@@ -2692,16 +2659,16 @@ function useMint() {
2692
2659
  }
2693
2660
 
2694
2661
  // src/hooks/useConsume.ts
2695
- var import_react19 = require("react");
2696
- var import_miden_sdk19 = require("@miden-sdk/miden-sdk");
2662
+ import { useCallback as useCallback17, useState as useState13 } from "react";
2663
+ import { NoteFilter as NoteFilter3, NoteFilterTypes as NoteFilterTypes2, NoteId } from "@miden-sdk/miden-sdk/mt";
2697
2664
  function useConsume() {
2698
2665
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2699
2666
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2700
- const [result, setResult] = (0, import_react19.useState)(null);
2701
- const [isLoading, setIsLoading] = (0, import_react19.useState)(false);
2702
- const [stage, setStage] = (0, import_react19.useState)("idle");
2703
- const [error, setError] = (0, import_react19.useState)(null);
2704
- const consume = (0, import_react19.useCallback)(
2667
+ const [result, setResult] = useState13(null);
2668
+ const [isLoading, setIsLoading] = useState13(false);
2669
+ const [stage, setStage] = useState13("idle");
2670
+ const [error, setError] = useState13(null);
2671
+ const consume = useCallback17(
2705
2672
  async (options) => {
2706
2673
  if (!client || !isReady) {
2707
2674
  throw new Error("Miden client is not ready");
@@ -2723,7 +2690,7 @@ function useConsume() {
2723
2690
  const item = options.notes[i];
2724
2691
  if (typeof item === "string") {
2725
2692
  lookupIndices.push(i);
2726
- lookupIds.push(import_miden_sdk19.NoteId.fromHex(item));
2693
+ lookupIds.push(NoteId.fromHex(item));
2727
2694
  } else if (item !== null && typeof item === "object" && typeof item.toNote === "function") {
2728
2695
  resolved[i] = item.toNote();
2729
2696
  } else if (item !== null && typeof item === "object" && typeof item.id === "function") {
@@ -2734,16 +2701,25 @@ function useConsume() {
2734
2701
  }
2735
2702
  }
2736
2703
  if (lookupIds.length > 0) {
2737
- const filter = new import_miden_sdk19.NoteFilter(import_miden_sdk19.NoteFilterTypes.List, lookupIds);
2704
+ const lookupIdStrings = lookupIds.map((id) => id.toString());
2705
+ const filter = new NoteFilter3(NoteFilterTypes2.List, lookupIds);
2738
2706
  const noteRecords = await client.getInputNotes(filter);
2739
- if (noteRecords.length !== lookupIds.length) {
2707
+ if (noteRecords.length !== lookupIdStrings.length) {
2740
2708
  throw new Error("Some notes could not be found for provided IDs");
2741
2709
  }
2742
2710
  const recordById = new Map(
2743
- noteRecords.map((r) => [r.id().toString(), r])
2711
+ noteRecords.map((r) => {
2712
+ const id = r.id();
2713
+ if (!id) {
2714
+ throw new Error(
2715
+ "getInputNotes returned a record without a note id"
2716
+ );
2717
+ }
2718
+ return [id.toString(), r];
2719
+ })
2744
2720
  );
2745
2721
  for (let j = 0; j < lookupIndices.length; j++) {
2746
- const record = recordById.get(lookupIds[j].toString());
2722
+ const record = recordById.get(lookupIdStrings[j]);
2747
2723
  if (!record) {
2748
2724
  throw new Error(
2749
2725
  "Some notes could not be found for provided IDs"
@@ -2759,7 +2735,7 @@ function useConsume() {
2759
2735
  txRequest,
2760
2736
  prover
2761
2737
  ) : await client.submitNewTransaction(accountIdObj, txRequest);
2762
- return { transactionId: txId.toString() };
2738
+ return { transactionId: txId.toHex() };
2763
2739
  });
2764
2740
  setStage("complete");
2765
2741
  setResult(txResult);
@@ -2776,7 +2752,7 @@ function useConsume() {
2776
2752
  },
2777
2753
  [client, isReady, prover, runExclusive, sync]
2778
2754
  );
2779
- const reset = (0, import_react19.useCallback)(() => {
2755
+ const reset = useCallback17(() => {
2780
2756
  setResult(null);
2781
2757
  setIsLoading(false);
2782
2758
  setStage("idle");
@@ -2793,15 +2769,15 @@ function useConsume() {
2793
2769
  }
2794
2770
 
2795
2771
  // src/hooks/useSwap.ts
2796
- var import_react20 = require("react");
2772
+ import { useCallback as useCallback18, useState as useState14 } from "react";
2797
2773
  function useSwap() {
2798
2774
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2799
2775
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2800
- const [result, setResult] = (0, import_react20.useState)(null);
2801
- const [isLoading, setIsLoading] = (0, import_react20.useState)(false);
2802
- const [stage, setStage] = (0, import_react20.useState)("idle");
2803
- const [error, setError] = (0, import_react20.useState)(null);
2804
- const swap = (0, import_react20.useCallback)(
2776
+ const [result, setResult] = useState14(null);
2777
+ const [isLoading, setIsLoading] = useState14(false);
2778
+ const [stage, setStage] = useState14("idle");
2779
+ const [error, setError] = useState14(null);
2780
+ const swap = useCallback18(
2805
2781
  async (options) => {
2806
2782
  if (!client || !isReady) {
2807
2783
  throw new Error("Miden client is not ready");
@@ -2833,7 +2809,7 @@ function useSwap() {
2833
2809
  txRequest,
2834
2810
  prover
2835
2811
  ) : await client.submitNewTransaction(accountIdObj, txRequest);
2836
- return { transactionId: txId.toString() };
2812
+ return { transactionId: txId.toHex() };
2837
2813
  });
2838
2814
  setStage("complete");
2839
2815
  setResult(txResult);
@@ -2850,7 +2826,7 @@ function useSwap() {
2850
2826
  },
2851
2827
  [client, isReady, prover, runExclusive, sync]
2852
2828
  );
2853
- const reset = (0, import_react20.useCallback)(() => {
2829
+ const reset = useCallback18(() => {
2854
2830
  setResult(null);
2855
2831
  setIsLoading(false);
2856
2832
  setStage("idle");
@@ -2866,17 +2842,237 @@ function useSwap() {
2866
2842
  };
2867
2843
  }
2868
2844
 
2845
+ // src/hooks/usePswapCreate.ts
2846
+ import { useCallback as useCallback19, useState as useState15 } from "react";
2847
+ function usePswapCreate() {
2848
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
2849
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2850
+ const [result, setResult] = useState15(null);
2851
+ const [isLoading, setIsLoading] = useState15(false);
2852
+ const [stage, setStage] = useState15("idle");
2853
+ const [error, setError] = useState15(null);
2854
+ const pswapCreate = useCallback19(
2855
+ async (options) => {
2856
+ if (!client || !isReady) {
2857
+ throw new Error("Miden client is not ready");
2858
+ }
2859
+ const offeredAmount = BigInt(options.offeredAmount);
2860
+ const requestedAmount = BigInt(options.requestedAmount);
2861
+ if (offeredAmount <= 0n) {
2862
+ throw new Error("offeredAmount must be greater than 0");
2863
+ }
2864
+ if (requestedAmount <= 0n) {
2865
+ throw new Error("requestedAmount must be greater than 0");
2866
+ }
2867
+ setIsLoading(true);
2868
+ setStage("executing");
2869
+ setError(null);
2870
+ try {
2871
+ const noteType = getNoteType(options.noteType ?? DEFAULTS.NOTE_TYPE);
2872
+ const paybackNoteType = getNoteType(
2873
+ options.paybackNoteType ?? DEFAULTS.NOTE_TYPE
2874
+ );
2875
+ const accountIdObj = parseAccountId(options.accountId);
2876
+ const offeredFaucetIdObj = parseAccountId(options.offeredFaucetId);
2877
+ const requestedFaucetIdObj = parseAccountId(options.requestedFaucetId);
2878
+ setStage("proving");
2879
+ const txResult = await runExclusiveSafe(async () => {
2880
+ const txRequest = await client.newPswapCreateTransactionRequest(
2881
+ accountIdObj,
2882
+ offeredFaucetIdObj,
2883
+ offeredAmount,
2884
+ requestedFaucetIdObj,
2885
+ requestedAmount,
2886
+ noteType,
2887
+ paybackNoteType
2888
+ );
2889
+ const txId = prover ? await client.submitNewTransactionWithProver(
2890
+ accountIdObj,
2891
+ txRequest,
2892
+ prover
2893
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
2894
+ return { transactionId: txId.toHex() };
2895
+ });
2896
+ setStage("complete");
2897
+ setResult(txResult);
2898
+ await sync();
2899
+ return txResult;
2900
+ } catch (err) {
2901
+ const error2 = err instanceof Error ? err : new Error(String(err));
2902
+ setError(error2);
2903
+ setStage("idle");
2904
+ throw error2;
2905
+ } finally {
2906
+ setIsLoading(false);
2907
+ }
2908
+ },
2909
+ [client, isReady, prover, runExclusive, sync]
2910
+ );
2911
+ const reset = useCallback19(() => {
2912
+ setResult(null);
2913
+ setIsLoading(false);
2914
+ setStage("idle");
2915
+ setError(null);
2916
+ }, []);
2917
+ return {
2918
+ pswapCreate,
2919
+ result,
2920
+ isLoading,
2921
+ stage,
2922
+ error,
2923
+ reset
2924
+ };
2925
+ }
2926
+
2927
+ // src/hooks/usePswapConsume.ts
2928
+ import { useCallback as useCallback20, useState as useState16 } from "react";
2929
+ function usePswapConsume() {
2930
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
2931
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2932
+ const [result, setResult] = useState16(null);
2933
+ const [isLoading, setIsLoading] = useState16(false);
2934
+ const [stage, setStage] = useState16("idle");
2935
+ const [error, setError] = useState16(null);
2936
+ const pswapConsume = useCallback20(
2937
+ async (options) => {
2938
+ if (!client || !isReady) {
2939
+ throw new Error("Miden client is not ready");
2940
+ }
2941
+ const fillAmount = BigInt(options.fillAmount);
2942
+ const noteFillAmount = BigInt(options.noteFillAmount ?? 0);
2943
+ if (fillAmount <= 0n) {
2944
+ throw new Error("fillAmount must be greater than 0");
2945
+ }
2946
+ if (noteFillAmount < 0n) {
2947
+ throw new Error("noteFillAmount must not be negative");
2948
+ }
2949
+ setIsLoading(true);
2950
+ setStage("executing");
2951
+ setError(null);
2952
+ try {
2953
+ const accountIdObj = parseAccountId(options.accountId);
2954
+ setStage("proving");
2955
+ const txResult = await runExclusiveSafe(async () => {
2956
+ const note = await resolveNoteInput(options.note, client);
2957
+ const txRequest = await client.newPswapConsumeTransactionRequest(
2958
+ note,
2959
+ accountIdObj,
2960
+ fillAmount,
2961
+ noteFillAmount
2962
+ );
2963
+ const txId = prover ? await client.submitNewTransactionWithProver(
2964
+ accountIdObj,
2965
+ txRequest,
2966
+ prover
2967
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
2968
+ return { transactionId: txId.toHex() };
2969
+ });
2970
+ setStage("complete");
2971
+ setResult(txResult);
2972
+ await sync();
2973
+ return txResult;
2974
+ } catch (err) {
2975
+ const error2 = err instanceof Error ? err : new Error(String(err));
2976
+ setError(error2);
2977
+ setStage("idle");
2978
+ throw error2;
2979
+ } finally {
2980
+ setIsLoading(false);
2981
+ }
2982
+ },
2983
+ [client, isReady, prover, runExclusive, sync]
2984
+ );
2985
+ const reset = useCallback20(() => {
2986
+ setResult(null);
2987
+ setIsLoading(false);
2988
+ setStage("idle");
2989
+ setError(null);
2990
+ }, []);
2991
+ return {
2992
+ pswapConsume,
2993
+ result,
2994
+ isLoading,
2995
+ stage,
2996
+ error,
2997
+ reset
2998
+ };
2999
+ }
3000
+
3001
+ // src/hooks/usePswapCancel.ts
3002
+ import { useCallback as useCallback21, useState as useState17 } from "react";
3003
+ function usePswapCancel() {
3004
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
3005
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3006
+ const [result, setResult] = useState17(null);
3007
+ const [isLoading, setIsLoading] = useState17(false);
3008
+ const [stage, setStage] = useState17("idle");
3009
+ const [error, setError] = useState17(null);
3010
+ const pswapCancel = useCallback21(
3011
+ async (options) => {
3012
+ if (!client || !isReady) {
3013
+ throw new Error("Miden client is not ready");
3014
+ }
3015
+ setIsLoading(true);
3016
+ setStage("executing");
3017
+ setError(null);
3018
+ try {
3019
+ const accountIdObj = parseAccountId(options.accountId);
3020
+ setStage("proving");
3021
+ const txResult = await runExclusiveSafe(async () => {
3022
+ const note = await resolveNoteInput(options.note, client);
3023
+ const txRequest = await client.newPswapCancelTransactionRequest(
3024
+ note,
3025
+ accountIdObj
3026
+ );
3027
+ const txId = prover ? await client.submitNewTransactionWithProver(
3028
+ accountIdObj,
3029
+ txRequest,
3030
+ prover
3031
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
3032
+ return { transactionId: txId.toHex() };
3033
+ });
3034
+ setStage("complete");
3035
+ setResult(txResult);
3036
+ await sync();
3037
+ return txResult;
3038
+ } catch (err) {
3039
+ const error2 = err instanceof Error ? err : new Error(String(err));
3040
+ setError(error2);
3041
+ setStage("idle");
3042
+ throw error2;
3043
+ } finally {
3044
+ setIsLoading(false);
3045
+ }
3046
+ },
3047
+ [client, isReady, prover, runExclusive, sync]
3048
+ );
3049
+ const reset = useCallback21(() => {
3050
+ setResult(null);
3051
+ setIsLoading(false);
3052
+ setStage("idle");
3053
+ setError(null);
3054
+ }, []);
3055
+ return {
3056
+ pswapCancel,
3057
+ result,
3058
+ isLoading,
3059
+ stage,
3060
+ error,
3061
+ reset
3062
+ };
3063
+ }
3064
+
2869
3065
  // src/hooks/useTransaction.ts
2870
- var import_react21 = require("react");
3066
+ import { useCallback as useCallback22, useRef as useRef6, useState as useState18 } from "react";
2871
3067
 
2872
3068
  // src/utils/transactions.ts
2873
- var import_miden_sdk20 = require("@miden-sdk/miden-sdk");
3069
+ import { NoteType as NoteType4, TransactionFilter as TransactionFilter4 } from "@miden-sdk/miden-sdk/mt";
2874
3070
  async function waitForTransactionCommit2(client, runExclusiveSafe, txId, maxWaitMs = 1e4, delayMs = 1e3) {
2875
3071
  let waited = 0;
2876
3072
  while (waited < maxWaitMs) {
2877
3073
  await runExclusiveSafe(() => client.syncState());
2878
3074
  const [record] = await runExclusiveSafe(
2879
- () => client.getTransactions(import_miden_sdk20.TransactionFilter.ids([txId]))
3075
+ () => client.getTransactions(TransactionFilter4.ids([txId]))
2880
3076
  );
2881
3077
  if (record) {
2882
3078
  const status = record.transactionStatus();
@@ -2898,7 +3094,7 @@ function extractFullNotes(txResult) {
2898
3094
  const notes = executedTx?.outputNotes?.().notes?.() ?? [];
2899
3095
  const result = [];
2900
3096
  for (const note of notes) {
2901
- if (note.noteType?.() === import_miden_sdk20.NoteType.Private) {
3097
+ if (note.noteType?.() === NoteType4.Private) {
2902
3098
  const full = note.intoFull?.();
2903
3099
  if (full) result.push(full);
2904
3100
  }
@@ -2913,12 +3109,12 @@ function extractFullNotes(txResult) {
2913
3109
  function useTransaction() {
2914
3110
  const { client, isReady, sync, runExclusive } = useMiden();
2915
3111
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2916
- const isBusyRef = (0, import_react21.useRef)(false);
2917
- const [result, setResult] = (0, import_react21.useState)(null);
2918
- const [isLoading, setIsLoading] = (0, import_react21.useState)(false);
2919
- const [stage, setStage] = (0, import_react21.useState)("idle");
2920
- const [error, setError] = (0, import_react21.useState)(null);
2921
- const execute = (0, import_react21.useCallback)(
3112
+ const isBusyRef = useRef6(false);
3113
+ const [result, setResult] = useState18(null);
3114
+ const [isLoading, setIsLoading] = useState18(false);
3115
+ const [stage, setStage] = useState18("idle");
3116
+ const [error, setError] = useState18(null);
3117
+ const execute = useCallback22(
2922
3118
  async (options) => {
2923
3119
  if (!client || !isReady) {
2924
3120
  throw new Error("Miden client is not ready");
@@ -2968,7 +3164,7 @@ function useTransaction() {
2968
3164
  );
2969
3165
  }
2970
3166
  }
2971
- const txSummary = { transactionId: txId.toString() };
3167
+ const txSummary = { transactionId: txId.toHex() };
2972
3168
  setStage("complete");
2973
3169
  setResult(txSummary);
2974
3170
  await sync();
@@ -2985,7 +3181,7 @@ function useTransaction() {
2985
3181
  },
2986
3182
  [client, isReady, runExclusive, sync]
2987
3183
  );
2988
- const reset = (0, import_react21.useCallback)(() => {
3184
+ const reset = useCallback22(() => {
2989
3185
  setResult(null);
2990
3186
  setIsLoading(false);
2991
3187
  setStage("idle");
@@ -3008,19 +3204,24 @@ async function resolveRequest(request, client) {
3008
3204
  }
3009
3205
 
3010
3206
  // src/hooks/useExecuteProgram.ts
3011
- var import_react22 = require("react");
3012
- var import_miden_sdk21 = require("@miden-sdk/miden-sdk");
3207
+ import { useCallback as useCallback23, useRef as useRef7, useState as useState19 } from "react";
3208
+ import {
3209
+ AdviceInputs,
3210
+ ForeignAccount,
3211
+ ForeignAccountArray,
3212
+ AccountStorageRequirements
3213
+ } from "@miden-sdk/miden-sdk/mt";
3013
3214
  function isForeignAccountWrapper(fa) {
3014
3215
  return fa !== null && typeof fa === "object" && "id" in fa && typeof fa.id !== "function";
3015
3216
  }
3016
3217
  function useExecuteProgram() {
3017
3218
  const { client, isReady, sync, runExclusive } = useMiden();
3018
3219
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3019
- const isBusyRef = (0, import_react22.useRef)(false);
3020
- const [result, setResult] = (0, import_react22.useState)(null);
3021
- const [isLoading, setIsLoading] = (0, import_react22.useState)(false);
3022
- const [error, setError] = (0, import_react22.useState)(null);
3023
- const execute = (0, import_react22.useCallback)(
3220
+ const isBusyRef = useRef7(false);
3221
+ const [result, setResult] = useState19(null);
3222
+ const [isLoading, setIsLoading] = useState19(false);
3223
+ const [error, setError] = useState19(null);
3224
+ const execute = useCallback23(
3024
3225
  async (options) => {
3025
3226
  if (!client || !isReady) {
3026
3227
  throw new Error("Miden client is not ready");
@@ -3040,18 +3241,18 @@ function useExecuteProgram() {
3040
3241
  }
3041
3242
  const programResult = await runExclusiveSafe(async () => {
3042
3243
  const accountIdObj = parseAccountId(options.accountId);
3043
- const adviceInputs = options.adviceInputs ?? new import_miden_sdk21.AdviceInputs();
3244
+ const adviceInputs = options.adviceInputs ?? new AdviceInputs();
3044
3245
  let foreignAccountsArray;
3045
3246
  if (options.foreignAccounts?.length) {
3046
3247
  const accounts = options.foreignAccounts.map((fa) => {
3047
3248
  const wrapper = isForeignAccountWrapper(fa);
3048
3249
  const id = parseAccountId(wrapper ? fa.id : fa);
3049
- const storage = wrapper && fa.storage ? fa.storage : new import_miden_sdk21.AccountStorageRequirements();
3050
- return import_miden_sdk21.ForeignAccount.public(id, storage);
3250
+ const storage = wrapper && fa.storage ? fa.storage : new AccountStorageRequirements();
3251
+ return ForeignAccount.public(id, storage);
3051
3252
  });
3052
- foreignAccountsArray = new import_miden_sdk21.ForeignAccountArray(accounts);
3253
+ foreignAccountsArray = new ForeignAccountArray(accounts);
3053
3254
  } else {
3054
- foreignAccountsArray = new import_miden_sdk21.ForeignAccountArray();
3255
+ foreignAccountsArray = new ForeignAccountArray();
3055
3256
  }
3056
3257
  const feltArray = await client.executeProgram(
3057
3258
  accountIdObj,
@@ -3079,7 +3280,7 @@ function useExecuteProgram() {
3079
3280
  },
3080
3281
  [client, isReady, runExclusive, sync]
3081
3282
  );
3082
- const reset = (0, import_react22.useCallback)(() => {
3283
+ const reset = useCallback23(() => {
3083
3284
  setResult(null);
3084
3285
  setIsLoading(false);
3085
3286
  setError(null);
@@ -3094,29 +3295,29 @@ function useExecuteProgram() {
3094
3295
  }
3095
3296
 
3096
3297
  // src/hooks/useCompile.ts
3097
- var import_react23 = require("react");
3098
- var import_miden_sdk22 = require("@miden-sdk/miden-sdk");
3298
+ import { useCallback as useCallback24, useMemo as useMemo8 } from "react";
3299
+ import { CompilerResource, getWasmOrThrow } from "@miden-sdk/miden-sdk/mt";
3099
3300
  function useCompile() {
3100
3301
  const { client, isReady } = useMiden();
3101
- const resource = (0, import_react23.useMemo)(
3102
- () => client && isReady ? new import_miden_sdk22.CompilerResource(client, import_miden_sdk22.getWasmOrThrow) : null,
3302
+ const resource = useMemo8(
3303
+ () => client && isReady ? new CompilerResource(client, getWasmOrThrow) : null,
3103
3304
  [client, isReady]
3104
3305
  );
3105
- const requireResource = (0, import_react23.useCallback)(() => {
3306
+ const requireResource = useCallback24(() => {
3106
3307
  if (!resource) {
3107
3308
  throw new Error("Miden client is not ready");
3108
3309
  }
3109
3310
  return resource;
3110
3311
  }, [resource]);
3111
- const component = (0, import_react23.useCallback)(
3312
+ const component = useCallback24(
3112
3313
  async (options) => requireResource().component(options),
3113
3314
  [requireResource]
3114
3315
  );
3115
- const txScript = (0, import_react23.useCallback)(
3316
+ const txScript = useCallback24(
3116
3317
  async (options) => requireResource().txScript(options),
3117
3318
  [requireResource]
3118
3319
  );
3119
- const noteScript = (0, import_react23.useCallback)(
3320
+ const noteScript = useCallback24(
3120
3321
  async (options) => requireResource().noteScript(options),
3121
3322
  [requireResource]
3122
3323
  );
@@ -3124,25 +3325,25 @@ function useCompile() {
3124
3325
  }
3125
3326
 
3126
3327
  // src/hooks/useSessionAccount.ts
3127
- var import_react24 = require("react");
3128
- var import_miden_sdk23 = require("@miden-sdk/miden-sdk");
3328
+ import { useCallback as useCallback25, useEffect as useEffect9, useRef as useRef8, useState as useState20 } from "react";
3329
+ import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk/mt";
3129
3330
  function useSessionAccount(options) {
3130
3331
  const { client, isReady, sync } = useMiden();
3131
3332
  const setAccounts = useMidenStore((state) => state.setAccounts);
3132
- const [sessionAccountId, setSessionAccountId] = (0, import_react24.useState)(null);
3133
- const [step, setStep] = (0, import_react24.useState)("idle");
3134
- const [error, setError] = (0, import_react24.useState)(null);
3135
- const cancelledRef = (0, import_react24.useRef)(false);
3136
- const isBusyRef = (0, import_react24.useRef)(false);
3333
+ const [sessionAccountId, setSessionAccountId] = useState20(null);
3334
+ const [step, setStep] = useState20("idle");
3335
+ const [error, setError] = useState20(null);
3336
+ const cancelledRef = useRef8(false);
3337
+ const isBusyRef = useRef8(false);
3137
3338
  const storagePrefix = options.storagePrefix ?? "miden-session";
3138
3339
  const pollIntervalMs = options.pollIntervalMs ?? 3e3;
3139
3340
  const maxWaitMs = options.maxWaitMs ?? 6e4;
3140
3341
  const storageMode = options.walletOptions?.storageMode ?? "public";
3141
3342
  const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
3142
3343
  const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
3143
- const fundRef = (0, import_react24.useRef)(options.fund);
3344
+ const fundRef = useRef8(options.fund);
3144
3345
  fundRef.current = options.fund;
3145
- (0, import_react24.useEffect)(() => {
3346
+ useEffect9(() => {
3146
3347
  try {
3147
3348
  const stored = localStorage.getItem(`${storagePrefix}:accountId`);
3148
3349
  const storedReady = localStorage.getItem(`${storagePrefix}:ready`);
@@ -3159,7 +3360,7 @@ function useSessionAccount(options) {
3159
3360
  localStorage.removeItem(`${storagePrefix}:ready`);
3160
3361
  }
3161
3362
  }, [storagePrefix]);
3162
- const initialize = (0, import_react24.useCallback)(async () => {
3363
+ const initialize = useCallback25(async () => {
3163
3364
  if (!client || !isReady) {
3164
3365
  throw new Error("Miden client is not ready");
3165
3366
  }
@@ -3228,7 +3429,7 @@ function useSessionAccount(options) {
3228
3429
  maxWaitMs,
3229
3430
  setAccounts
3230
3431
  ]);
3231
- const reset = (0, import_react24.useCallback)(() => {
3432
+ const reset = useCallback25(() => {
3232
3433
  cancelledRef.current = true;
3233
3434
  isBusyRef.current = false;
3234
3435
  setSessionAccountId(null);
@@ -3249,11 +3450,11 @@ function useSessionAccount(options) {
3249
3450
  function getStorageMode3(mode) {
3250
3451
  switch (mode) {
3251
3452
  case "private":
3252
- return import_miden_sdk23.AccountStorageMode.private();
3453
+ return AccountStorageMode3.private();
3253
3454
  case "public":
3254
- return import_miden_sdk23.AccountStorageMode.public();
3455
+ return AccountStorageMode3.public();
3255
3456
  default:
3256
- return import_miden_sdk23.AccountStorageMode.public();
3457
+ return AccountStorageMode3.public();
3257
3458
  }
3258
3459
  }
3259
3460
  async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
@@ -3277,13 +3478,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
3277
3478
  }
3278
3479
 
3279
3480
  // src/hooks/useExportStore.ts
3280
- var import_react25 = require("react");
3281
- var import_miden_sdk24 = require("@miden-sdk/miden-sdk");
3481
+ import { useCallback as useCallback26, useState as useState21 } from "react";
3482
+ import { exportStore as sdkExportStore } from "@miden-sdk/miden-sdk/mt";
3282
3483
  function useExportStore() {
3283
3484
  const { client, isReady, runExclusive } = useMiden();
3284
- const [isExporting, setIsExporting] = (0, import_react25.useState)(false);
3285
- const [error, setError] = (0, import_react25.useState)(null);
3286
- const exportStore = (0, import_react25.useCallback)(async () => {
3485
+ const [isExporting, setIsExporting] = useState21(false);
3486
+ const [error, setError] = useState21(null);
3487
+ const exportStore = useCallback26(async () => {
3287
3488
  if (!client || !isReady) {
3288
3489
  throw new Error("Miden client is not ready");
3289
3490
  }
@@ -3291,7 +3492,7 @@ function useExportStore() {
3291
3492
  setError(null);
3292
3493
  try {
3293
3494
  const storeName = await client.storeIdentifier();
3294
- const snapshot = await runExclusive(() => (0, import_miden_sdk24.exportStore)(storeName));
3495
+ const snapshot = await runExclusive(() => sdkExportStore(storeName));
3295
3496
  return snapshot;
3296
3497
  } catch (err) {
3297
3498
  const error2 = err instanceof Error ? err : new Error(String(err));
@@ -3301,7 +3502,7 @@ function useExportStore() {
3301
3502
  setIsExporting(false);
3302
3503
  }
3303
3504
  }, [client, isReady, runExclusive]);
3304
- const reset = (0, import_react25.useCallback)(() => {
3505
+ const reset = useCallback26(() => {
3305
3506
  setIsExporting(false);
3306
3507
  setError(null);
3307
3508
  }, []);
@@ -3314,13 +3515,13 @@ function useExportStore() {
3314
3515
  }
3315
3516
 
3316
3517
  // src/hooks/useImportStore.ts
3317
- var import_react26 = require("react");
3318
- var import_miden_sdk25 = require("@miden-sdk/miden-sdk");
3518
+ import { useCallback as useCallback27, useState as useState22 } from "react";
3519
+ import { importStore as sdkImportStore } from "@miden-sdk/miden-sdk/mt";
3319
3520
  function useImportStore() {
3320
3521
  const { client, isReady, runExclusive, sync } = useMiden();
3321
- const [isImporting, setIsImporting] = (0, import_react26.useState)(false);
3322
- const [error, setError] = (0, import_react26.useState)(null);
3323
- const importStore = (0, import_react26.useCallback)(
3522
+ const [isImporting, setIsImporting] = useState22(false);
3523
+ const [error, setError] = useState22(null);
3524
+ const importStore = useCallback27(
3324
3525
  async (storeDump, storeName, options) => {
3325
3526
  if (!client || !isReady) {
3326
3527
  throw new Error("Miden client is not ready");
@@ -3328,7 +3529,7 @@ function useImportStore() {
3328
3529
  setIsImporting(true);
3329
3530
  setError(null);
3330
3531
  try {
3331
- await runExclusive(() => (0, import_miden_sdk25.importStore)(storeName, storeDump));
3532
+ await runExclusive(() => sdkImportStore(storeName, storeDump));
3332
3533
  if (!options?.skipSync) {
3333
3534
  await sync();
3334
3535
  }
@@ -3342,7 +3543,7 @@ function useImportStore() {
3342
3543
  },
3343
3544
  [client, isReady, runExclusive, sync]
3344
3545
  );
3345
- const reset = (0, import_react26.useCallback)(() => {
3546
+ const reset = useCallback27(() => {
3346
3547
  setIsImporting(false);
3347
3548
  setError(null);
3348
3549
  }, []);
@@ -3355,13 +3556,13 @@ function useImportStore() {
3355
3556
  }
3356
3557
 
3357
3558
  // src/hooks/useImportNote.ts
3358
- var import_react27 = require("react");
3359
- var import_miden_sdk26 = require("@miden-sdk/miden-sdk");
3559
+ import { useCallback as useCallback28, useState as useState23 } from "react";
3560
+ import { NoteFile } from "@miden-sdk/miden-sdk/mt";
3360
3561
  function useImportNote() {
3361
3562
  const { client, isReady, runExclusive, sync } = useMiden();
3362
- const [isImporting, setIsImporting] = (0, import_react27.useState)(false);
3363
- const [error, setError] = (0, import_react27.useState)(null);
3364
- const importNote = (0, import_react27.useCallback)(
3563
+ const [isImporting, setIsImporting] = useState23(false);
3564
+ const [error, setError] = useState23(null);
3565
+ const importNote = useCallback28(
3365
3566
  async (noteBytes) => {
3366
3567
  if (!client || !isReady) {
3367
3568
  throw new Error("Miden client is not ready");
@@ -3369,7 +3570,7 @@ function useImportNote() {
3369
3570
  setIsImporting(true);
3370
3571
  setError(null);
3371
3572
  try {
3372
- const noteFile = import_miden_sdk26.NoteFile.deserialize(noteBytes);
3573
+ const noteFile = NoteFile.deserialize(noteBytes);
3373
3574
  const noteId = await runExclusive(
3374
3575
  () => client.importNoteFile(noteFile)
3375
3576
  );
@@ -3385,7 +3586,7 @@ function useImportNote() {
3385
3586
  },
3386
3587
  [client, isReady, runExclusive, sync]
3387
3588
  );
3388
- const reset = (0, import_react27.useCallback)(() => {
3589
+ const reset = useCallback28(() => {
3389
3590
  setIsImporting(false);
3390
3591
  setError(null);
3391
3592
  }, []);
@@ -3398,13 +3599,13 @@ function useImportNote() {
3398
3599
  }
3399
3600
 
3400
3601
  // src/hooks/useExportNote.ts
3401
- var import_react28 = require("react");
3402
- var import_miden_sdk27 = require("@miden-sdk/miden-sdk");
3602
+ import { useCallback as useCallback29, useState as useState24 } from "react";
3603
+ import { NoteExportFormat } from "@miden-sdk/miden-sdk/mt";
3403
3604
  function useExportNote() {
3404
3605
  const { client, isReady, runExclusive } = useMiden();
3405
- const [isExporting, setIsExporting] = (0, import_react28.useState)(false);
3406
- const [error, setError] = (0, import_react28.useState)(null);
3407
- const exportNote = (0, import_react28.useCallback)(
3606
+ const [isExporting, setIsExporting] = useState24(false);
3607
+ const [error, setError] = useState24(null);
3608
+ const exportNote = useCallback29(
3408
3609
  async (noteId) => {
3409
3610
  if (!client || !isReady) {
3410
3611
  throw new Error("Miden client is not ready");
@@ -3413,7 +3614,7 @@ function useExportNote() {
3413
3614
  setError(null);
3414
3615
  try {
3415
3616
  const noteFile = await runExclusive(
3416
- () => client.exportNoteFile(noteId, import_miden_sdk27.NoteExportFormat.Full)
3617
+ () => client.exportNoteFile(noteId, NoteExportFormat.Full)
3417
3618
  );
3418
3619
  return noteFile.serialize();
3419
3620
  } catch (err) {
@@ -3426,7 +3627,7 @@ function useExportNote() {
3426
3627
  },
3427
3628
  [client, isReady, runExclusive]
3428
3629
  );
3429
- const reset = (0, import_react28.useCallback)(() => {
3630
+ const reset = useCallback29(() => {
3430
3631
  setIsExporting(false);
3431
3632
  setError(null);
3432
3633
  }, []);
@@ -3439,12 +3640,12 @@ function useExportNote() {
3439
3640
  }
3440
3641
 
3441
3642
  // src/hooks/useSyncControl.ts
3442
- var import_react29 = require("react");
3643
+ import { useCallback as useCallback30 } from "react";
3443
3644
  function useSyncControl() {
3444
3645
  const isPaused = useMidenStore((state) => state.syncPaused);
3445
3646
  const setSyncPaused = useMidenStore((state) => state.setSyncPaused);
3446
- const pauseSync = (0, import_react29.useCallback)(() => setSyncPaused(true), [setSyncPaused]);
3447
- const resumeSync = (0, import_react29.useCallback)(() => setSyncPaused(false), [setSyncPaused]);
3647
+ const pauseSync = useCallback30(() => setSyncPaused(true), [setSyncPaused]);
3648
+ const resumeSync = useCallback30(() => setSyncPaused(false), [setSyncPaused]);
3448
3649
  return {
3449
3650
  pauseSync,
3450
3651
  resumeSync,
@@ -3601,8 +3802,7 @@ function createMidenStorage(prefix) {
3601
3802
 
3602
3803
  // src/index.ts
3603
3804
  installAccountBech32();
3604
- // Annotate the CommonJS export names for ESM import in node:
3605
- 0 && (module.exports = {
3805
+ export {
3606
3806
  AuthScheme,
3607
3807
  DEFAULTS,
3608
3808
  MidenError,
@@ -3647,6 +3847,9 @@ installAccountBech32();
3647
3847
  useMultiSigner,
3648
3848
  useNoteStream,
3649
3849
  useNotes,
3850
+ usePswapCancel,
3851
+ usePswapConsume,
3852
+ usePswapCreate,
3650
3853
  useSend,
3651
3854
  useSessionAccount,
3652
3855
  useSigner,
@@ -3659,4 +3862,4 @@ installAccountBech32();
3659
3862
  useWaitForNotes,
3660
3863
  waitForWalletDetection,
3661
3864
  wrapWasmError
3662
- });
3865
+ };