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

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,21 +528,21 @@ 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)(
545
+ const defaultProver = useMemo(
632
546
  () => resolveTransactionProver(resolvedConfig),
633
547
  [
634
548
  resolvedConfig.prover,
@@ -637,11 +551,11 @@ function MidenProvider({
637
551
  resolvedConfig.proverUrls?.testnet
638
552
  ]
639
553
  );
640
- const runExclusive = (0, import_react2.useCallback)(
554
+ const runExclusive = useCallback(
641
555
  async (fn) => clientLockRef.current.runExclusive(fn),
642
556
  []
643
557
  );
644
- const sync = (0, import_react2.useCallback)(async () => {
558
+ const sync = useCallback(async () => {
645
559
  if (!client || !isReady) return;
646
560
  const store = useMidenStore.getState();
647
561
  if (store.sync.isSyncing) return;
@@ -668,10 +582,10 @@ function MidenProvider({
668
582
  const signerStoreName = signerContext?.storeName ?? null;
669
583
  const signerAccountType = signerContext?.accountConfig?.accountType ?? null;
670
584
  const signerStorageMode = signerContext?.accountConfig?.storageMode?.toString() ?? null;
671
- (0, import_react2.useEffect)(() => {
585
+ useEffect(() => {
672
586
  signCbRef.current = signerContext?.signCb ?? null;
673
587
  }, [signerContext?.signCb]);
674
- const wrappedSignCb = (0, import_react2.useCallback)(
588
+ const wrappedSignCb = useCallback(
675
589
  async (pubKey, signingInputs) => {
676
590
  const cb = signCbRef.current;
677
591
  if (!cb) {
@@ -681,7 +595,7 @@ function MidenProvider({
681
595
  },
682
596
  []
683
597
  );
684
- (0, import_react2.useEffect)(() => {
598
+ useEffect(() => {
685
599
  if (signerIsConnected === null && isInitializedRef.current) return;
686
600
  if (signerIsConnected === false) {
687
601
  const store = useMidenStore.getState();
@@ -715,14 +629,16 @@ function MidenProvider({
715
629
  if (signerContext && signerIsConnected === true) {
716
630
  const storeName = `MidenClientDB_${signerContext.storeName}`;
717
631
  signCbRef.current = signerContext.signCb;
718
- webClient = await import_miden_sdk6.WasmWebClient.createClientWithExternalKeystore(
632
+ webClient = await WebClient.createClientWithExternalKeystore(
719
633
  resolvedConfig.rpcUrl,
720
634
  resolvedConfig.noteTransportUrl,
721
635
  resolvedConfig.seed,
722
636
  storeName,
723
637
  signerContext.getKeyCb,
724
638
  signerContext.insertKeyCb,
725
- wrappedSignCb
639
+ wrappedSignCb,
640
+ void 0,
641
+ resolvedConfig.useWorker
726
642
  );
727
643
  if (cancelled) return;
728
644
  const accountId = await initializeSignerAccount(
@@ -735,10 +651,13 @@ function MidenProvider({
735
651
  currentStoreNameRef.current = signerContext.storeName;
736
652
  } else {
737
653
  const seed = resolvedConfig.seed;
738
- webClient = await import_miden_sdk6.WasmWebClient.createClient(
654
+ webClient = await WebClient.createClient(
739
655
  resolvedConfig.rpcUrl,
740
656
  resolvedConfig.noteTransportUrl,
741
- seed
657
+ seed,
658
+ void 0,
659
+ void 0,
660
+ resolvedConfig.useWorker
742
661
  );
743
662
  if (cancelled) return;
744
663
  }
@@ -804,7 +723,7 @@ function MidenProvider({
804
723
  // signCb changes are handled by the dedicated useEffect + signCbRef above,
805
724
  // not by this effect.
806
725
  ]);
807
- (0, import_react2.useEffect)(() => {
726
+ useEffect(() => {
808
727
  if (!isReady || !client) return;
809
728
  const interval = config.autoSyncInterval ?? DEFAULTS.AUTO_SYNC_INTERVAL;
810
729
  if (interval <= 0) return;
@@ -820,7 +739,7 @@ function MidenProvider({
820
739
  }
821
740
  };
822
741
  }, [isReady, client, config.autoSyncInterval, sync]);
823
- (0, import_react2.useEffect)(() => {
742
+ useEffect(() => {
824
743
  if (!isReady || !client) return;
825
744
  const unsubscribe = client.onStateChanged?.(async () => {
826
745
  try {
@@ -835,13 +754,13 @@ function MidenProvider({
835
754
  };
836
755
  }, [isReady, client, setSyncState]);
837
756
  if (isInitializing && loadingComponent) {
838
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: loadingComponent });
757
+ return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
839
758
  }
840
759
  if (initError && errorComponent) {
841
760
  if (typeof errorComponent === "function") {
842
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: errorComponent(initError) });
761
+ return /* @__PURE__ */ jsx(Fragment, { children: errorComponent(initError) });
843
762
  }
844
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: errorComponent });
763
+ return /* @__PURE__ */ jsx(Fragment, { children: errorComponent });
845
764
  }
846
765
  const contextValue = {
847
766
  client,
@@ -854,10 +773,10 @@ function MidenProvider({
854
773
  signerAccountId,
855
774
  signerConnected
856
775
  };
857
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MidenContext.Provider, { value: contextValue, children });
776
+ return /* @__PURE__ */ jsx(MidenContext.Provider, { value: contextValue, children });
858
777
  }
859
778
  function useMiden() {
860
- const context = (0, import_react2.useContext)(MidenContext);
779
+ const context = useContext2(MidenContext);
861
780
  if (!context) {
862
781
  throw new Error("useMiden must be used within a MidenProvider");
863
782
  }
@@ -874,22 +793,30 @@ function useMidenClient() {
874
793
  }
875
794
 
876
795
  // 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);
796
+ import {
797
+ createContext as createContext3,
798
+ useContext as useContext3,
799
+ useEffect as useEffect2,
800
+ useRef as useRef2,
801
+ useState as useState2,
802
+ useCallback as useCallback2,
803
+ useMemo as useMemo2
804
+ } from "react";
805
+ import { jsx as jsx2 } from "react/jsx-runtime";
806
+ var MultiSignerRegistryContext = createContext3(null);
807
+ var MultiSignerContext = createContext3(null);
881
808
  function MultiSignerProvider({ children }) {
882
- const signersRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
883
- const [signersSnapshot, setSignersSnapshot] = (0, import_react3.useState)(
809
+ const signersRef = useRef2(/* @__PURE__ */ new Map());
810
+ const [signersSnapshot, setSignersSnapshot] = useState2(
884
811
  []
885
812
  );
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)(() => {
813
+ const [activeSignerName, setActiveSignerName] = useState2(null);
814
+ const activeSignerNameRef = useRef2(null);
815
+ const generationRef = useRef2(0);
816
+ const updateSnapshot = useCallback2(() => {
890
817
  setSignersSnapshot(Array.from(signersRef.current.values()));
891
818
  }, []);
892
- const register = (0, import_react3.useCallback)(
819
+ const register = useCallback2(
893
820
  (value) => {
894
821
  const prev = signersRef.current.get(value.name);
895
822
  signersRef.current.set(value.name, value);
@@ -899,7 +826,7 @@ function MultiSignerProvider({ children }) {
899
826
  },
900
827
  [updateSnapshot]
901
828
  );
902
- const unregister = (0, import_react3.useCallback)(
829
+ const unregister = useCallback2(
903
830
  (name) => {
904
831
  signersRef.current.delete(name);
905
832
  setActiveSignerName((current) => current === name ? null : current);
@@ -907,12 +834,12 @@ function MultiSignerProvider({ children }) {
907
834
  },
908
835
  [updateSnapshot]
909
836
  );
910
- const registry = (0, import_react3.useMemo)(
837
+ const registry = useMemo2(
911
838
  () => ({ register, unregister }),
912
839
  [register, unregister]
913
840
  );
914
841
  const activeSigner = activeSignerName ? signersSnapshot.find((s) => s.name === activeSignerName) ?? null : null;
915
- const stableSignCb = (0, import_react3.useCallback)(
842
+ const stableSignCb = useCallback2(
916
843
  async (pubKey, signingInputs) => {
917
844
  const name = activeSignerName;
918
845
  if (!name) throw new Error("No active signer (signer was disconnected)");
@@ -922,21 +849,21 @@ function MultiSignerProvider({ children }) {
922
849
  },
923
850
  [activeSignerName]
924
851
  );
925
- const stableConnect = (0, import_react3.useCallback)(async () => {
852
+ const stableConnect = useCallback2(async () => {
926
853
  const name = activeSignerName;
927
854
  if (!name) throw new Error("No active signer (signer was disconnected)");
928
855
  const signer = signersRef.current.get(name);
929
856
  if (!signer) throw new Error(`Signer "${name}" not found in registry`);
930
857
  return signer.connect();
931
858
  }, [activeSignerName]);
932
- const stableDisconnect = (0, import_react3.useCallback)(async () => {
859
+ const stableDisconnect = useCallback2(async () => {
933
860
  const name = activeSignerName;
934
861
  if (!name) throw new Error("No active signer (signer was disconnected)");
935
862
  const signer = signersRef.current.get(name);
936
863
  if (!signer) throw new Error(`Signer "${name}" not found in registry`);
937
864
  return signer.disconnect();
938
865
  }, [activeSignerName]);
939
- const forwardedValue = (0, import_react3.useMemo)(() => {
866
+ const forwardedValue = useMemo2(() => {
940
867
  if (!activeSigner) return null;
941
868
  return {
942
869
  name: activeSigner.name,
@@ -956,11 +883,11 @@ function MultiSignerProvider({ children }) {
956
883
  stableConnect,
957
884
  stableDisconnect
958
885
  ]);
959
- const setActiveName = (0, import_react3.useCallback)((name) => {
886
+ const setActiveName = useCallback2((name) => {
960
887
  activeSignerNameRef.current = name;
961
888
  setActiveSignerName(name);
962
889
  }, []);
963
- const connectSigner = (0, import_react3.useCallback)(
890
+ const connectSigner = useCallback2(
964
891
  async (name) => {
965
892
  const currentName = activeSignerNameRef.current;
966
893
  const currentSigner = currentName ? signersRef.current.get(currentName) : null;
@@ -985,7 +912,7 @@ function MultiSignerProvider({ children }) {
985
912
  },
986
913
  [setActiveName]
987
914
  );
988
- const disconnectSigner = (0, import_react3.useCallback)(async () => {
915
+ const disconnectSigner = useCallback2(async () => {
989
916
  ++generationRef.current;
990
917
  const currentName = activeSignerNameRef.current;
991
918
  const signer = currentName ? signersRef.current.get(currentName) : null;
@@ -996,7 +923,7 @@ function MultiSignerProvider({ children }) {
996
923
  });
997
924
  }
998
925
  }, [setActiveName]);
999
- const multiSignerValue = (0, import_react3.useMemo)(
926
+ const multiSignerValue = useMemo2(
1000
927
  () => ({
1001
928
  signers: signersSnapshot,
1002
929
  activeSigner,
@@ -1005,18 +932,18 @@ function MultiSignerProvider({ children }) {
1005
932
  }),
1006
933
  [signersSnapshot, activeSigner, connectSigner, disconnectSigner]
1007
934
  );
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 }) }) });
935
+ return /* @__PURE__ */ jsx2(SignerContext.Provider, { value: forwardedValue, children: /* @__PURE__ */ jsx2(MultiSignerRegistryContext.Provider, { value: registry, children: /* @__PURE__ */ jsx2(MultiSignerContext.Provider, { value: multiSignerValue, children }) }) });
1009
936
  }
1010
937
  function SignerSlot() {
1011
938
  const signerValue = useSigner();
1012
- const registry = (0, import_react3.useContext)(MultiSignerRegistryContext);
1013
- const nameRef = (0, import_react3.useRef)();
1014
- (0, import_react3.useEffect)(() => {
939
+ const registry = useContext3(MultiSignerRegistryContext);
940
+ const nameRef = useRef2();
941
+ useEffect2(() => {
1015
942
  if (!signerValue || !registry) return;
1016
943
  nameRef.current = signerValue.name;
1017
944
  registry.register(signerValue);
1018
945
  }, [signerValue, registry]);
1019
- (0, import_react3.useEffect)(() => {
946
+ useEffect2(() => {
1020
947
  return () => {
1021
948
  if (nameRef.current && registry) {
1022
949
  registry.unregister(nameRef.current);
@@ -1026,18 +953,18 @@ function SignerSlot() {
1026
953
  return null;
1027
954
  }
1028
955
  function useMultiSigner() {
1029
- return (0, import_react3.useContext)(MultiSignerContext);
956
+ return useContext3(MultiSignerContext);
1030
957
  }
1031
958
 
1032
959
  // src/hooks/useAccounts.ts
1033
- var import_react4 = require("react");
960
+ import { useCallback as useCallback3, useEffect as useEffect3 } from "react";
1034
961
  function useAccounts() {
1035
962
  const { client, isReady } = useMiden();
1036
963
  const accounts = useAccountsStore();
1037
964
  const isLoadingAccounts = useMidenStore((state) => state.isLoadingAccounts);
1038
965
  const setLoadingAccounts = useMidenStore((state) => state.setLoadingAccounts);
1039
966
  const setAccounts = useMidenStore((state) => state.setAccounts);
1040
- const refetch = (0, import_react4.useCallback)(async () => {
967
+ const refetch = useCallback3(async () => {
1041
968
  if (!client || !isReady) return;
1042
969
  setLoadingAccounts(true);
1043
970
  try {
@@ -1049,7 +976,7 @@ function useAccounts() {
1049
976
  setLoadingAccounts(false);
1050
977
  }
1051
978
  }, [client, isReady, setAccounts, setLoadingAccounts]);
1052
- (0, import_react4.useEffect)(() => {
979
+ useEffect3(() => {
1053
980
  if (isReady && accounts.length === 0) {
1054
981
  refetch();
1055
982
  }
@@ -1075,11 +1002,15 @@ function useAccounts() {
1075
1002
  }
1076
1003
 
1077
1004
  // src/hooks/useAccount.ts
1078
- var import_react6 = require("react");
1005
+ import { useCallback as useCallback4, useEffect as useEffect5, useState as useState3, useMemo as useMemo4 } from "react";
1079
1006
 
1080
1007
  // src/hooks/useAssetMetadata.ts
1081
- var import_react5 = require("react");
1082
- var import_miden_sdk7 = require("@miden-sdk/miden-sdk");
1008
+ import { useEffect as useEffect4, useMemo as useMemo3 } from "react";
1009
+ import {
1010
+ BasicFungibleFaucetComponent,
1011
+ Endpoint,
1012
+ RpcClient
1013
+ } from "@miden-sdk/miden-sdk/mt";
1083
1014
  var inflight = /* @__PURE__ */ new Map();
1084
1015
  var rpcClients = /* @__PURE__ */ new Map();
1085
1016
  var getRpcClient = (rpcUrl) => {
@@ -1087,8 +1018,8 @@ var getRpcClient = (rpcUrl) => {
1087
1018
  const existing = rpcClients.get(key);
1088
1019
  if (existing) return existing;
1089
1020
  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);
1021
+ const endpoint = rpcUrl ? new Endpoint(rpcUrl) : Endpoint.testnet();
1022
+ const client = new RpcClient(endpoint);
1092
1023
  rpcClients.set(key, client);
1093
1024
  return client;
1094
1025
  } catch {
@@ -1102,7 +1033,7 @@ var fetchAssetMetadata = async (rpcClient, assetId) => {
1102
1033
  const fetched = await rpcClient.getAccountDetails(accountId);
1103
1034
  const account = fetched.account?.();
1104
1035
  if (!account) return null;
1105
- const faucet = import_miden_sdk7.BasicFungibleFaucetComponent.fromAccount(account);
1036
+ const faucet = BasicFungibleFaucetComponent.fromAccount(account);
1106
1037
  const symbol = faucet.symbol().toString();
1107
1038
  const decimals = faucet.decimals();
1108
1039
  return { assetId, symbol, decimals };
@@ -1114,12 +1045,12 @@ function useAssetMetadata(assetIds = []) {
1114
1045
  const assetMetadata = useAssetMetadataStore();
1115
1046
  const setAssetMetadata = useMidenStore((state) => state.setAssetMetadata);
1116
1047
  const rpcUrl = useMidenStore((state) => state.config.rpcUrl);
1117
- const rpcClient = (0, import_react5.useMemo)(() => getRpcClient(rpcUrl), [rpcUrl]);
1118
- const uniqueAssetIds = (0, import_react5.useMemo)(
1048
+ const rpcClient = useMemo3(() => getRpcClient(rpcUrl), [rpcUrl]);
1049
+ const uniqueAssetIds = useMemo3(
1119
1050
  () => Array.from(new Set(assetIds.filter(Boolean))),
1120
1051
  [assetIds]
1121
1052
  );
1122
- (0, import_react5.useEffect)(() => {
1053
+ useEffect4(() => {
1123
1054
  if (!rpcClient || uniqueAssetIds.length === 0) return;
1124
1055
  uniqueAssetIds.forEach((assetId) => {
1125
1056
  const existing = assetMetadata.get(assetId);
@@ -1142,15 +1073,15 @@ function useAccount(accountId) {
1142
1073
  const accountDetails = useMidenStore((state) => state.accountDetails);
1143
1074
  const setAccountDetails = useMidenStore((state) => state.setAccountDetails);
1144
1075
  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)(() => {
1076
+ const [isLoading, setIsLoading] = useState3(false);
1077
+ const [error, setError] = useState3(null);
1078
+ const accountIdStr = useMemo4(() => {
1148
1079
  if (!accountId) return void 0;
1149
1080
  if (typeof accountId === "string") return accountId;
1150
1081
  return parseAccountId(accountId).toString();
1151
1082
  }, [accountId]);
1152
1083
  const account = accountIdStr ? accountDetails.get(accountIdStr) ?? null : null;
1153
- const refetch = (0, import_react6.useCallback)(async () => {
1084
+ const refetch = useCallback4(async () => {
1154
1085
  if (!client || !isReady || !accountIdStr) return;
1155
1086
  setIsLoading(true);
1156
1087
  setError(null);
@@ -1167,16 +1098,16 @@ function useAccount(accountId) {
1167
1098
  setIsLoading(false);
1168
1099
  }
1169
1100
  }, [client, isReady, accountIdStr, setAccountDetails]);
1170
- (0, import_react6.useEffect)(() => {
1101
+ useEffect5(() => {
1171
1102
  if (isReady && accountIdStr && !account) {
1172
1103
  refetch();
1173
1104
  }
1174
1105
  }, [isReady, accountIdStr, account, refetch]);
1175
- (0, import_react6.useEffect)(() => {
1106
+ useEffect5(() => {
1176
1107
  if (!isReady || !accountIdStr || !lastSyncTime) return;
1177
1108
  refetch();
1178
1109
  }, [isReady, accountIdStr, lastSyncTime, refetch]);
1179
- const rawAssets = (0, import_react6.useMemo)(() => {
1110
+ const rawAssets = useMemo4(() => {
1180
1111
  if (!account) return [];
1181
1112
  try {
1182
1113
  const vault = account.vault();
@@ -1193,12 +1124,12 @@ function useAccount(accountId) {
1193
1124
  return [];
1194
1125
  }
1195
1126
  }, [account]);
1196
- const assetIds = (0, import_react6.useMemo)(
1127
+ const assetIds = useMemo4(
1197
1128
  () => rawAssets.map((asset) => asset.assetId),
1198
1129
  [rawAssets]
1199
1130
  );
1200
1131
  const { assetMetadata } = useAssetMetadata(assetIds);
1201
- const assets = (0, import_react6.useMemo)(
1132
+ const assets = useMemo4(
1202
1133
  () => rawAssets.map((asset) => {
1203
1134
  const metadata = assetMetadata.get(asset.assetId);
1204
1135
  return {
@@ -1209,7 +1140,7 @@ function useAccount(accountId) {
1209
1140
  }),
1210
1141
  [rawAssets, assetMetadata]
1211
1142
  );
1212
- const getBalance = (0, import_react6.useCallback)(
1143
+ const getBalance = useCallback4(
1213
1144
  (assetId) => {
1214
1145
  const asset = assets.find((a) => a.assetId === assetId);
1215
1146
  return asset?.amount ?? 0n;
@@ -1227,8 +1158,8 @@ function useAccount(accountId) {
1227
1158
  }
1228
1159
 
1229
1160
  // src/hooks/useNotes.ts
1230
- var import_react7 = require("react");
1231
- var import_miden_sdk9 = require("@miden-sdk/miden-sdk");
1161
+ import { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo5, useState as useState4 } from "react";
1162
+ import { NoteFilter } from "@miden-sdk/miden-sdk/mt";
1232
1163
 
1233
1164
  // src/utils/amounts.ts
1234
1165
  var formatAssetAmount = (amount, decimals) => {
@@ -1270,6 +1201,27 @@ var parseAssetAmount = (input, decimals) => {
1270
1201
  };
1271
1202
 
1272
1203
  // src/utils/notes.ts
1204
+ var resolveNoteInput = async (input, client) => {
1205
+ if (typeof input === "string") {
1206
+ const record2 = await client.getInputNote(input);
1207
+ if (!record2) {
1208
+ throw new Error(`Note not found: ${input}`);
1209
+ }
1210
+ return record2.toNote();
1211
+ }
1212
+ if (typeof input.toNote === "function") {
1213
+ return input.toNote();
1214
+ }
1215
+ if (typeof input.id === "function") {
1216
+ return input;
1217
+ }
1218
+ const hex = input.toString();
1219
+ const record = await client.getInputNote(hex);
1220
+ if (!record) {
1221
+ throw new Error(`Note not found: ${hex}`);
1222
+ }
1223
+ return record.toNote();
1224
+ };
1273
1225
  var getInputNoteRecord = (note) => {
1274
1226
  const maybeConsumable = note;
1275
1227
  if (typeof maybeConsumable.inputNoteRecord === "function") {
@@ -1280,7 +1232,9 @@ var getInputNoteRecord = (note) => {
1280
1232
  var getNoteSummary = (note, getAssetMetadata) => {
1281
1233
  try {
1282
1234
  const record = getInputNoteRecord(note);
1283
- const id = record.id().toString();
1235
+ const rawId = record.id();
1236
+ if (!rawId) return null;
1237
+ const id = rawId.toString();
1284
1238
  const assets = [];
1285
1239
  try {
1286
1240
  const details = record.details();
@@ -1333,30 +1287,34 @@ function accountIdsEqual(a, b) {
1333
1287
  }
1334
1288
 
1335
1289
  // src/utils/noteFilters.ts
1336
- var import_miden_sdk8 = require("@miden-sdk/miden-sdk");
1290
+ import {
1291
+ NoteFilterTypes,
1292
+ NoteType,
1293
+ TransactionFilter
1294
+ } from "@miden-sdk/miden-sdk/mt";
1337
1295
  function getNoteFilterType(status) {
1338
1296
  switch (status) {
1339
1297
  case "consumed":
1340
- return import_miden_sdk8.NoteFilterTypes.Consumed;
1298
+ return NoteFilterTypes.Consumed;
1341
1299
  case "committed":
1342
- return import_miden_sdk8.NoteFilterTypes.Committed;
1300
+ return NoteFilterTypes.Committed;
1343
1301
  case "expected":
1344
- return import_miden_sdk8.NoteFilterTypes.Expected;
1302
+ return NoteFilterTypes.Expected;
1345
1303
  case "processing":
1346
- return import_miden_sdk8.NoteFilterTypes.Processing;
1304
+ return NoteFilterTypes.Processing;
1347
1305
  case "all":
1348
1306
  default:
1349
- return import_miden_sdk8.NoteFilterTypes.All;
1307
+ return NoteFilterTypes.All;
1350
1308
  }
1351
1309
  }
1352
1310
  function getNoteType(type) {
1353
1311
  switch (type) {
1354
1312
  case "private":
1355
- return import_miden_sdk8.NoteType.Private;
1313
+ return NoteType.Private;
1356
1314
  case "public":
1357
- return import_miden_sdk8.NoteType.Public;
1315
+ return NoteType.Public;
1358
1316
  default:
1359
- return import_miden_sdk8.NoteType.Private;
1317
+ return NoteType.Private;
1360
1318
  }
1361
1319
  }
1362
1320
  async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWaitMs = 1e4, delayMs = 1e3) {
@@ -1365,7 +1323,7 @@ async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWa
1365
1323
  while (Date.now() < deadline) {
1366
1324
  await runExclusiveSafe(() => client.syncState());
1367
1325
  const records = await runExclusiveSafe(
1368
- () => client.getTransactions(import_miden_sdk8.TransactionFilter.all())
1326
+ () => client.getTransactions(TransactionFilter.all())
1369
1327
  );
1370
1328
  const record = records.find(
1371
1329
  (r) => normalizeHex(r.id().toHex()) === targetHex
@@ -1401,14 +1359,14 @@ function useNotes(options) {
1401
1359
  (state) => state.setConsumableNotesIfChanged
1402
1360
  );
1403
1361
  const { lastSyncTime } = useSyncStateStore();
1404
- const [error, setError] = (0, import_react7.useState)(null);
1405
- const refetch = (0, import_react7.useCallback)(async () => {
1362
+ const [error, setError] = useState4(null);
1363
+ const refetch = useCallback5(async () => {
1406
1364
  if (!client || !isReady) return;
1407
1365
  setLoadingNotes(true);
1408
1366
  setError(null);
1409
1367
  try {
1410
1368
  const filterType = getNoteFilterType(options?.status);
1411
- const filter = new import_miden_sdk9.NoteFilter(filterType);
1369
+ const filter = new NoteFilter(filterType);
1412
1370
  const fetchedNotes = await client.getInputNotes(filter);
1413
1371
  let fetchedConsumable;
1414
1372
  if (options?.accountId) {
@@ -1433,16 +1391,16 @@ function useNotes(options) {
1433
1391
  setNotesIfChanged,
1434
1392
  setConsumableNotesIfChanged
1435
1393
  ]);
1436
- (0, import_react7.useEffect)(() => {
1394
+ useEffect6(() => {
1437
1395
  if (isReady && notes.length === 0) {
1438
1396
  refetch();
1439
1397
  }
1440
1398
  }, [isReady, notes.length, refetch]);
1441
- (0, import_react7.useEffect)(() => {
1399
+ useEffect6(() => {
1442
1400
  if (!isReady || !lastSyncTime) return;
1443
1401
  refetch();
1444
1402
  }, [isReady, lastSyncTime, refetch]);
1445
- const noteAssetIds = (0, import_react7.useMemo)(() => {
1403
+ const noteAssetIds = useMemo5(() => {
1446
1404
  const ids = /* @__PURE__ */ new Set();
1447
1405
  const collect = (note) => {
1448
1406
  const summary = getNoteSummary(note);
@@ -1454,11 +1412,11 @@ function useNotes(options) {
1454
1412
  return Array.from(ids);
1455
1413
  }, [notes, consumableNotes]);
1456
1414
  const { assetMetadata } = useAssetMetadata(noteAssetIds);
1457
- const getMetadata = (0, import_react7.useCallback)(
1415
+ const getMetadata = useCallback5(
1458
1416
  (assetId) => assetMetadata.get(assetId),
1459
1417
  [assetMetadata]
1460
1418
  );
1461
- const normalizedSender = (0, import_react7.useMemo)(() => {
1419
+ const normalizedSender = useMemo5(() => {
1462
1420
  if (!options?.sender) return null;
1463
1421
  try {
1464
1422
  return normalizeAccountId(options.sender);
@@ -1466,11 +1424,11 @@ function useNotes(options) {
1466
1424
  return options.sender;
1467
1425
  }
1468
1426
  }, [options?.sender]);
1469
- const excludeIdsKey = (0, import_react7.useMemo)(() => {
1427
+ const excludeIdsKey = useMemo5(() => {
1470
1428
  if (!options?.excludeIds || options.excludeIds.length === 0) return "";
1471
1429
  return [...options.excludeIds].sort().join("\0");
1472
1430
  }, [options?.excludeIds]);
1473
- const filterBySender = (0, import_react7.useCallback)(
1431
+ const filterBySender = useCallback5(
1474
1432
  (summaries, target) => {
1475
1433
  const cache = /* @__PURE__ */ new Map();
1476
1434
  return summaries.filter((s) => {
@@ -1489,7 +1447,7 @@ function useNotes(options) {
1489
1447
  },
1490
1448
  []
1491
1449
  );
1492
- const noteSummaries = (0, import_react7.useMemo)(() => {
1450
+ const noteSummaries = useMemo5(() => {
1493
1451
  let summaries = notes.map((note) => getNoteSummary(note, getMetadata)).filter(Boolean);
1494
1452
  if (normalizedSender) {
1495
1453
  summaries = filterBySender(summaries, normalizedSender);
@@ -1500,7 +1458,7 @@ function useNotes(options) {
1500
1458
  }
1501
1459
  return summaries;
1502
1460
  }, [notes, getMetadata, normalizedSender, excludeIdsKey, filterBySender]);
1503
- const consumableNoteSummaries = (0, import_react7.useMemo)(() => {
1461
+ const consumableNoteSummaries = useMemo5(() => {
1504
1462
  let summaries = consumableNotes.map((note) => getNoteSummary(note, getMetadata)).filter(Boolean);
1505
1463
  if (normalizedSender) {
1506
1464
  summaries = filterBySender(summaries, normalizedSender);
@@ -1529,39 +1487,29 @@ function useNotes(options) {
1529
1487
  }
1530
1488
 
1531
1489
  // src/hooks/useNoteStream.ts
1532
- var import_react8 = require("react");
1533
- var import_miden_sdk11 = require("@miden-sdk/miden-sdk");
1490
+ import { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3, useState as useState5 } from "react";
1491
+ import { NoteFilter as NoteFilter2 } from "@miden-sdk/miden-sdk/mt";
1534
1492
 
1535
1493
  // src/utils/noteAttachment.ts
1536
- var import_miden_sdk10 = require("@miden-sdk/miden-sdk");
1494
+ import {
1495
+ NoteAttachment,
1496
+ NoteAttachmentScheme,
1497
+ Word
1498
+ } from "@miden-sdk/miden-sdk/mt";
1537
1499
  function readNoteAttachment(note) {
1538
1500
  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;
1501
+ const attachments = note.attachments?.();
1502
+ if (!attachments || attachments.length === 0) return null;
1503
+ const words = attachments[0].toWords();
1504
+ if (words.length === 0) return null;
1505
+ const values = [];
1506
+ for (const word of words) {
1507
+ for (const value of word.toU64s()) {
1508
+ values.push(BigInt(value));
1509
+ }
1510
+ }
1511
+ if (values.every((value) => value === 0n)) return null;
1512
+ return { values, kind: words.length === 1 ? "word" : "array" };
1565
1513
  } catch {
1566
1514
  return null;
1567
1515
  }
@@ -1572,30 +1520,29 @@ function createNoteAttachment(values) {
1572
1520
  bigints.push(BigInt(values[i]));
1573
1521
  }
1574
1522
  if (bigints.length === 0) {
1575
- return new import_miden_sdk10.NoteAttachment();
1523
+ return emptyAttachment();
1576
1524
  }
1577
- const scheme = import_miden_sdk10.NoteAttachmentScheme.none();
1525
+ const scheme = NoteAttachmentScheme.none();
1578
1526
  if (bigints.length <= 4) {
1579
1527
  while (bigints.length < 4) {
1580
1528
  bigints.push(0n);
1581
1529
  }
1582
- const word = new import_miden_sdk10.Word(BigUint64Array.from(bigints));
1583
- return import_miden_sdk10.NoteAttachment.newWord(scheme, word);
1530
+ const word = new Word(BigUint64Array.from(bigints));
1531
+ return NoteAttachment.fromWord(scheme, word);
1584
1532
  }
1585
1533
  while (bigints.length % 4 !== 0) {
1586
1534
  bigints.push(0n);
1587
1535
  }
1588
1536
  const words = [];
1589
1537
  for (let i = 0; i < bigints.length; i += 4) {
1590
- words.push(new import_miden_sdk10.Word(BigUint64Array.from(bigints.slice(i, i + 4))));
1538
+ words.push(new Word(BigUint64Array.from(bigints.slice(i, i + 4))));
1591
1539
  }
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);
1540
+ return NoteAttachment.fromWords(scheme, words);
1541
+ }
1542
+ function emptyAttachment() {
1543
+ const scheme = NoteAttachmentScheme.none();
1544
+ const word = new Word(BigUint64Array.from([0n, 0n, 0n, 0n]));
1545
+ return NoteAttachment.fromWord(scheme, word);
1599
1546
  }
1600
1547
 
1601
1548
  // src/hooks/useNoteStream.ts
@@ -1605,32 +1552,32 @@ function useNoteStream(options = {}) {
1605
1552
  const noteFirstSeen = useNoteFirstSeenStore();
1606
1553
  const { lastSyncTime } = useSyncStateStore();
1607
1554
  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);
1555
+ const [isLoading, setIsLoading] = useState5(false);
1556
+ const [error, setError] = useState5(null);
1557
+ const handledIdsRef = useRef3(/* @__PURE__ */ new Set());
1558
+ const [handledVersion, setHandledVersion] = useState5(0);
1612
1559
  const status = options.status ?? "committed";
1613
1560
  const sender = options.sender ?? null;
1614
1561
  const since = options.since;
1615
- const amountFilterRef = (0, import_react8.useRef)(options.amountFilter);
1562
+ const amountFilterRef = useRef3(options.amountFilter);
1616
1563
  amountFilterRef.current = options.amountFilter;
1617
- const excludeIdsKey = (0, import_react8.useMemo)(() => {
1564
+ const excludeIdsKey = useMemo6(() => {
1618
1565
  if (!options.excludeIds) return "";
1619
1566
  if (options.excludeIds instanceof Set)
1620
1567
  return Array.from(options.excludeIds).sort().join("\0");
1621
1568
  return [...options.excludeIds].sort().join("\0");
1622
1569
  }, [options.excludeIds]);
1623
- const excludeIdSet = (0, import_react8.useMemo)(() => {
1570
+ const excludeIdSet = useMemo6(() => {
1624
1571
  if (!excludeIdsKey) return null;
1625
1572
  return new Set(excludeIdsKey.split("\0"));
1626
1573
  }, [excludeIdsKey]);
1627
- const refetch = (0, import_react8.useCallback)(async () => {
1574
+ const refetch = useCallback6(async () => {
1628
1575
  if (!client || !isReady) return;
1629
1576
  setIsLoading(true);
1630
1577
  setError(null);
1631
1578
  try {
1632
1579
  const filterType = getNoteFilterType(status);
1633
- const filter = new import_miden_sdk11.NoteFilter(filterType);
1580
+ const filter = new NoteFilter2(filterType);
1634
1581
  const fetched = await client.getInputNotes(filter);
1635
1582
  setNotesIfChanged(fetched);
1636
1583
  } catch (err) {
@@ -1639,12 +1586,12 @@ function useNoteStream(options = {}) {
1639
1586
  setIsLoading(false);
1640
1587
  }
1641
1588
  }, [client, isReady, status, setNotesIfChanged]);
1642
- (0, import_react8.useEffect)(() => {
1589
+ useEffect7(() => {
1643
1590
  if (isReady) {
1644
1591
  refetch();
1645
1592
  }
1646
1593
  }, [isReady, lastSyncTime, refetch]);
1647
- const streamedNotes = (0, import_react8.useMemo)(() => {
1594
+ const streamedNotes = useMemo6(() => {
1648
1595
  void handledVersion;
1649
1596
  const result = [];
1650
1597
  let normalizedSender = null;
@@ -1669,15 +1616,15 @@ function useNoteStream(options = {}) {
1669
1616
  result.sort((a, b) => a.firstSeenAt - b.firstSeenAt);
1670
1617
  return result;
1671
1618
  }, [allNotes, noteFirstSeen, excludeIdSet, sender, since, handledVersion]);
1672
- const latest = (0, import_react8.useMemo)(
1619
+ const latest = useMemo6(
1673
1620
  () => streamedNotes.length > 0 ? streamedNotes[streamedNotes.length - 1] : null,
1674
1621
  [streamedNotes]
1675
1622
  );
1676
- const markHandled = (0, import_react8.useCallback)((noteId) => {
1623
+ const markHandled = useCallback6((noteId) => {
1677
1624
  handledIdsRef.current = new Set(handledIdsRef.current).add(noteId);
1678
1625
  setHandledVersion((v) => v + 1);
1679
1626
  }, []);
1680
- const markAllHandled = (0, import_react8.useCallback)(() => {
1627
+ const markAllHandled = useCallback6(() => {
1681
1628
  const newSet = new Set(handledIdsRef.current);
1682
1629
  for (const note of streamedNotes) {
1683
1630
  newSet.add(note.id);
@@ -1685,7 +1632,7 @@ function useNoteStream(options = {}) {
1685
1632
  handledIdsRef.current = newSet;
1686
1633
  setHandledVersion((v) => v + 1);
1687
1634
  }, [streamedNotes]);
1688
- const snapshot = (0, import_react8.useCallback)(() => {
1635
+ const snapshot = useCallback6(() => {
1689
1636
  const ids = /* @__PURE__ */ new Set();
1690
1637
  for (const note of streamedNotes) {
1691
1638
  ids.add(note.id);
@@ -1704,7 +1651,9 @@ function useNoteStream(options = {}) {
1704
1651
  }
1705
1652
  function buildStreamedNote(record, noteFirstSeen) {
1706
1653
  try {
1707
- const id = record.id().toString();
1654
+ const rawId = record.id();
1655
+ if (!rawId) return null;
1656
+ const id = rawId.toString();
1708
1657
  const metadata = record.metadata?.();
1709
1658
  const senderHex = metadata?.sender?.()?.toString?.();
1710
1659
  const sender = senderHex ? toBech32AccountId(senderHex) : "";
@@ -1741,20 +1690,20 @@ function buildStreamedNote(record, noteFirstSeen) {
1741
1690
  }
1742
1691
 
1743
1692
  // src/hooks/useTransactionHistory.ts
1744
- var import_react9 = require("react");
1745
- var import_miden_sdk12 = require("@miden-sdk/miden-sdk");
1693
+ import { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
1694
+ import { TransactionFilter as TransactionFilter2 } from "@miden-sdk/miden-sdk/mt";
1746
1695
  function useTransactionHistory(options = {}) {
1747
1696
  const { client, isReady } = useMiden();
1748
1697
  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)(() => {
1698
+ const [records, setRecords] = useState6([]);
1699
+ const [isLoading, setIsLoading] = useState6(false);
1700
+ const [error, setError] = useState6(null);
1701
+ const rawIds = useMemo7(() => {
1753
1702
  if (options.id) return [options.id];
1754
1703
  if (options.ids && options.ids.length > 0) return options.ids;
1755
1704
  return null;
1756
1705
  }, [options.id, options.ids]);
1757
- const idsHex = (0, import_react9.useMemo)(() => {
1706
+ const idsHex = useMemo7(() => {
1758
1707
  if (!rawIds) return null;
1759
1708
  return rawIds.map(
1760
1709
  (id) => normalizeHex2(typeof id === "string" ? id : id.toHex())
@@ -1762,7 +1711,7 @@ function useTransactionHistory(options = {}) {
1762
1711
  }, [rawIds]);
1763
1712
  const filter = options.filter;
1764
1713
  const refreshOnSync = options.refreshOnSync !== false;
1765
- const refetch = (0, import_react9.useCallback)(async () => {
1714
+ const refetch = useCallback7(async () => {
1766
1715
  if (!client || !isReady) return;
1767
1716
  setIsLoading(true);
1768
1717
  setError(null);
@@ -1783,19 +1732,19 @@ function useTransactionHistory(options = {}) {
1783
1732
  setIsLoading(false);
1784
1733
  }
1785
1734
  }, [client, isReady, filter, rawIds, idsHex]);
1786
- (0, import_react9.useEffect)(() => {
1735
+ useEffect8(() => {
1787
1736
  if (!isReady) return;
1788
1737
  refetch();
1789
1738
  }, [isReady, refetch]);
1790
- (0, import_react9.useEffect)(() => {
1739
+ useEffect8(() => {
1791
1740
  if (!isReady || !refreshOnSync || !lastSyncTime) return;
1792
1741
  refetch();
1793
1742
  }, [isReady, lastSyncTime, refreshOnSync, refetch]);
1794
- const record = (0, import_react9.useMemo)(() => {
1743
+ const record = useMemo7(() => {
1795
1744
  if (!idsHex || idsHex.length !== 1) return null;
1796
1745
  return records.find((item) => normalizeHex2(item.id().toHex()) === idsHex[0]) ?? null;
1797
1746
  }, [records, idsHex]);
1798
- const status = (0, import_react9.useMemo)(() => {
1747
+ const status = useMemo7(() => {
1799
1748
  if (!record) return null;
1800
1749
  const current = record.transactionStatus();
1801
1750
  if (current.isCommitted()) return "committed";
@@ -1817,14 +1766,14 @@ function buildFilter(filter, ids, idsHex) {
1817
1766
  return { filter };
1818
1767
  }
1819
1768
  if (!ids || ids.length === 0) {
1820
- return { filter: import_miden_sdk12.TransactionFilter.all() };
1769
+ return { filter: TransactionFilter2.all() };
1821
1770
  }
1822
1771
  const allTransactionIds = ids.every((id) => typeof id !== "string");
1823
1772
  if (allTransactionIds) {
1824
- return { filter: import_miden_sdk12.TransactionFilter.ids(ids) };
1773
+ return { filter: TransactionFilter2.ids(ids) };
1825
1774
  }
1826
1775
  return {
1827
- filter: import_miden_sdk12.TransactionFilter.all(),
1776
+ filter: TransactionFilter2.all(),
1828
1777
  localFilterHexes: idsHex ?? []
1829
1778
  };
1830
1779
  }
@@ -1835,11 +1784,11 @@ function normalizeHex2(value) {
1835
1784
  }
1836
1785
 
1837
1786
  // src/hooks/useSyncState.ts
1838
- var import_react10 = require("react");
1787
+ import { useCallback as useCallback8 } from "react";
1839
1788
  function useSyncState() {
1840
1789
  const { sync: triggerSync } = useMiden();
1841
1790
  const syncState = useSyncStateStore();
1842
- const sync = (0, import_react10.useCallback)(async () => {
1791
+ const sync = useCallback8(async () => {
1843
1792
  await triggerSync();
1844
1793
  }, [triggerSync]);
1845
1794
  return {
@@ -1849,8 +1798,8 @@ function useSyncState() {
1849
1798
  }
1850
1799
 
1851
1800
  // src/hooks/useCreateWallet.ts
1852
- var import_react11 = require("react");
1853
- var import_miden_sdk13 = require("@miden-sdk/miden-sdk");
1801
+ import { useCallback as useCallback9, useState as useState7 } from "react";
1802
+ import { AccountStorageMode } from "@miden-sdk/miden-sdk/mt";
1854
1803
 
1855
1804
  // src/utils/runExclusive.ts
1856
1805
  var runExclusiveDirect = async (fn) => fn();
@@ -1860,10 +1809,10 @@ function useCreateWallet() {
1860
1809
  const { client, isReady, runExclusive } = useMiden();
1861
1810
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
1862
1811
  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)(
1812
+ const [wallet, setWallet] = useState7(null);
1813
+ const [isCreating, setIsCreating] = useState7(false);
1814
+ const [error, setError] = useState7(null);
1815
+ const createWallet = useCallback9(
1867
1816
  async (options = {}) => {
1868
1817
  if (!client || !isReady) {
1869
1818
  throw new Error("Miden client is not ready");
@@ -1900,7 +1849,7 @@ function useCreateWallet() {
1900
1849
  },
1901
1850
  [client, isReady, runExclusive, setAccounts]
1902
1851
  );
1903
- const reset = (0, import_react11.useCallback)(() => {
1852
+ const reset = useCallback9(() => {
1904
1853
  setWallet(null);
1905
1854
  setIsCreating(false);
1906
1855
  setError(null);
@@ -1916,27 +1865,25 @@ function useCreateWallet() {
1916
1865
  function getStorageMode(mode) {
1917
1866
  switch (mode) {
1918
1867
  case "private":
1919
- return import_miden_sdk13.AccountStorageMode.private();
1868
+ return AccountStorageMode.private();
1920
1869
  case "public":
1921
- return import_miden_sdk13.AccountStorageMode.public();
1922
- case "network":
1923
- return import_miden_sdk13.AccountStorageMode.network();
1870
+ return AccountStorageMode.public();
1924
1871
  default:
1925
- return import_miden_sdk13.AccountStorageMode.private();
1872
+ return AccountStorageMode.private();
1926
1873
  }
1927
1874
  }
1928
1875
 
1929
1876
  // src/hooks/useCreateFaucet.ts
1930
- var import_react12 = require("react");
1931
- var import_miden_sdk14 = require("@miden-sdk/miden-sdk");
1877
+ import { useCallback as useCallback10, useState as useState8 } from "react";
1878
+ import { AccountStorageMode as AccountStorageMode2 } from "@miden-sdk/miden-sdk/mt";
1932
1879
  function useCreateFaucet() {
1933
1880
  const { client, isReady, runExclusive } = useMiden();
1934
1881
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
1935
1882
  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)(
1883
+ const [faucet, setFaucet] = useState8(null);
1884
+ const [isCreating, setIsCreating] = useState8(false);
1885
+ const [error, setError] = useState8(null);
1886
+ const createFaucet = useCallback10(
1940
1887
  async (options) => {
1941
1888
  if (!client || !isReady) {
1942
1889
  throw new Error("Miden client is not ready");
@@ -1954,6 +1901,7 @@ function useCreateFaucet() {
1954
1901
  storageMode,
1955
1902
  false,
1956
1903
  // nonFungible - currently only fungible faucets supported
1904
+ options.tokenName ?? options.tokenSymbol,
1957
1905
  options.tokenSymbol,
1958
1906
  decimals,
1959
1907
  BigInt(options.maxSupply),
@@ -1975,7 +1923,7 @@ function useCreateFaucet() {
1975
1923
  },
1976
1924
  [client, isReady, runExclusive, setAccounts]
1977
1925
  );
1978
- const reset = (0, import_react12.useCallback)(() => {
1926
+ const reset = useCallback10(() => {
1979
1927
  setFaucet(null);
1980
1928
  setIsCreating(false);
1981
1929
  setError(null);
@@ -1991,19 +1939,17 @@ function useCreateFaucet() {
1991
1939
  function getStorageMode2(mode) {
1992
1940
  switch (mode) {
1993
1941
  case "private":
1994
- return import_miden_sdk14.AccountStorageMode.private();
1942
+ return AccountStorageMode2.private();
1995
1943
  case "public":
1996
- return import_miden_sdk14.AccountStorageMode.public();
1997
- case "network":
1998
- return import_miden_sdk14.AccountStorageMode.network();
1944
+ return AccountStorageMode2.public();
1999
1945
  default:
2000
- return import_miden_sdk14.AccountStorageMode.private();
1946
+ return AccountStorageMode2.private();
2001
1947
  }
2002
1948
  }
2003
1949
 
2004
1950
  // src/hooks/useImportAccount.ts
2005
- var import_react13 = require("react");
2006
- var import_miden_sdk15 = require("@miden-sdk/miden-sdk");
1951
+ import { useCallback as useCallback11, useState as useState9 } from "react";
1952
+ import { AccountFile } from "@miden-sdk/miden-sdk/mt";
2007
1953
 
2008
1954
  // src/utils/errors.ts
2009
1955
  var MidenError = class extends Error {
@@ -2061,10 +2007,10 @@ function wrapWasmError(e) {
2061
2007
  function useImportAccount() {
2062
2008
  const { client, isReady, signerConnected } = useMiden();
2063
2009
  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)(
2010
+ const [account, setAccount] = useState9(null);
2011
+ const [isImporting, setIsImporting] = useState9(false);
2012
+ const [error, setError] = useState9(null);
2013
+ const importAccount = useCallback11(
2068
2014
  async (options) => {
2069
2015
  if (!client || !isReady) {
2070
2016
  throw new Error("Miden client is not ready");
@@ -2160,7 +2106,7 @@ function useImportAccount() {
2160
2106
  },
2161
2107
  [client, isReady, setAccounts, signerConnected]
2162
2108
  );
2163
- const reset = (0, import_react13.useCallback)(() => {
2109
+ const reset = useCallback11(() => {
2164
2110
  setAccount(null);
2165
2111
  setIsImporting(false);
2166
2112
  setError(null);
@@ -2175,10 +2121,10 @@ function useImportAccount() {
2175
2121
  }
2176
2122
  async function resolveAccountFile(file) {
2177
2123
  if (file instanceof Uint8Array) {
2178
- return import_miden_sdk15.AccountFile.deserialize(file);
2124
+ return AccountFile.deserialize(file);
2179
2125
  }
2180
2126
  if (file instanceof ArrayBuffer) {
2181
- return import_miden_sdk15.AccountFile.deserialize(new Uint8Array(file));
2127
+ return AccountFile.deserialize(new Uint8Array(file));
2182
2128
  }
2183
2129
  return file;
2184
2130
  }
@@ -2207,17 +2153,24 @@ function bytesEqual(left, right) {
2207
2153
  }
2208
2154
 
2209
2155
  // src/hooks/useSend.ts
2210
- var import_react14 = require("react");
2211
- var import_miden_sdk16 = require("@miden-sdk/miden-sdk");
2156
+ import { useCallback as useCallback12, useRef as useRef4, useState as useState10 } from "react";
2157
+ import {
2158
+ FungibleAsset,
2159
+ Note,
2160
+ NoteAssets,
2161
+ NoteType as NoteType2,
2162
+ NoteArray,
2163
+ TransactionRequestBuilder
2164
+ } from "@miden-sdk/miden-sdk/mt";
2212
2165
  function useSend() {
2213
2166
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2214
2167
  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)(
2168
+ const isBusyRef = useRef4(false);
2169
+ const [result, setResult] = useState10(null);
2170
+ const [isLoading, setIsLoading] = useState10(false);
2171
+ const [stage, setStage] = useState10("idle");
2172
+ const [error, setError] = useState10(null);
2173
+ const send = useCallback12(
2221
2174
  async (options) => {
2222
2175
  if (!client || !isReady) {
2223
2176
  throw new Error("Miden client is not ready");
@@ -2275,26 +2228,26 @@ function useSend() {
2275
2228
  const fromId = parseAccountId(options.from);
2276
2229
  const toId = parseAccountId(options.to);
2277
2230
  const assetObj = parseAccountId(assetId);
2278
- const assets = new import_miden_sdk16.NoteAssets([
2279
- new import_miden_sdk16.FungibleAsset(assetObj, BigInt(amount))
2231
+ const assets = new NoteAssets([
2232
+ new FungibleAsset(assetObj, BigInt(amount))
2280
2233
  ]);
2281
- const p2idNote = import_miden_sdk16.Note.createP2IDNote(
2234
+ const p2idNote = Note.createP2IDNote(
2282
2235
  fromId,
2283
2236
  toId,
2284
2237
  assets,
2285
2238
  noteType,
2286
- new import_miden_sdk16.NoteAttachment()
2239
+ emptyAttachment()
2287
2240
  );
2288
- const ownOutputs = new import_miden_sdk16.NoteArray();
2241
+ const ownOutputs = new NoteArray();
2289
2242
  ownOutputs.push(p2idNote);
2290
- const txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
2243
+ const txRequest = new TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
2291
2244
  const execFromId = parseAccountId(options.from);
2292
2245
  const txId = prover ? await client.submitNewTransactionWithProver(
2293
2246
  execFromId,
2294
2247
  txRequest,
2295
2248
  prover
2296
2249
  ) : await client.submitNewTransaction(execFromId, txRequest);
2297
- return { txId: txId.toString(), note: p2idNote };
2250
+ return { txId: txId.toHex(), note: p2idNote };
2298
2251
  });
2299
2252
  setStage("complete");
2300
2253
  setResult(returnResult);
@@ -2308,17 +2261,17 @@ function useSend() {
2308
2261
  let txRequest;
2309
2262
  if (hasAttachment) {
2310
2263
  const attachment = createNoteAttachment(options.attachment);
2311
- const assets = new import_miden_sdk16.NoteAssets([
2312
- new import_miden_sdk16.FungibleAsset(assetIdObj, amount)
2264
+ const assets = new NoteAssets([
2265
+ new FungibleAsset(assetIdObj, amount)
2313
2266
  ]);
2314
- const note = import_miden_sdk16.Note.createP2IDNote(
2267
+ const note = Note.createP2IDNote(
2315
2268
  fromAccountId,
2316
2269
  toAccountId,
2317
2270
  assets,
2318
2271
  noteType,
2319
2272
  attachment
2320
2273
  );
2321
- txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk16.NoteArray([note])).build();
2274
+ txRequest = new TransactionRequestBuilder().withOwnOutputNotes(new NoteArray([note])).build();
2322
2275
  } else {
2323
2276
  txRequest = await client.newSendTransactionRequest(
2324
2277
  fromAccountId,
@@ -2346,15 +2299,14 @@ function useSend() {
2346
2299
  () => client.submitProvenTransaction(provenTransaction, txResult)
2347
2300
  );
2348
2301
  const txIdHex = txResult.id().toHex();
2349
- const txIdString = txResult.id().toString();
2350
2302
  let fullNote = null;
2351
- if (noteType === import_miden_sdk16.NoteType.Private) {
2303
+ if (noteType === NoteType2.Private) {
2352
2304
  fullNote = extractFullNote(txResult);
2353
2305
  }
2354
2306
  await runExclusiveSafe(
2355
2307
  () => client.applyTransaction(txResult, submissionHeight)
2356
2308
  );
2357
- if (noteType === import_miden_sdk16.NoteType.Private) {
2309
+ if (noteType === NoteType2.Private) {
2358
2310
  if (!fullNote) {
2359
2311
  throw new Error("Missing full note for private send");
2360
2312
  }
@@ -2370,7 +2322,7 @@ function useSend() {
2370
2322
  );
2371
2323
  }
2372
2324
  const sendResult = {
2373
- txId: txIdString,
2325
+ txId: txIdHex,
2374
2326
  note: null
2375
2327
  };
2376
2328
  setStage("complete");
@@ -2389,7 +2341,7 @@ function useSend() {
2389
2341
  },
2390
2342
  [client, isReady, prover, runExclusive, sync]
2391
2343
  );
2392
- const reset = (0, import_react14.useCallback)(() => {
2344
+ const reset = useCallback12(() => {
2393
2345
  setResult(null);
2394
2346
  setIsLoading(false);
2395
2347
  setStage("idle");
@@ -2416,16 +2368,23 @@ function extractFullNote(txResult) {
2416
2368
  }
2417
2369
 
2418
2370
  // src/hooks/useMultiSend.ts
2419
- var import_react15 = require("react");
2420
- var import_miden_sdk17 = require("@miden-sdk/miden-sdk");
2371
+ import { useCallback as useCallback13, useRef as useRef5, useState as useState11 } from "react";
2372
+ import {
2373
+ FungibleAsset as FungibleAsset2,
2374
+ Note as Note2,
2375
+ NoteAssets as NoteAssets2,
2376
+ NoteType as NoteType3,
2377
+ NoteArray as NoteArray2,
2378
+ TransactionRequestBuilder as TransactionRequestBuilder2
2379
+ } from "@miden-sdk/miden-sdk/mt";
2421
2380
  function useMultiSend() {
2422
2381
  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)(
2382
+ const isBusyRef = useRef5(false);
2383
+ const [result, setResult] = useState11(null);
2384
+ const [isLoading, setIsLoading] = useState11(false);
2385
+ const [stage, setStage] = useState11("idle");
2386
+ const [error, setError] = useState11(null);
2387
+ const sendMany = useCallback13(
2429
2388
  async (options) => {
2430
2389
  if (!client || !isReady) {
2431
2390
  throw new Error("Miden client is not ready");
@@ -2454,12 +2413,12 @@ function useMultiSend() {
2454
2413
  const iterSenderId = parseAccountId(options.from);
2455
2414
  const iterAssetId = parseAccountId(options.assetId);
2456
2415
  const receiverId = parseAccountId(to);
2457
- const assets = new import_miden_sdk17.NoteAssets([
2458
- new import_miden_sdk17.FungibleAsset(iterAssetId, BigInt(amount))
2416
+ const assets = new NoteAssets2([
2417
+ new FungibleAsset2(iterAssetId, BigInt(amount))
2459
2418
  ]);
2460
2419
  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(
2420
+ const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : emptyAttachment();
2421
+ const note = Note2.createP2IDNote(
2463
2422
  iterSenderId,
2464
2423
  receiverId,
2465
2424
  assets,
@@ -2474,7 +2433,11 @@ function useMultiSend() {
2474
2433
  };
2475
2434
  }
2476
2435
  );
2477
- const txRequest = new import_miden_sdk17.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk17.NoteArray(outputs.map((o) => o.note))).build();
2436
+ const ownOutputs = new NoteArray2();
2437
+ for (const o of outputs) {
2438
+ ownOutputs.push(o.note);
2439
+ }
2440
+ const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(ownOutputs).build();
2478
2441
  const txSenderId = parseAccountId(options.from);
2479
2442
  const txResult = await client.executeTransaction(txSenderId, txRequest);
2480
2443
  setStage("proving");
@@ -2491,9 +2454,8 @@ function useMultiSend() {
2491
2454
  txResult
2492
2455
  );
2493
2456
  const txIdHex = txResult.id().toHex();
2494
- const txIdString = txResult.id().toString();
2495
2457
  await client.applyTransaction(txResult, submissionHeight);
2496
- const hasPrivate = outputs.some((o) => o.noteType === import_miden_sdk17.NoteType.Private);
2458
+ const hasPrivate = outputs.some((o) => o.noteType === NoteType3.Private);
2497
2459
  if (hasPrivate) {
2498
2460
  await waitForTransactionCommit(
2499
2461
  client,
@@ -2501,7 +2463,7 @@ function useMultiSend() {
2501
2463
  txIdHex
2502
2464
  );
2503
2465
  for (const output of outputs) {
2504
- if (output.noteType === import_miden_sdk17.NoteType.Private) {
2466
+ if (output.noteType === NoteType3.Private) {
2505
2467
  await client.sendPrivateNote(
2506
2468
  output.note,
2507
2469
  output.recipientAddress
@@ -2509,7 +2471,7 @@ function useMultiSend() {
2509
2471
  }
2510
2472
  }
2511
2473
  }
2512
- const txSummary = { transactionId: txIdString };
2474
+ const txSummary = { transactionId: txIdHex };
2513
2475
  setStage("complete");
2514
2476
  setResult(txSummary);
2515
2477
  await sync();
@@ -2526,7 +2488,7 @@ function useMultiSend() {
2526
2488
  },
2527
2489
  [client, isReady, prover, signerConnected, sync]
2528
2490
  );
2529
- const reset = (0, import_react15.useCallback)(() => {
2491
+ const reset = useCallback13(() => {
2530
2492
  setResult(null);
2531
2493
  setIsLoading(false);
2532
2494
  setStage("idle");
@@ -2543,11 +2505,11 @@ function useMultiSend() {
2543
2505
  }
2544
2506
 
2545
2507
  // src/hooks/useWaitForCommit.ts
2546
- var import_react16 = require("react");
2547
- var import_miden_sdk18 = require("@miden-sdk/miden-sdk");
2508
+ import { useCallback as useCallback14 } from "react";
2509
+ import { TransactionFilter as TransactionFilter3 } from "@miden-sdk/miden-sdk/mt";
2548
2510
  function useWaitForCommit() {
2549
2511
  const { client, isReady } = useMiden();
2550
- const waitForCommit = (0, import_react16.useCallback)(
2512
+ const waitForCommit = useCallback14(
2551
2513
  async (txId, options) => {
2552
2514
  if (!client || !isReady) {
2553
2515
  throw new Error("Miden client is not ready");
@@ -2561,7 +2523,7 @@ function useWaitForCommit() {
2561
2523
  while (Date.now() < deadline) {
2562
2524
  await client.syncState();
2563
2525
  const records = await client.getTransactions(
2564
- typeof txId === "string" ? import_miden_sdk18.TransactionFilter.all() : import_miden_sdk18.TransactionFilter.ids([txId])
2526
+ typeof txId === "string" ? TransactionFilter3.all() : TransactionFilter3.ids([txId])
2565
2527
  );
2566
2528
  const record = records.find(
2567
2529
  (item) => normalizeHex3(item.id().toHex()) === targetHex
@@ -2590,11 +2552,11 @@ function normalizeHex3(value) {
2590
2552
  }
2591
2553
 
2592
2554
  // src/hooks/useWaitForNotes.ts
2593
- var import_react17 = require("react");
2555
+ import { useCallback as useCallback15 } from "react";
2594
2556
  function useWaitForNotes() {
2595
2557
  const { client, isReady, runExclusive } = useMiden();
2596
2558
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2597
- const waitForConsumableNotes = (0, import_react17.useCallback)(
2559
+ const waitForConsumableNotes = useCallback15(
2598
2560
  async (options) => {
2599
2561
  if (!client || !isReady) {
2600
2562
  throw new Error("Miden client is not ready");
@@ -2625,15 +2587,15 @@ function useWaitForNotes() {
2625
2587
  }
2626
2588
 
2627
2589
  // src/hooks/useMint.ts
2628
- var import_react18 = require("react");
2590
+ import { useCallback as useCallback16, useState as useState12 } from "react";
2629
2591
  function useMint() {
2630
2592
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2631
2593
  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)(
2594
+ const [result, setResult] = useState12(null);
2595
+ const [isLoading, setIsLoading] = useState12(false);
2596
+ const [stage, setStage] = useState12("idle");
2597
+ const [error, setError] = useState12(null);
2598
+ const mint = useCallback16(
2637
2599
  async (options) => {
2638
2600
  if (!client || !isReady) {
2639
2601
  throw new Error("Miden client is not ready");
@@ -2658,7 +2620,7 @@ function useMint() {
2658
2620
  txRequest,
2659
2621
  prover
2660
2622
  ) : await client.submitNewTransaction(faucetIdObj, txRequest);
2661
- return { transactionId: txId.toString() };
2623
+ return { transactionId: txId.toHex() };
2662
2624
  });
2663
2625
  setStage("complete");
2664
2626
  setResult(txResult);
@@ -2675,7 +2637,7 @@ function useMint() {
2675
2637
  },
2676
2638
  [client, isReady, prover, runExclusive, sync]
2677
2639
  );
2678
- const reset = (0, import_react18.useCallback)(() => {
2640
+ const reset = useCallback16(() => {
2679
2641
  setResult(null);
2680
2642
  setIsLoading(false);
2681
2643
  setStage("idle");
@@ -2692,16 +2654,16 @@ function useMint() {
2692
2654
  }
2693
2655
 
2694
2656
  // src/hooks/useConsume.ts
2695
- var import_react19 = require("react");
2696
- var import_miden_sdk19 = require("@miden-sdk/miden-sdk");
2657
+ import { useCallback as useCallback17, useState as useState13 } from "react";
2658
+ import { NoteFilter as NoteFilter3, NoteFilterTypes as NoteFilterTypes2, NoteId } from "@miden-sdk/miden-sdk/mt";
2697
2659
  function useConsume() {
2698
2660
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2699
2661
  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)(
2662
+ const [result, setResult] = useState13(null);
2663
+ const [isLoading, setIsLoading] = useState13(false);
2664
+ const [stage, setStage] = useState13("idle");
2665
+ const [error, setError] = useState13(null);
2666
+ const consume = useCallback17(
2705
2667
  async (options) => {
2706
2668
  if (!client || !isReady) {
2707
2669
  throw new Error("Miden client is not ready");
@@ -2723,7 +2685,7 @@ function useConsume() {
2723
2685
  const item = options.notes[i];
2724
2686
  if (typeof item === "string") {
2725
2687
  lookupIndices.push(i);
2726
- lookupIds.push(import_miden_sdk19.NoteId.fromHex(item));
2688
+ lookupIds.push(NoteId.fromHex(item));
2727
2689
  } else if (item !== null && typeof item === "object" && typeof item.toNote === "function") {
2728
2690
  resolved[i] = item.toNote();
2729
2691
  } else if (item !== null && typeof item === "object" && typeof item.id === "function") {
@@ -2734,16 +2696,25 @@ function useConsume() {
2734
2696
  }
2735
2697
  }
2736
2698
  if (lookupIds.length > 0) {
2737
- const filter = new import_miden_sdk19.NoteFilter(import_miden_sdk19.NoteFilterTypes.List, lookupIds);
2699
+ const lookupIdStrings = lookupIds.map((id) => id.toString());
2700
+ const filter = new NoteFilter3(NoteFilterTypes2.List, lookupIds);
2738
2701
  const noteRecords = await client.getInputNotes(filter);
2739
- if (noteRecords.length !== lookupIds.length) {
2702
+ if (noteRecords.length !== lookupIdStrings.length) {
2740
2703
  throw new Error("Some notes could not be found for provided IDs");
2741
2704
  }
2742
2705
  const recordById = new Map(
2743
- noteRecords.map((r) => [r.id().toString(), r])
2706
+ noteRecords.map((r) => {
2707
+ const id = r.id();
2708
+ if (!id) {
2709
+ throw new Error(
2710
+ "getInputNotes returned a record without a note id"
2711
+ );
2712
+ }
2713
+ return [id.toString(), r];
2714
+ })
2744
2715
  );
2745
2716
  for (let j = 0; j < lookupIndices.length; j++) {
2746
- const record = recordById.get(lookupIds[j].toString());
2717
+ const record = recordById.get(lookupIdStrings[j]);
2747
2718
  if (!record) {
2748
2719
  throw new Error(
2749
2720
  "Some notes could not be found for provided IDs"
@@ -2759,7 +2730,7 @@ function useConsume() {
2759
2730
  txRequest,
2760
2731
  prover
2761
2732
  ) : await client.submitNewTransaction(accountIdObj, txRequest);
2762
- return { transactionId: txId.toString() };
2733
+ return { transactionId: txId.toHex() };
2763
2734
  });
2764
2735
  setStage("complete");
2765
2736
  setResult(txResult);
@@ -2776,7 +2747,7 @@ function useConsume() {
2776
2747
  },
2777
2748
  [client, isReady, prover, runExclusive, sync]
2778
2749
  );
2779
- const reset = (0, import_react19.useCallback)(() => {
2750
+ const reset = useCallback17(() => {
2780
2751
  setResult(null);
2781
2752
  setIsLoading(false);
2782
2753
  setStage("idle");
@@ -2793,15 +2764,15 @@ function useConsume() {
2793
2764
  }
2794
2765
 
2795
2766
  // src/hooks/useSwap.ts
2796
- var import_react20 = require("react");
2767
+ import { useCallback as useCallback18, useState as useState14 } from "react";
2797
2768
  function useSwap() {
2798
2769
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2799
2770
  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)(
2771
+ const [result, setResult] = useState14(null);
2772
+ const [isLoading, setIsLoading] = useState14(false);
2773
+ const [stage, setStage] = useState14("idle");
2774
+ const [error, setError] = useState14(null);
2775
+ const swap = useCallback18(
2805
2776
  async (options) => {
2806
2777
  if (!client || !isReady) {
2807
2778
  throw new Error("Miden client is not ready");
@@ -2833,7 +2804,7 @@ function useSwap() {
2833
2804
  txRequest,
2834
2805
  prover
2835
2806
  ) : await client.submitNewTransaction(accountIdObj, txRequest);
2836
- return { transactionId: txId.toString() };
2807
+ return { transactionId: txId.toHex() };
2837
2808
  });
2838
2809
  setStage("complete");
2839
2810
  setResult(txResult);
@@ -2850,7 +2821,7 @@ function useSwap() {
2850
2821
  },
2851
2822
  [client, isReady, prover, runExclusive, sync]
2852
2823
  );
2853
- const reset = (0, import_react20.useCallback)(() => {
2824
+ const reset = useCallback18(() => {
2854
2825
  setResult(null);
2855
2826
  setIsLoading(false);
2856
2827
  setStage("idle");
@@ -2866,17 +2837,237 @@ function useSwap() {
2866
2837
  };
2867
2838
  }
2868
2839
 
2840
+ // src/hooks/usePswapCreate.ts
2841
+ import { useCallback as useCallback19, useState as useState15 } from "react";
2842
+ function usePswapCreate() {
2843
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
2844
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2845
+ const [result, setResult] = useState15(null);
2846
+ const [isLoading, setIsLoading] = useState15(false);
2847
+ const [stage, setStage] = useState15("idle");
2848
+ const [error, setError] = useState15(null);
2849
+ const pswapCreate = useCallback19(
2850
+ async (options) => {
2851
+ if (!client || !isReady) {
2852
+ throw new Error("Miden client is not ready");
2853
+ }
2854
+ const offeredAmount = BigInt(options.offeredAmount);
2855
+ const requestedAmount = BigInt(options.requestedAmount);
2856
+ if (offeredAmount <= 0n) {
2857
+ throw new Error("offeredAmount must be greater than 0");
2858
+ }
2859
+ if (requestedAmount <= 0n) {
2860
+ throw new Error("requestedAmount must be greater than 0");
2861
+ }
2862
+ setIsLoading(true);
2863
+ setStage("executing");
2864
+ setError(null);
2865
+ try {
2866
+ const noteType = getNoteType(options.noteType ?? DEFAULTS.NOTE_TYPE);
2867
+ const paybackNoteType = getNoteType(
2868
+ options.paybackNoteType ?? DEFAULTS.NOTE_TYPE
2869
+ );
2870
+ const accountIdObj = parseAccountId(options.accountId);
2871
+ const offeredFaucetIdObj = parseAccountId(options.offeredFaucetId);
2872
+ const requestedFaucetIdObj = parseAccountId(options.requestedFaucetId);
2873
+ setStage("proving");
2874
+ const txResult = await runExclusiveSafe(async () => {
2875
+ const txRequest = await client.newPswapCreateTransactionRequest(
2876
+ accountIdObj,
2877
+ offeredFaucetIdObj,
2878
+ offeredAmount,
2879
+ requestedFaucetIdObj,
2880
+ requestedAmount,
2881
+ noteType,
2882
+ paybackNoteType
2883
+ );
2884
+ const txId = prover ? await client.submitNewTransactionWithProver(
2885
+ accountIdObj,
2886
+ txRequest,
2887
+ prover
2888
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
2889
+ return { transactionId: txId.toHex() };
2890
+ });
2891
+ setStage("complete");
2892
+ setResult(txResult);
2893
+ await sync();
2894
+ return txResult;
2895
+ } catch (err) {
2896
+ const error2 = err instanceof Error ? err : new Error(String(err));
2897
+ setError(error2);
2898
+ setStage("idle");
2899
+ throw error2;
2900
+ } finally {
2901
+ setIsLoading(false);
2902
+ }
2903
+ },
2904
+ [client, isReady, prover, runExclusive, sync]
2905
+ );
2906
+ const reset = useCallback19(() => {
2907
+ setResult(null);
2908
+ setIsLoading(false);
2909
+ setStage("idle");
2910
+ setError(null);
2911
+ }, []);
2912
+ return {
2913
+ pswapCreate,
2914
+ result,
2915
+ isLoading,
2916
+ stage,
2917
+ error,
2918
+ reset
2919
+ };
2920
+ }
2921
+
2922
+ // src/hooks/usePswapConsume.ts
2923
+ import { useCallback as useCallback20, useState as useState16 } from "react";
2924
+ function usePswapConsume() {
2925
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
2926
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2927
+ const [result, setResult] = useState16(null);
2928
+ const [isLoading, setIsLoading] = useState16(false);
2929
+ const [stage, setStage] = useState16("idle");
2930
+ const [error, setError] = useState16(null);
2931
+ const pswapConsume = useCallback20(
2932
+ async (options) => {
2933
+ if (!client || !isReady) {
2934
+ throw new Error("Miden client is not ready");
2935
+ }
2936
+ const fillAmount = BigInt(options.fillAmount);
2937
+ const noteFillAmount = BigInt(options.noteFillAmount ?? 0);
2938
+ if (fillAmount <= 0n) {
2939
+ throw new Error("fillAmount must be greater than 0");
2940
+ }
2941
+ if (noteFillAmount < 0n) {
2942
+ throw new Error("noteFillAmount must not be negative");
2943
+ }
2944
+ setIsLoading(true);
2945
+ setStage("executing");
2946
+ setError(null);
2947
+ try {
2948
+ const accountIdObj = parseAccountId(options.accountId);
2949
+ setStage("proving");
2950
+ const txResult = await runExclusiveSafe(async () => {
2951
+ const note = await resolveNoteInput(options.note, client);
2952
+ const txRequest = await client.newPswapConsumeTransactionRequest(
2953
+ note,
2954
+ accountIdObj,
2955
+ fillAmount,
2956
+ noteFillAmount
2957
+ );
2958
+ const txId = prover ? await client.submitNewTransactionWithProver(
2959
+ accountIdObj,
2960
+ txRequest,
2961
+ prover
2962
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
2963
+ return { transactionId: txId.toHex() };
2964
+ });
2965
+ setStage("complete");
2966
+ setResult(txResult);
2967
+ await sync();
2968
+ return txResult;
2969
+ } catch (err) {
2970
+ const error2 = err instanceof Error ? err : new Error(String(err));
2971
+ setError(error2);
2972
+ setStage("idle");
2973
+ throw error2;
2974
+ } finally {
2975
+ setIsLoading(false);
2976
+ }
2977
+ },
2978
+ [client, isReady, prover, runExclusive, sync]
2979
+ );
2980
+ const reset = useCallback20(() => {
2981
+ setResult(null);
2982
+ setIsLoading(false);
2983
+ setStage("idle");
2984
+ setError(null);
2985
+ }, []);
2986
+ return {
2987
+ pswapConsume,
2988
+ result,
2989
+ isLoading,
2990
+ stage,
2991
+ error,
2992
+ reset
2993
+ };
2994
+ }
2995
+
2996
+ // src/hooks/usePswapCancel.ts
2997
+ import { useCallback as useCallback21, useState as useState17 } from "react";
2998
+ function usePswapCancel() {
2999
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
3000
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3001
+ const [result, setResult] = useState17(null);
3002
+ const [isLoading, setIsLoading] = useState17(false);
3003
+ const [stage, setStage] = useState17("idle");
3004
+ const [error, setError] = useState17(null);
3005
+ const pswapCancel = useCallback21(
3006
+ async (options) => {
3007
+ if (!client || !isReady) {
3008
+ throw new Error("Miden client is not ready");
3009
+ }
3010
+ setIsLoading(true);
3011
+ setStage("executing");
3012
+ setError(null);
3013
+ try {
3014
+ const accountIdObj = parseAccountId(options.accountId);
3015
+ setStage("proving");
3016
+ const txResult = await runExclusiveSafe(async () => {
3017
+ const note = await resolveNoteInput(options.note, client);
3018
+ const txRequest = await client.newPswapCancelTransactionRequest(
3019
+ note,
3020
+ accountIdObj
3021
+ );
3022
+ const txId = prover ? await client.submitNewTransactionWithProver(
3023
+ accountIdObj,
3024
+ txRequest,
3025
+ prover
3026
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
3027
+ return { transactionId: txId.toHex() };
3028
+ });
3029
+ setStage("complete");
3030
+ setResult(txResult);
3031
+ await sync();
3032
+ return txResult;
3033
+ } catch (err) {
3034
+ const error2 = err instanceof Error ? err : new Error(String(err));
3035
+ setError(error2);
3036
+ setStage("idle");
3037
+ throw error2;
3038
+ } finally {
3039
+ setIsLoading(false);
3040
+ }
3041
+ },
3042
+ [client, isReady, prover, runExclusive, sync]
3043
+ );
3044
+ const reset = useCallback21(() => {
3045
+ setResult(null);
3046
+ setIsLoading(false);
3047
+ setStage("idle");
3048
+ setError(null);
3049
+ }, []);
3050
+ return {
3051
+ pswapCancel,
3052
+ result,
3053
+ isLoading,
3054
+ stage,
3055
+ error,
3056
+ reset
3057
+ };
3058
+ }
3059
+
2869
3060
  // src/hooks/useTransaction.ts
2870
- var import_react21 = require("react");
3061
+ import { useCallback as useCallback22, useRef as useRef6, useState as useState18 } from "react";
2871
3062
 
2872
3063
  // src/utils/transactions.ts
2873
- var import_miden_sdk20 = require("@miden-sdk/miden-sdk");
3064
+ import { NoteType as NoteType4, TransactionFilter as TransactionFilter4 } from "@miden-sdk/miden-sdk/mt";
2874
3065
  async function waitForTransactionCommit2(client, runExclusiveSafe, txId, maxWaitMs = 1e4, delayMs = 1e3) {
2875
3066
  let waited = 0;
2876
3067
  while (waited < maxWaitMs) {
2877
3068
  await runExclusiveSafe(() => client.syncState());
2878
3069
  const [record] = await runExclusiveSafe(
2879
- () => client.getTransactions(import_miden_sdk20.TransactionFilter.ids([txId]))
3070
+ () => client.getTransactions(TransactionFilter4.ids([txId]))
2880
3071
  );
2881
3072
  if (record) {
2882
3073
  const status = record.transactionStatus();
@@ -2898,7 +3089,7 @@ function extractFullNotes(txResult) {
2898
3089
  const notes = executedTx?.outputNotes?.().notes?.() ?? [];
2899
3090
  const result = [];
2900
3091
  for (const note of notes) {
2901
- if (note.noteType?.() === import_miden_sdk20.NoteType.Private) {
3092
+ if (note.noteType?.() === NoteType4.Private) {
2902
3093
  const full = note.intoFull?.();
2903
3094
  if (full) result.push(full);
2904
3095
  }
@@ -2913,12 +3104,12 @@ function extractFullNotes(txResult) {
2913
3104
  function useTransaction() {
2914
3105
  const { client, isReady, sync, runExclusive } = useMiden();
2915
3106
  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)(
3107
+ const isBusyRef = useRef6(false);
3108
+ const [result, setResult] = useState18(null);
3109
+ const [isLoading, setIsLoading] = useState18(false);
3110
+ const [stage, setStage] = useState18("idle");
3111
+ const [error, setError] = useState18(null);
3112
+ const execute = useCallback22(
2922
3113
  async (options) => {
2923
3114
  if (!client || !isReady) {
2924
3115
  throw new Error("Miden client is not ready");
@@ -2968,7 +3159,7 @@ function useTransaction() {
2968
3159
  );
2969
3160
  }
2970
3161
  }
2971
- const txSummary = { transactionId: txId.toString() };
3162
+ const txSummary = { transactionId: txId.toHex() };
2972
3163
  setStage("complete");
2973
3164
  setResult(txSummary);
2974
3165
  await sync();
@@ -2985,7 +3176,7 @@ function useTransaction() {
2985
3176
  },
2986
3177
  [client, isReady, runExclusive, sync]
2987
3178
  );
2988
- const reset = (0, import_react21.useCallback)(() => {
3179
+ const reset = useCallback22(() => {
2989
3180
  setResult(null);
2990
3181
  setIsLoading(false);
2991
3182
  setStage("idle");
@@ -3008,19 +3199,24 @@ async function resolveRequest(request, client) {
3008
3199
  }
3009
3200
 
3010
3201
  // src/hooks/useExecuteProgram.ts
3011
- var import_react22 = require("react");
3012
- var import_miden_sdk21 = require("@miden-sdk/miden-sdk");
3202
+ import { useCallback as useCallback23, useRef as useRef7, useState as useState19 } from "react";
3203
+ import {
3204
+ AdviceInputs,
3205
+ ForeignAccount,
3206
+ ForeignAccountArray,
3207
+ AccountStorageRequirements
3208
+ } from "@miden-sdk/miden-sdk/mt";
3013
3209
  function isForeignAccountWrapper(fa) {
3014
3210
  return fa !== null && typeof fa === "object" && "id" in fa && typeof fa.id !== "function";
3015
3211
  }
3016
3212
  function useExecuteProgram() {
3017
3213
  const { client, isReady, sync, runExclusive } = useMiden();
3018
3214
  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)(
3215
+ const isBusyRef = useRef7(false);
3216
+ const [result, setResult] = useState19(null);
3217
+ const [isLoading, setIsLoading] = useState19(false);
3218
+ const [error, setError] = useState19(null);
3219
+ const execute = useCallback23(
3024
3220
  async (options) => {
3025
3221
  if (!client || !isReady) {
3026
3222
  throw new Error("Miden client is not ready");
@@ -3040,18 +3236,18 @@ function useExecuteProgram() {
3040
3236
  }
3041
3237
  const programResult = await runExclusiveSafe(async () => {
3042
3238
  const accountIdObj = parseAccountId(options.accountId);
3043
- const adviceInputs = options.adviceInputs ?? new import_miden_sdk21.AdviceInputs();
3239
+ const adviceInputs = options.adviceInputs ?? new AdviceInputs();
3044
3240
  let foreignAccountsArray;
3045
3241
  if (options.foreignAccounts?.length) {
3046
3242
  const accounts = options.foreignAccounts.map((fa) => {
3047
3243
  const wrapper = isForeignAccountWrapper(fa);
3048
3244
  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);
3245
+ const storage = wrapper && fa.storage ? fa.storage : new AccountStorageRequirements();
3246
+ return ForeignAccount.public(id, storage);
3051
3247
  });
3052
- foreignAccountsArray = new import_miden_sdk21.ForeignAccountArray(accounts);
3248
+ foreignAccountsArray = new ForeignAccountArray(accounts);
3053
3249
  } else {
3054
- foreignAccountsArray = new import_miden_sdk21.ForeignAccountArray();
3250
+ foreignAccountsArray = new ForeignAccountArray();
3055
3251
  }
3056
3252
  const feltArray = await client.executeProgram(
3057
3253
  accountIdObj,
@@ -3079,7 +3275,7 @@ function useExecuteProgram() {
3079
3275
  },
3080
3276
  [client, isReady, runExclusive, sync]
3081
3277
  );
3082
- const reset = (0, import_react22.useCallback)(() => {
3278
+ const reset = useCallback23(() => {
3083
3279
  setResult(null);
3084
3280
  setIsLoading(false);
3085
3281
  setError(null);
@@ -3094,29 +3290,29 @@ function useExecuteProgram() {
3094
3290
  }
3095
3291
 
3096
3292
  // src/hooks/useCompile.ts
3097
- var import_react23 = require("react");
3098
- var import_miden_sdk22 = require("@miden-sdk/miden-sdk");
3293
+ import { useCallback as useCallback24, useMemo as useMemo8 } from "react";
3294
+ import { CompilerResource, getWasmOrThrow } from "@miden-sdk/miden-sdk/mt";
3099
3295
  function useCompile() {
3100
3296
  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,
3297
+ const resource = useMemo8(
3298
+ () => client && isReady ? new CompilerResource(client, getWasmOrThrow) : null,
3103
3299
  [client, isReady]
3104
3300
  );
3105
- const requireResource = (0, import_react23.useCallback)(() => {
3301
+ const requireResource = useCallback24(() => {
3106
3302
  if (!resource) {
3107
3303
  throw new Error("Miden client is not ready");
3108
3304
  }
3109
3305
  return resource;
3110
3306
  }, [resource]);
3111
- const component = (0, import_react23.useCallback)(
3307
+ const component = useCallback24(
3112
3308
  async (options) => requireResource().component(options),
3113
3309
  [requireResource]
3114
3310
  );
3115
- const txScript = (0, import_react23.useCallback)(
3311
+ const txScript = useCallback24(
3116
3312
  async (options) => requireResource().txScript(options),
3117
3313
  [requireResource]
3118
3314
  );
3119
- const noteScript = (0, import_react23.useCallback)(
3315
+ const noteScript = useCallback24(
3120
3316
  async (options) => requireResource().noteScript(options),
3121
3317
  [requireResource]
3122
3318
  );
@@ -3124,25 +3320,25 @@ function useCompile() {
3124
3320
  }
3125
3321
 
3126
3322
  // src/hooks/useSessionAccount.ts
3127
- var import_react24 = require("react");
3128
- var import_miden_sdk23 = require("@miden-sdk/miden-sdk");
3323
+ import { useCallback as useCallback25, useEffect as useEffect9, useRef as useRef8, useState as useState20 } from "react";
3324
+ import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk/mt";
3129
3325
  function useSessionAccount(options) {
3130
3326
  const { client, isReady, sync } = useMiden();
3131
3327
  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);
3328
+ const [sessionAccountId, setSessionAccountId] = useState20(null);
3329
+ const [step, setStep] = useState20("idle");
3330
+ const [error, setError] = useState20(null);
3331
+ const cancelledRef = useRef8(false);
3332
+ const isBusyRef = useRef8(false);
3137
3333
  const storagePrefix = options.storagePrefix ?? "miden-session";
3138
3334
  const pollIntervalMs = options.pollIntervalMs ?? 3e3;
3139
3335
  const maxWaitMs = options.maxWaitMs ?? 6e4;
3140
3336
  const storageMode = options.walletOptions?.storageMode ?? "public";
3141
3337
  const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
3142
3338
  const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
3143
- const fundRef = (0, import_react24.useRef)(options.fund);
3339
+ const fundRef = useRef8(options.fund);
3144
3340
  fundRef.current = options.fund;
3145
- (0, import_react24.useEffect)(() => {
3341
+ useEffect9(() => {
3146
3342
  try {
3147
3343
  const stored = localStorage.getItem(`${storagePrefix}:accountId`);
3148
3344
  const storedReady = localStorage.getItem(`${storagePrefix}:ready`);
@@ -3159,7 +3355,7 @@ function useSessionAccount(options) {
3159
3355
  localStorage.removeItem(`${storagePrefix}:ready`);
3160
3356
  }
3161
3357
  }, [storagePrefix]);
3162
- const initialize = (0, import_react24.useCallback)(async () => {
3358
+ const initialize = useCallback25(async () => {
3163
3359
  if (!client || !isReady) {
3164
3360
  throw new Error("Miden client is not ready");
3165
3361
  }
@@ -3228,7 +3424,7 @@ function useSessionAccount(options) {
3228
3424
  maxWaitMs,
3229
3425
  setAccounts
3230
3426
  ]);
3231
- const reset = (0, import_react24.useCallback)(() => {
3427
+ const reset = useCallback25(() => {
3232
3428
  cancelledRef.current = true;
3233
3429
  isBusyRef.current = false;
3234
3430
  setSessionAccountId(null);
@@ -3249,11 +3445,11 @@ function useSessionAccount(options) {
3249
3445
  function getStorageMode3(mode) {
3250
3446
  switch (mode) {
3251
3447
  case "private":
3252
- return import_miden_sdk23.AccountStorageMode.private();
3448
+ return AccountStorageMode3.private();
3253
3449
  case "public":
3254
- return import_miden_sdk23.AccountStorageMode.public();
3450
+ return AccountStorageMode3.public();
3255
3451
  default:
3256
- return import_miden_sdk23.AccountStorageMode.public();
3452
+ return AccountStorageMode3.public();
3257
3453
  }
3258
3454
  }
3259
3455
  async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
@@ -3277,13 +3473,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
3277
3473
  }
3278
3474
 
3279
3475
  // src/hooks/useExportStore.ts
3280
- var import_react25 = require("react");
3281
- var import_miden_sdk24 = require("@miden-sdk/miden-sdk");
3476
+ import { useCallback as useCallback26, useState as useState21 } from "react";
3477
+ import { exportStore as sdkExportStore } from "@miden-sdk/miden-sdk/mt";
3282
3478
  function useExportStore() {
3283
3479
  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 () => {
3480
+ const [isExporting, setIsExporting] = useState21(false);
3481
+ const [error, setError] = useState21(null);
3482
+ const exportStore = useCallback26(async () => {
3287
3483
  if (!client || !isReady) {
3288
3484
  throw new Error("Miden client is not ready");
3289
3485
  }
@@ -3291,7 +3487,7 @@ function useExportStore() {
3291
3487
  setError(null);
3292
3488
  try {
3293
3489
  const storeName = await client.storeIdentifier();
3294
- const snapshot = await runExclusive(() => (0, import_miden_sdk24.exportStore)(storeName));
3490
+ const snapshot = await runExclusive(() => sdkExportStore(storeName));
3295
3491
  return snapshot;
3296
3492
  } catch (err) {
3297
3493
  const error2 = err instanceof Error ? err : new Error(String(err));
@@ -3301,7 +3497,7 @@ function useExportStore() {
3301
3497
  setIsExporting(false);
3302
3498
  }
3303
3499
  }, [client, isReady, runExclusive]);
3304
- const reset = (0, import_react25.useCallback)(() => {
3500
+ const reset = useCallback26(() => {
3305
3501
  setIsExporting(false);
3306
3502
  setError(null);
3307
3503
  }, []);
@@ -3314,13 +3510,13 @@ function useExportStore() {
3314
3510
  }
3315
3511
 
3316
3512
  // src/hooks/useImportStore.ts
3317
- var import_react26 = require("react");
3318
- var import_miden_sdk25 = require("@miden-sdk/miden-sdk");
3513
+ import { useCallback as useCallback27, useState as useState22 } from "react";
3514
+ import { importStore as sdkImportStore } from "@miden-sdk/miden-sdk/mt";
3319
3515
  function useImportStore() {
3320
3516
  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)(
3517
+ const [isImporting, setIsImporting] = useState22(false);
3518
+ const [error, setError] = useState22(null);
3519
+ const importStore = useCallback27(
3324
3520
  async (storeDump, storeName, options) => {
3325
3521
  if (!client || !isReady) {
3326
3522
  throw new Error("Miden client is not ready");
@@ -3328,7 +3524,7 @@ function useImportStore() {
3328
3524
  setIsImporting(true);
3329
3525
  setError(null);
3330
3526
  try {
3331
- await runExclusive(() => (0, import_miden_sdk25.importStore)(storeName, storeDump));
3527
+ await runExclusive(() => sdkImportStore(storeName, storeDump));
3332
3528
  if (!options?.skipSync) {
3333
3529
  await sync();
3334
3530
  }
@@ -3342,7 +3538,7 @@ function useImportStore() {
3342
3538
  },
3343
3539
  [client, isReady, runExclusive, sync]
3344
3540
  );
3345
- const reset = (0, import_react26.useCallback)(() => {
3541
+ const reset = useCallback27(() => {
3346
3542
  setIsImporting(false);
3347
3543
  setError(null);
3348
3544
  }, []);
@@ -3355,13 +3551,13 @@ function useImportStore() {
3355
3551
  }
3356
3552
 
3357
3553
  // src/hooks/useImportNote.ts
3358
- var import_react27 = require("react");
3359
- var import_miden_sdk26 = require("@miden-sdk/miden-sdk");
3554
+ import { useCallback as useCallback28, useState as useState23 } from "react";
3555
+ import { NoteFile } from "@miden-sdk/miden-sdk/mt";
3360
3556
  function useImportNote() {
3361
3557
  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)(
3558
+ const [isImporting, setIsImporting] = useState23(false);
3559
+ const [error, setError] = useState23(null);
3560
+ const importNote = useCallback28(
3365
3561
  async (noteBytes) => {
3366
3562
  if (!client || !isReady) {
3367
3563
  throw new Error("Miden client is not ready");
@@ -3369,7 +3565,7 @@ function useImportNote() {
3369
3565
  setIsImporting(true);
3370
3566
  setError(null);
3371
3567
  try {
3372
- const noteFile = import_miden_sdk26.NoteFile.deserialize(noteBytes);
3568
+ const noteFile = NoteFile.deserialize(noteBytes);
3373
3569
  const noteId = await runExclusive(
3374
3570
  () => client.importNoteFile(noteFile)
3375
3571
  );
@@ -3385,7 +3581,7 @@ function useImportNote() {
3385
3581
  },
3386
3582
  [client, isReady, runExclusive, sync]
3387
3583
  );
3388
- const reset = (0, import_react27.useCallback)(() => {
3584
+ const reset = useCallback28(() => {
3389
3585
  setIsImporting(false);
3390
3586
  setError(null);
3391
3587
  }, []);
@@ -3398,13 +3594,13 @@ function useImportNote() {
3398
3594
  }
3399
3595
 
3400
3596
  // src/hooks/useExportNote.ts
3401
- var import_react28 = require("react");
3402
- var import_miden_sdk27 = require("@miden-sdk/miden-sdk");
3597
+ import { useCallback as useCallback29, useState as useState24 } from "react";
3598
+ import { NoteExportFormat } from "@miden-sdk/miden-sdk/mt";
3403
3599
  function useExportNote() {
3404
3600
  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)(
3601
+ const [isExporting, setIsExporting] = useState24(false);
3602
+ const [error, setError] = useState24(null);
3603
+ const exportNote = useCallback29(
3408
3604
  async (noteId) => {
3409
3605
  if (!client || !isReady) {
3410
3606
  throw new Error("Miden client is not ready");
@@ -3413,7 +3609,7 @@ function useExportNote() {
3413
3609
  setError(null);
3414
3610
  try {
3415
3611
  const noteFile = await runExclusive(
3416
- () => client.exportNoteFile(noteId, import_miden_sdk27.NoteExportFormat.Full)
3612
+ () => client.exportNoteFile(noteId, NoteExportFormat.Full)
3417
3613
  );
3418
3614
  return noteFile.serialize();
3419
3615
  } catch (err) {
@@ -3426,7 +3622,7 @@ function useExportNote() {
3426
3622
  },
3427
3623
  [client, isReady, runExclusive]
3428
3624
  );
3429
- const reset = (0, import_react28.useCallback)(() => {
3625
+ const reset = useCallback29(() => {
3430
3626
  setIsExporting(false);
3431
3627
  setError(null);
3432
3628
  }, []);
@@ -3439,12 +3635,12 @@ function useExportNote() {
3439
3635
  }
3440
3636
 
3441
3637
  // src/hooks/useSyncControl.ts
3442
- var import_react29 = require("react");
3638
+ import { useCallback as useCallback30 } from "react";
3443
3639
  function useSyncControl() {
3444
3640
  const isPaused = useMidenStore((state) => state.syncPaused);
3445
3641
  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]);
3642
+ const pauseSync = useCallback30(() => setSyncPaused(true), [setSyncPaused]);
3643
+ const resumeSync = useCallback30(() => setSyncPaused(false), [setSyncPaused]);
3448
3644
  return {
3449
3645
  pauseSync,
3450
3646
  resumeSync,
@@ -3601,8 +3797,7 @@ function createMidenStorage(prefix) {
3601
3797
 
3602
3798
  // src/index.ts
3603
3799
  installAccountBech32();
3604
- // Annotate the CommonJS export names for ESM import in node:
3605
- 0 && (module.exports = {
3800
+ export {
3606
3801
  AuthScheme,
3607
3802
  DEFAULTS,
3608
3803
  MidenError,
@@ -3647,6 +3842,9 @@ installAccountBech32();
3647
3842
  useMultiSigner,
3648
3843
  useNoteStream,
3649
3844
  useNotes,
3845
+ usePswapCancel,
3846
+ usePswapConsume,
3847
+ usePswapCreate,
3650
3848
  useSend,
3651
3849
  useSessionAccount,
3652
3850
  useSigner,
@@ -3659,4 +3857,4 @@ installAccountBech32();
3659
3857
  useWaitForNotes,
3660
3858
  waitForWalletDetection,
3661
3859
  wrapWasmError
3662
- });
3860
+ };