@miden-sdk/react 0.15.1 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lazy.mjs CHANGED
@@ -1775,8 +1775,142 @@ function useSyncState() {
1775
1775
  };
1776
1776
  }
1777
1777
 
1778
+ // src/hooks/usePswapLineages.ts
1779
+ import { useCallback as useCallback9, useEffect as useEffect9, useRef as useRef4, useState as useState7 } from "react";
1780
+ function usePswapLineages() {
1781
+ const { client, isReady } = useMiden();
1782
+ const { lastSyncTime } = useSyncStateStore();
1783
+ const [lineages, setLineages] = useState7([]);
1784
+ const [isLoading, setIsLoading] = useState7(false);
1785
+ const [error, setError] = useState7(null);
1786
+ const fetchGenRef = useRef4(0);
1787
+ const refetch = useCallback9(async () => {
1788
+ if (!client || !isReady) return;
1789
+ const gen = ++fetchGenRef.current;
1790
+ setIsLoading(true);
1791
+ setError(null);
1792
+ try {
1793
+ const fetched = await client.getPswapLineages();
1794
+ if (gen === fetchGenRef.current) setLineages(fetched);
1795
+ } catch (err) {
1796
+ if (gen === fetchGenRef.current)
1797
+ setError(err instanceof Error ? err : new Error(String(err)));
1798
+ } finally {
1799
+ if (gen === fetchGenRef.current) setIsLoading(false);
1800
+ }
1801
+ }, [client, isReady]);
1802
+ useEffect9(() => {
1803
+ if (!isReady) return;
1804
+ refetch();
1805
+ return () => {
1806
+ fetchGenRef.current++;
1807
+ };
1808
+ }, [isReady, refetch]);
1809
+ useEffect9(() => {
1810
+ if (!isReady || !lastSyncTime) return;
1811
+ refetch();
1812
+ return () => {
1813
+ fetchGenRef.current++;
1814
+ };
1815
+ }, [isReady, lastSyncTime, refetch]);
1816
+ return { lineages, isLoading, error, refetch };
1817
+ }
1818
+
1819
+ // src/hooks/usePswapLineagesFor.ts
1820
+ import { useCallback as useCallback10, useEffect as useEffect10, useMemo as useMemo8, useRef as useRef5, useState as useState8 } from "react";
1821
+ import { AccountId as AccountId3 } from "@miden-sdk/miden-sdk/lazy";
1822
+ function usePswapLineagesFor(account) {
1823
+ const { client, isReady } = useMiden();
1824
+ const { lastSyncTime } = useSyncStateStore();
1825
+ const [lineages, setLineages] = useState8([]);
1826
+ const [isLoading, setIsLoading] = useState8(false);
1827
+ const [error, setError] = useState8(null);
1828
+ const fetchGenRef = useRef5(0);
1829
+ const accountKey = useMemo8(() => {
1830
+ if (account == null) return null;
1831
+ try {
1832
+ return parseAccountId(account).toString();
1833
+ } catch {
1834
+ return null;
1835
+ }
1836
+ }, [account]);
1837
+ const refetch = useCallback10(async () => {
1838
+ if (!client || !isReady || accountKey == null) return;
1839
+ const gen = ++fetchGenRef.current;
1840
+ setIsLoading(true);
1841
+ setError(null);
1842
+ try {
1843
+ const accountIdObj = AccountId3.fromHex(accountKey);
1844
+ const fetched = await client.getPswapLineagesFor(accountIdObj);
1845
+ if (gen === fetchGenRef.current) setLineages(fetched);
1846
+ } catch (err) {
1847
+ if (gen === fetchGenRef.current)
1848
+ setError(err instanceof Error ? err : new Error(String(err)));
1849
+ } finally {
1850
+ if (gen === fetchGenRef.current) setIsLoading(false);
1851
+ }
1852
+ }, [client, isReady, accountKey]);
1853
+ useEffect10(() => {
1854
+ if (!isReady) return;
1855
+ refetch();
1856
+ return () => {
1857
+ fetchGenRef.current++;
1858
+ };
1859
+ }, [isReady, refetch]);
1860
+ useEffect10(() => {
1861
+ if (!isReady || !lastSyncTime) return;
1862
+ refetch();
1863
+ return () => {
1864
+ fetchGenRef.current++;
1865
+ };
1866
+ }, [isReady, lastSyncTime, refetch]);
1867
+ return { lineages, isLoading, error, refetch };
1868
+ }
1869
+
1870
+ // src/hooks/usePswapLineage.ts
1871
+ import { useCallback as useCallback11, useEffect as useEffect11, useRef as useRef6, useState as useState9 } from "react";
1872
+ function usePswapLineage(orderId) {
1873
+ const { client, isReady } = useMiden();
1874
+ const { lastSyncTime } = useSyncStateStore();
1875
+ const [lineage, setLineage] = useState9(null);
1876
+ const [isLoading, setIsLoading] = useState9(false);
1877
+ const [error, setError] = useState9(null);
1878
+ const orderIdStr = orderId == null ? null : String(orderId);
1879
+ const fetchGenRef = useRef6(0);
1880
+ const refetch = useCallback11(async () => {
1881
+ if (!client || !isReady || orderIdStr == null) return;
1882
+ const gen = ++fetchGenRef.current;
1883
+ setIsLoading(true);
1884
+ setError(null);
1885
+ try {
1886
+ const fetched = await client.getPswapLineage(orderIdStr);
1887
+ if (gen === fetchGenRef.current) setLineage(fetched ?? null);
1888
+ } catch (err) {
1889
+ if (gen === fetchGenRef.current)
1890
+ setError(err instanceof Error ? err : new Error(String(err)));
1891
+ } finally {
1892
+ if (gen === fetchGenRef.current) setIsLoading(false);
1893
+ }
1894
+ }, [client, isReady, orderIdStr]);
1895
+ useEffect11(() => {
1896
+ if (!isReady) return;
1897
+ refetch();
1898
+ return () => {
1899
+ fetchGenRef.current++;
1900
+ };
1901
+ }, [isReady, refetch]);
1902
+ useEffect11(() => {
1903
+ if (!isReady || !lastSyncTime) return;
1904
+ refetch();
1905
+ return () => {
1906
+ fetchGenRef.current++;
1907
+ };
1908
+ }, [isReady, lastSyncTime, refetch]);
1909
+ return { lineage, isLoading, error, refetch };
1910
+ }
1911
+
1778
1912
  // src/hooks/useCreateWallet.ts
1779
- import { useCallback as useCallback9, useState as useState7 } from "react";
1913
+ import { useCallback as useCallback12, useState as useState10 } from "react";
1780
1914
  import { AccountStorageMode } from "@miden-sdk/miden-sdk/lazy";
1781
1915
 
1782
1916
  // src/utils/runExclusive.ts
@@ -1787,10 +1921,10 @@ function useCreateWallet() {
1787
1921
  const { client, isReady, runExclusive } = useMiden();
1788
1922
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
1789
1923
  const setAccounts = useMidenStore((state) => state.setAccounts);
1790
- const [wallet, setWallet] = useState7(null);
1791
- const [isCreating, setIsCreating] = useState7(false);
1792
- const [error, setError] = useState7(null);
1793
- const createWallet = useCallback9(
1924
+ const [wallet, setWallet] = useState10(null);
1925
+ const [isCreating, setIsCreating] = useState10(false);
1926
+ const [error, setError] = useState10(null);
1927
+ const createWallet = useCallback12(
1794
1928
  async (options = {}) => {
1795
1929
  if (!client || !isReady) {
1796
1930
  throw new Error("Miden client is not ready");
@@ -1825,7 +1959,7 @@ function useCreateWallet() {
1825
1959
  },
1826
1960
  [client, isReady, runExclusive, setAccounts]
1827
1961
  );
1828
- const reset = useCallback9(() => {
1962
+ const reset = useCallback12(() => {
1829
1963
  setWallet(null);
1830
1964
  setIsCreating(false);
1831
1965
  setError(null);
@@ -1850,16 +1984,16 @@ function getStorageMode(mode) {
1850
1984
  }
1851
1985
 
1852
1986
  // src/hooks/useCreateFaucet.ts
1853
- import { useCallback as useCallback10, useState as useState8 } from "react";
1987
+ import { useCallback as useCallback13, useState as useState11 } from "react";
1854
1988
  import { AccountStorageMode as AccountStorageMode2 } from "@miden-sdk/miden-sdk/lazy";
1855
1989
  function useCreateFaucet() {
1856
1990
  const { client, isReady, runExclusive } = useMiden();
1857
1991
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
1858
1992
  const setAccounts = useMidenStore((state) => state.setAccounts);
1859
- const [faucet, setFaucet] = useState8(null);
1860
- const [isCreating, setIsCreating] = useState8(false);
1861
- const [error, setError] = useState8(null);
1862
- const createFaucet = useCallback10(
1993
+ const [faucet, setFaucet] = useState11(null);
1994
+ const [isCreating, setIsCreating] = useState11(false);
1995
+ const [error, setError] = useState11(null);
1996
+ const createFaucet = useCallback13(
1863
1997
  async (options) => {
1864
1998
  if (!client || !isReady) {
1865
1999
  throw new Error("Miden client is not ready");
@@ -1899,7 +2033,7 @@ function useCreateFaucet() {
1899
2033
  },
1900
2034
  [client, isReady, runExclusive, setAccounts]
1901
2035
  );
1902
- const reset = useCallback10(() => {
2036
+ const reset = useCallback13(() => {
1903
2037
  setFaucet(null);
1904
2038
  setIsCreating(false);
1905
2039
  setError(null);
@@ -1924,7 +2058,7 @@ function getStorageMode2(mode) {
1924
2058
  }
1925
2059
 
1926
2060
  // src/hooks/useImportAccount.ts
1927
- import { useCallback as useCallback11, useState as useState9 } from "react";
2061
+ import { useCallback as useCallback14, useState as useState12 } from "react";
1928
2062
  import { AccountFile } from "@miden-sdk/miden-sdk/lazy";
1929
2063
 
1930
2064
  // src/utils/errors.ts
@@ -1983,10 +2117,10 @@ function wrapWasmError(e) {
1983
2117
  function useImportAccount() {
1984
2118
  const { client, isReady, signerConnected } = useMiden();
1985
2119
  const setAccounts = useMidenStore((state) => state.setAccounts);
1986
- const [account, setAccount] = useState9(null);
1987
- const [isImporting, setIsImporting] = useState9(false);
1988
- const [error, setError] = useState9(null);
1989
- const importAccount = useCallback11(
2120
+ const [account, setAccount] = useState12(null);
2121
+ const [isImporting, setIsImporting] = useState12(false);
2122
+ const [error, setError] = useState12(null);
2123
+ const importAccount = useCallback14(
1990
2124
  async (options) => {
1991
2125
  if (!client || !isReady) {
1992
2126
  throw new Error("Miden client is not ready");
@@ -2080,7 +2214,7 @@ function useImportAccount() {
2080
2214
  },
2081
2215
  [client, isReady, setAccounts, signerConnected]
2082
2216
  );
2083
- const reset = useCallback11(() => {
2217
+ const reset = useCallback14(() => {
2084
2218
  setAccount(null);
2085
2219
  setIsImporting(false);
2086
2220
  setError(null);
@@ -2127,7 +2261,7 @@ function bytesEqual(left, right) {
2127
2261
  }
2128
2262
 
2129
2263
  // src/hooks/useSend.ts
2130
- import { useCallback as useCallback12, useRef as useRef4, useState as useState10 } from "react";
2264
+ import { useCallback as useCallback15, useRef as useRef7, useState as useState13 } from "react";
2131
2265
  import {
2132
2266
  FungibleAsset,
2133
2267
  Note,
@@ -2139,12 +2273,12 @@ import {
2139
2273
  function useSend() {
2140
2274
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2141
2275
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2142
- const isBusyRef = useRef4(false);
2143
- const [result, setResult] = useState10(null);
2144
- const [isLoading, setIsLoading] = useState10(false);
2145
- const [stage, setStage] = useState10("idle");
2146
- const [error, setError] = useState10(null);
2147
- const send = useCallback12(
2276
+ const isBusyRef = useRef7(false);
2277
+ const [result, setResult] = useState13(null);
2278
+ const [isLoading, setIsLoading] = useState13(false);
2279
+ const [stage, setStage] = useState13("idle");
2280
+ const [error, setError] = useState13(null);
2281
+ const send = useCallback15(
2148
2282
  async (options) => {
2149
2283
  if (!client || !isReady) {
2150
2284
  throw new Error("Miden client is not ready");
@@ -2315,7 +2449,7 @@ function useSend() {
2315
2449
  },
2316
2450
  [client, isReady, prover, runExclusive, sync]
2317
2451
  );
2318
- const reset = useCallback12(() => {
2452
+ const reset = useCallback15(() => {
2319
2453
  setResult(null);
2320
2454
  setIsLoading(false);
2321
2455
  setStage("idle");
@@ -2342,7 +2476,7 @@ function extractFullNote(txResult) {
2342
2476
  }
2343
2477
 
2344
2478
  // src/hooks/useMultiSend.ts
2345
- import { useCallback as useCallback13, useRef as useRef5, useState as useState11 } from "react";
2479
+ import { useCallback as useCallback16, useRef as useRef8, useState as useState14 } from "react";
2346
2480
  import {
2347
2481
  FungibleAsset as FungibleAsset2,
2348
2482
  Note as Note2,
@@ -2353,12 +2487,12 @@ import {
2353
2487
  } from "@miden-sdk/miden-sdk/lazy";
2354
2488
  function useMultiSend() {
2355
2489
  const { client, isReady, sync, prover, signerConnected } = useMiden();
2356
- const isBusyRef = useRef5(false);
2357
- const [result, setResult] = useState11(null);
2358
- const [isLoading, setIsLoading] = useState11(false);
2359
- const [stage, setStage] = useState11("idle");
2360
- const [error, setError] = useState11(null);
2361
- const sendMany = useCallback13(
2490
+ const isBusyRef = useRef8(false);
2491
+ const [result, setResult] = useState14(null);
2492
+ const [isLoading, setIsLoading] = useState14(false);
2493
+ const [stage, setStage] = useState14("idle");
2494
+ const [error, setError] = useState14(null);
2495
+ const sendMany = useCallback16(
2362
2496
  async (options) => {
2363
2497
  if (!client || !isReady) {
2364
2498
  throw new Error("Miden client is not ready");
@@ -2462,7 +2596,7 @@ function useMultiSend() {
2462
2596
  },
2463
2597
  [client, isReady, prover, signerConnected, sync]
2464
2598
  );
2465
- const reset = useCallback13(() => {
2599
+ const reset = useCallback16(() => {
2466
2600
  setResult(null);
2467
2601
  setIsLoading(false);
2468
2602
  setStage("idle");
@@ -2479,11 +2613,11 @@ function useMultiSend() {
2479
2613
  }
2480
2614
 
2481
2615
  // src/hooks/useWaitForCommit.ts
2482
- import { useCallback as useCallback14 } from "react";
2616
+ import { useCallback as useCallback17 } from "react";
2483
2617
  import { TransactionFilter as TransactionFilter3 } from "@miden-sdk/miden-sdk/lazy";
2484
2618
  function useWaitForCommit() {
2485
2619
  const { client, isReady } = useMiden();
2486
- const waitForCommit = useCallback14(
2620
+ const waitForCommit = useCallback17(
2487
2621
  async (txId, options) => {
2488
2622
  if (!client || !isReady) {
2489
2623
  throw new Error("Miden client is not ready");
@@ -2526,11 +2660,11 @@ function normalizeHex3(value) {
2526
2660
  }
2527
2661
 
2528
2662
  // src/hooks/useWaitForNotes.ts
2529
- import { useCallback as useCallback15 } from "react";
2663
+ import { useCallback as useCallback18 } from "react";
2530
2664
  function useWaitForNotes() {
2531
2665
  const { client, isReady, runExclusive } = useMiden();
2532
2666
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2533
- const waitForConsumableNotes = useCallback15(
2667
+ const waitForConsumableNotes = useCallback18(
2534
2668
  async (options) => {
2535
2669
  if (!client || !isReady) {
2536
2670
  throw new Error("Miden client is not ready");
@@ -2561,15 +2695,15 @@ function useWaitForNotes() {
2561
2695
  }
2562
2696
 
2563
2697
  // src/hooks/useMint.ts
2564
- import { useCallback as useCallback16, useState as useState12 } from "react";
2698
+ import { useCallback as useCallback19, useState as useState15 } from "react";
2565
2699
  function useMint() {
2566
2700
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2567
2701
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2568
- const [result, setResult] = useState12(null);
2569
- const [isLoading, setIsLoading] = useState12(false);
2570
- const [stage, setStage] = useState12("idle");
2571
- const [error, setError] = useState12(null);
2572
- const mint = useCallback16(
2702
+ const [result, setResult] = useState15(null);
2703
+ const [isLoading, setIsLoading] = useState15(false);
2704
+ const [stage, setStage] = useState15("idle");
2705
+ const [error, setError] = useState15(null);
2706
+ const mint = useCallback19(
2573
2707
  async (options) => {
2574
2708
  if (!client || !isReady) {
2575
2709
  throw new Error("Miden client is not ready");
@@ -2611,7 +2745,7 @@ function useMint() {
2611
2745
  },
2612
2746
  [client, isReady, prover, runExclusive, sync]
2613
2747
  );
2614
- const reset = useCallback16(() => {
2748
+ const reset = useCallback19(() => {
2615
2749
  setResult(null);
2616
2750
  setIsLoading(false);
2617
2751
  setStage("idle");
@@ -2628,16 +2762,16 @@ function useMint() {
2628
2762
  }
2629
2763
 
2630
2764
  // src/hooks/useConsume.ts
2631
- import { useCallback as useCallback17, useState as useState13 } from "react";
2765
+ import { useCallback as useCallback20, useState as useState16 } from "react";
2632
2766
  import { NoteFilter as NoteFilter3, NoteFilterTypes as NoteFilterTypes2, NoteId } from "@miden-sdk/miden-sdk/lazy";
2633
2767
  function useConsume() {
2634
2768
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2635
2769
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2636
- const [result, setResult] = useState13(null);
2637
- const [isLoading, setIsLoading] = useState13(false);
2638
- const [stage, setStage] = useState13("idle");
2639
- const [error, setError] = useState13(null);
2640
- const consume = useCallback17(
2770
+ const [result, setResult] = useState16(null);
2771
+ const [isLoading, setIsLoading] = useState16(false);
2772
+ const [stage, setStage] = useState16("idle");
2773
+ const [error, setError] = useState16(null);
2774
+ const consume = useCallback20(
2641
2775
  async (options) => {
2642
2776
  if (!client || !isReady) {
2643
2777
  throw new Error("Miden client is not ready");
@@ -2721,7 +2855,7 @@ function useConsume() {
2721
2855
  },
2722
2856
  [client, isReady, prover, runExclusive, sync]
2723
2857
  );
2724
- const reset = useCallback17(() => {
2858
+ const reset = useCallback20(() => {
2725
2859
  setResult(null);
2726
2860
  setIsLoading(false);
2727
2861
  setStage("idle");
@@ -2738,15 +2872,15 @@ function useConsume() {
2738
2872
  }
2739
2873
 
2740
2874
  // src/hooks/useSwap.ts
2741
- import { useCallback as useCallback18, useState as useState14 } from "react";
2875
+ import { useCallback as useCallback21, useState as useState17 } from "react";
2742
2876
  function useSwap() {
2743
2877
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2744
2878
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2745
- const [result, setResult] = useState14(null);
2746
- const [isLoading, setIsLoading] = useState14(false);
2747
- const [stage, setStage] = useState14("idle");
2748
- const [error, setError] = useState14(null);
2749
- const swap = useCallback18(
2879
+ const [result, setResult] = useState17(null);
2880
+ const [isLoading, setIsLoading] = useState17(false);
2881
+ const [stage, setStage] = useState17("idle");
2882
+ const [error, setError] = useState17(null);
2883
+ const swap = useCallback21(
2750
2884
  async (options) => {
2751
2885
  if (!client || !isReady) {
2752
2886
  throw new Error("Miden client is not ready");
@@ -2795,7 +2929,7 @@ function useSwap() {
2795
2929
  },
2796
2930
  [client, isReady, prover, runExclusive, sync]
2797
2931
  );
2798
- const reset = useCallback18(() => {
2932
+ const reset = useCallback21(() => {
2799
2933
  setResult(null);
2800
2934
  setIsLoading(false);
2801
2935
  setStage("idle");
@@ -2812,15 +2946,15 @@ function useSwap() {
2812
2946
  }
2813
2947
 
2814
2948
  // src/hooks/usePswapCreate.ts
2815
- import { useCallback as useCallback19, useState as useState15 } from "react";
2949
+ import { useCallback as useCallback22, useState as useState18 } from "react";
2816
2950
  function usePswapCreate() {
2817
2951
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2818
2952
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2819
- const [result, setResult] = useState15(null);
2820
- const [isLoading, setIsLoading] = useState15(false);
2821
- const [stage, setStage] = useState15("idle");
2822
- const [error, setError] = useState15(null);
2823
- const pswapCreate = useCallback19(
2953
+ const [result, setResult] = useState18(null);
2954
+ const [isLoading, setIsLoading] = useState18(false);
2955
+ const [stage, setStage] = useState18("idle");
2956
+ const [error, setError] = useState18(null);
2957
+ const pswapCreate = useCallback22(
2824
2958
  async (options) => {
2825
2959
  if (!client || !isReady) {
2826
2960
  throw new Error("Miden client is not ready");
@@ -2877,7 +3011,7 @@ function usePswapCreate() {
2877
3011
  },
2878
3012
  [client, isReady, prover, runExclusive, sync]
2879
3013
  );
2880
- const reset = useCallback19(() => {
3014
+ const reset = useCallback22(() => {
2881
3015
  setResult(null);
2882
3016
  setIsLoading(false);
2883
3017
  setStage("idle");
@@ -2894,15 +3028,15 @@ function usePswapCreate() {
2894
3028
  }
2895
3029
 
2896
3030
  // src/hooks/usePswapConsume.ts
2897
- import { useCallback as useCallback20, useState as useState16 } from "react";
3031
+ import { useCallback as useCallback23, useState as useState19 } from "react";
2898
3032
  function usePswapConsume() {
2899
3033
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2900
3034
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2901
- const [result, setResult] = useState16(null);
2902
- const [isLoading, setIsLoading] = useState16(false);
2903
- const [stage, setStage] = useState16("idle");
2904
- const [error, setError] = useState16(null);
2905
- const pswapConsume = useCallback20(
3035
+ const [result, setResult] = useState19(null);
3036
+ const [isLoading, setIsLoading] = useState19(false);
3037
+ const [stage, setStage] = useState19("idle");
3038
+ const [error, setError] = useState19(null);
3039
+ const pswapConsume = useCallback23(
2906
3040
  async (options) => {
2907
3041
  if (!client || !isReady) {
2908
3042
  throw new Error("Miden client is not ready");
@@ -2951,7 +3085,7 @@ function usePswapConsume() {
2951
3085
  },
2952
3086
  [client, isReady, prover, runExclusive, sync]
2953
3087
  );
2954
- const reset = useCallback20(() => {
3088
+ const reset = useCallback23(() => {
2955
3089
  setResult(null);
2956
3090
  setIsLoading(false);
2957
3091
  setStage("idle");
@@ -2968,15 +3102,15 @@ function usePswapConsume() {
2968
3102
  }
2969
3103
 
2970
3104
  // src/hooks/usePswapCancel.ts
2971
- import { useCallback as useCallback21, useState as useState17 } from "react";
3105
+ import { useCallback as useCallback24, useState as useState20 } from "react";
2972
3106
  function usePswapCancel() {
2973
3107
  const { client, isReady, sync, runExclusive, prover } = useMiden();
2974
3108
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
2975
- const [result, setResult] = useState17(null);
2976
- const [isLoading, setIsLoading] = useState17(false);
2977
- const [stage, setStage] = useState17("idle");
2978
- const [error, setError] = useState17(null);
2979
- const pswapCancel = useCallback21(
3109
+ const [result, setResult] = useState20(null);
3110
+ const [isLoading, setIsLoading] = useState20(false);
3111
+ const [stage, setStage] = useState20("idle");
3112
+ const [error, setError] = useState20(null);
3113
+ const pswapCancel = useCallback24(
2980
3114
  async (options) => {
2981
3115
  if (!client || !isReady) {
2982
3116
  throw new Error("Miden client is not ready");
@@ -3015,7 +3149,7 @@ function usePswapCancel() {
3015
3149
  },
3016
3150
  [client, isReady, prover, runExclusive, sync]
3017
3151
  );
3018
- const reset = useCallback21(() => {
3152
+ const reset = useCallback24(() => {
3019
3153
  setResult(null);
3020
3154
  setIsLoading(false);
3021
3155
  setStage("idle");
@@ -3031,8 +3165,73 @@ function usePswapCancel() {
3031
3165
  };
3032
3166
  }
3033
3167
 
3168
+ // src/hooks/usePswapCancelByOrder.ts
3169
+ import { useCallback as useCallback25, useState as useState21 } from "react";
3170
+ function usePswapCancelByOrder() {
3171
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
3172
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3173
+ const [result, setResult] = useState21(null);
3174
+ const [isLoading, setIsLoading] = useState21(false);
3175
+ const [stage, setStage] = useState21("idle");
3176
+ const [error, setError] = useState21(null);
3177
+ const pswapCancelByOrder = useCallback25(
3178
+ async (options) => {
3179
+ if (!client || !isReady) {
3180
+ throw new Error("Miden client is not ready");
3181
+ }
3182
+ setIsLoading(true);
3183
+ setStage("executing");
3184
+ setError(null);
3185
+ try {
3186
+ const orderId = String(options.orderId);
3187
+ setStage("proving");
3188
+ const txResult = await runExclusiveSafe(async () => {
3189
+ const lineage = await client.getPswapLineage(orderId);
3190
+ if (!lineage) {
3191
+ throw new Error(`No PSWAP lineage tracked for order ${orderId}`);
3192
+ }
3193
+ const accountIdObj = lineage.creatorAccountId();
3194
+ const txRequest = await client.buildPswapCancelByOrder(orderId);
3195
+ const txId = prover ? await client.submitNewTransactionWithProver(
3196
+ accountIdObj,
3197
+ txRequest,
3198
+ prover
3199
+ ) : await client.submitNewTransaction(accountIdObj, txRequest);
3200
+ return { transactionId: txId.toHex() };
3201
+ });
3202
+ setResult(txResult);
3203
+ await sync();
3204
+ setStage("complete");
3205
+ return txResult;
3206
+ } catch (err) {
3207
+ const error2 = err instanceof Error ? err : new Error(String(err));
3208
+ setError(error2);
3209
+ setStage("idle");
3210
+ throw error2;
3211
+ } finally {
3212
+ setIsLoading(false);
3213
+ }
3214
+ },
3215
+ [client, isReady, prover, runExclusive, sync]
3216
+ );
3217
+ const reset = useCallback25(() => {
3218
+ setResult(null);
3219
+ setIsLoading(false);
3220
+ setStage("idle");
3221
+ setError(null);
3222
+ }, []);
3223
+ return {
3224
+ pswapCancelByOrder,
3225
+ result,
3226
+ isLoading,
3227
+ stage,
3228
+ error,
3229
+ reset
3230
+ };
3231
+ }
3232
+
3034
3233
  // src/hooks/useTransaction.ts
3035
- import { useCallback as useCallback22, useRef as useRef6, useState as useState18 } from "react";
3234
+ import { useCallback as useCallback26, useRef as useRef9, useState as useState22 } from "react";
3036
3235
 
3037
3236
  // src/utils/transactions.ts
3038
3237
  import { NoteType as NoteType4, TransactionFilter as TransactionFilter4 } from "@miden-sdk/miden-sdk/lazy";
@@ -3078,12 +3277,12 @@ function extractFullNotes(txResult) {
3078
3277
  function useTransaction() {
3079
3278
  const { client, isReady, sync, runExclusive } = useMiden();
3080
3279
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3081
- const isBusyRef = useRef6(false);
3082
- const [result, setResult] = useState18(null);
3083
- const [isLoading, setIsLoading] = useState18(false);
3084
- const [stage, setStage] = useState18("idle");
3085
- const [error, setError] = useState18(null);
3086
- const execute = useCallback22(
3280
+ const isBusyRef = useRef9(false);
3281
+ const [result, setResult] = useState22(null);
3282
+ const [isLoading, setIsLoading] = useState22(false);
3283
+ const [stage, setStage] = useState22("idle");
3284
+ const [error, setError] = useState22(null);
3285
+ const execute = useCallback26(
3087
3286
  async (options) => {
3088
3287
  if (!client || !isReady) {
3089
3288
  throw new Error("Miden client is not ready");
@@ -3150,7 +3349,7 @@ function useTransaction() {
3150
3349
  },
3151
3350
  [client, isReady, runExclusive, sync]
3152
3351
  );
3153
- const reset = useCallback22(() => {
3352
+ const reset = useCallback26(() => {
3154
3353
  setResult(null);
3155
3354
  setIsLoading(false);
3156
3355
  setStage("idle");
@@ -3173,7 +3372,7 @@ async function resolveRequest(request, client) {
3173
3372
  }
3174
3373
 
3175
3374
  // src/hooks/useExecuteProgram.ts
3176
- import { useCallback as useCallback23, useRef as useRef7, useState as useState19 } from "react";
3375
+ import { useCallback as useCallback27, useRef as useRef10, useState as useState23 } from "react";
3177
3376
  import {
3178
3377
  AdviceInputs,
3179
3378
  ForeignAccount,
@@ -3186,11 +3385,11 @@ function isForeignAccountWrapper(fa) {
3186
3385
  function useExecuteProgram() {
3187
3386
  const { client, isReady, sync, runExclusive } = useMiden();
3188
3387
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3189
- const isBusyRef = useRef7(false);
3190
- const [result, setResult] = useState19(null);
3191
- const [isLoading, setIsLoading] = useState19(false);
3192
- const [error, setError] = useState19(null);
3193
- const execute = useCallback23(
3388
+ const isBusyRef = useRef10(false);
3389
+ const [result, setResult] = useState23(null);
3390
+ const [isLoading, setIsLoading] = useState23(false);
3391
+ const [error, setError] = useState23(null);
3392
+ const execute = useCallback27(
3194
3393
  async (options) => {
3195
3394
  if (!client || !isReady) {
3196
3395
  throw new Error("Miden client is not ready");
@@ -3249,7 +3448,7 @@ function useExecuteProgram() {
3249
3448
  },
3250
3449
  [client, isReady, runExclusive, sync]
3251
3450
  );
3252
- const reset = useCallback23(() => {
3451
+ const reset = useCallback27(() => {
3253
3452
  setResult(null);
3254
3453
  setIsLoading(false);
3255
3454
  setError(null);
@@ -3264,29 +3463,29 @@ function useExecuteProgram() {
3264
3463
  }
3265
3464
 
3266
3465
  // src/hooks/useCompile.ts
3267
- import { useCallback as useCallback24, useMemo as useMemo8 } from "react";
3466
+ import { useCallback as useCallback28, useMemo as useMemo9 } from "react";
3268
3467
  import { CompilerResource, getWasmOrThrow } from "@miden-sdk/miden-sdk/lazy";
3269
3468
  function useCompile() {
3270
3469
  const { client, isReady } = useMiden();
3271
- const resource = useMemo8(
3470
+ const resource = useMemo9(
3272
3471
  () => client && isReady ? new CompilerResource(client, getWasmOrThrow) : null,
3273
3472
  [client, isReady]
3274
3473
  );
3275
- const requireResource = useCallback24(() => {
3474
+ const requireResource = useCallback28(() => {
3276
3475
  if (!resource) {
3277
3476
  throw new Error("Miden client is not ready");
3278
3477
  }
3279
3478
  return resource;
3280
3479
  }, [resource]);
3281
- const component = useCallback24(
3480
+ const component = useCallback28(
3282
3481
  async (options) => requireResource().component(options),
3283
3482
  [requireResource]
3284
3483
  );
3285
- const txScript = useCallback24(
3484
+ const txScript = useCallback28(
3286
3485
  async (options) => requireResource().txScript(options),
3287
3486
  [requireResource]
3288
3487
  );
3289
- const noteScript = useCallback24(
3488
+ const noteScript = useCallback28(
3290
3489
  async (options) => requireResource().noteScript(options),
3291
3490
  [requireResource]
3292
3491
  );
@@ -3294,24 +3493,24 @@ function useCompile() {
3294
3493
  }
3295
3494
 
3296
3495
  // src/hooks/useSessionAccount.ts
3297
- import { useCallback as useCallback25, useEffect as useEffect9, useRef as useRef8, useState as useState20 } from "react";
3496
+ import { useCallback as useCallback29, useEffect as useEffect12, useRef as useRef11, useState as useState24 } from "react";
3298
3497
  import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk/lazy";
3299
3498
  function useSessionAccount(options) {
3300
3499
  const { client, isReady, sync } = useMiden();
3301
3500
  const setAccounts = useMidenStore((state) => state.setAccounts);
3302
- const [sessionAccountId, setSessionAccountId] = useState20(null);
3303
- const [step, setStep] = useState20("idle");
3304
- const [error, setError] = useState20(null);
3305
- const cancelledRef = useRef8(false);
3306
- const isBusyRef = useRef8(false);
3501
+ const [sessionAccountId, setSessionAccountId] = useState24(null);
3502
+ const [step, setStep] = useState24("idle");
3503
+ const [error, setError] = useState24(null);
3504
+ const cancelledRef = useRef11(false);
3505
+ const isBusyRef = useRef11(false);
3307
3506
  const storagePrefix = options.storagePrefix ?? "miden-session";
3308
3507
  const pollIntervalMs = options.pollIntervalMs ?? 3e3;
3309
3508
  const maxWaitMs = options.maxWaitMs ?? 6e4;
3310
3509
  const storageMode = options.walletOptions?.storageMode ?? "public";
3311
3510
  const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
3312
- const fundRef = useRef8(options.fund);
3511
+ const fundRef = useRef11(options.fund);
3313
3512
  fundRef.current = options.fund;
3314
- useEffect9(() => {
3513
+ useEffect12(() => {
3315
3514
  try {
3316
3515
  const stored = localStorage.getItem(`${storagePrefix}:accountId`);
3317
3516
  const storedReady = localStorage.getItem(`${storagePrefix}:ready`);
@@ -3328,7 +3527,7 @@ function useSessionAccount(options) {
3328
3527
  localStorage.removeItem(`${storagePrefix}:ready`);
3329
3528
  }
3330
3529
  }, [storagePrefix]);
3331
- const initialize = useCallback25(async () => {
3530
+ const initialize = useCallback29(async () => {
3332
3531
  if (!client || !isReady) {
3333
3532
  throw new Error("Miden client is not ready");
3334
3533
  }
@@ -3392,7 +3591,7 @@ function useSessionAccount(options) {
3392
3591
  maxWaitMs,
3393
3592
  setAccounts
3394
3593
  ]);
3395
- const reset = useCallback25(() => {
3594
+ const reset = useCallback29(() => {
3396
3595
  cancelledRef.current = true;
3397
3596
  isBusyRef.current = false;
3398
3597
  setSessionAccountId(null);
@@ -3441,13 +3640,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
3441
3640
  }
3442
3641
 
3443
3642
  // src/hooks/useExportStore.ts
3444
- import { useCallback as useCallback26, useState as useState21 } from "react";
3643
+ import { useCallback as useCallback30, useState as useState25 } from "react";
3445
3644
  import { exportStore as sdkExportStore } from "@miden-sdk/miden-sdk/lazy";
3446
3645
  function useExportStore() {
3447
3646
  const { client, isReady, runExclusive } = useMiden();
3448
- const [isExporting, setIsExporting] = useState21(false);
3449
- const [error, setError] = useState21(null);
3450
- const exportStore = useCallback26(async () => {
3647
+ const [isExporting, setIsExporting] = useState25(false);
3648
+ const [error, setError] = useState25(null);
3649
+ const exportStore = useCallback30(async () => {
3451
3650
  if (!client || !isReady) {
3452
3651
  throw new Error("Miden client is not ready");
3453
3652
  }
@@ -3465,7 +3664,7 @@ function useExportStore() {
3465
3664
  setIsExporting(false);
3466
3665
  }
3467
3666
  }, [client, isReady, runExclusive]);
3468
- const reset = useCallback26(() => {
3667
+ const reset = useCallback30(() => {
3469
3668
  setIsExporting(false);
3470
3669
  setError(null);
3471
3670
  }, []);
@@ -3478,13 +3677,13 @@ function useExportStore() {
3478
3677
  }
3479
3678
 
3480
3679
  // src/hooks/useImportStore.ts
3481
- import { useCallback as useCallback27, useState as useState22 } from "react";
3680
+ import { useCallback as useCallback31, useState as useState26 } from "react";
3482
3681
  import { importStore as sdkImportStore } from "@miden-sdk/miden-sdk/lazy";
3483
3682
  function useImportStore() {
3484
3683
  const { client, isReady, runExclusive, sync } = useMiden();
3485
- const [isImporting, setIsImporting] = useState22(false);
3486
- const [error, setError] = useState22(null);
3487
- const importStore = useCallback27(
3684
+ const [isImporting, setIsImporting] = useState26(false);
3685
+ const [error, setError] = useState26(null);
3686
+ const importStore = useCallback31(
3488
3687
  async (storeDump, storeName, options) => {
3489
3688
  if (!client || !isReady) {
3490
3689
  throw new Error("Miden client is not ready");
@@ -3506,7 +3705,7 @@ function useImportStore() {
3506
3705
  },
3507
3706
  [client, isReady, runExclusive, sync]
3508
3707
  );
3509
- const reset = useCallback27(() => {
3708
+ const reset = useCallback31(() => {
3510
3709
  setIsImporting(false);
3511
3710
  setError(null);
3512
3711
  }, []);
@@ -3519,13 +3718,13 @@ function useImportStore() {
3519
3718
  }
3520
3719
 
3521
3720
  // src/hooks/useImportNote.ts
3522
- import { useCallback as useCallback28, useState as useState23 } from "react";
3721
+ import { useCallback as useCallback32, useState as useState27 } from "react";
3523
3722
  import { NoteFile } from "@miden-sdk/miden-sdk/lazy";
3524
3723
  function useImportNote() {
3525
3724
  const { client, isReady, runExclusive, sync } = useMiden();
3526
- const [isImporting, setIsImporting] = useState23(false);
3527
- const [error, setError] = useState23(null);
3528
- const importNote = useCallback28(
3725
+ const [isImporting, setIsImporting] = useState27(false);
3726
+ const [error, setError] = useState27(null);
3727
+ const importNote = useCallback32(
3529
3728
  async (noteBytes) => {
3530
3729
  if (!client || !isReady) {
3531
3730
  throw new Error("Miden client is not ready");
@@ -3549,7 +3748,7 @@ function useImportNote() {
3549
3748
  },
3550
3749
  [client, isReady, runExclusive, sync]
3551
3750
  );
3552
- const reset = useCallback28(() => {
3751
+ const reset = useCallback32(() => {
3553
3752
  setIsImporting(false);
3554
3753
  setError(null);
3555
3754
  }, []);
@@ -3562,13 +3761,13 @@ function useImportNote() {
3562
3761
  }
3563
3762
 
3564
3763
  // src/hooks/useExportNote.ts
3565
- import { useCallback as useCallback29, useState as useState24 } from "react";
3764
+ import { useCallback as useCallback33, useState as useState28 } from "react";
3566
3765
  import { NoteExportFormat } from "@miden-sdk/miden-sdk/lazy";
3567
3766
  function useExportNote() {
3568
3767
  const { client, isReady, runExclusive } = useMiden();
3569
- const [isExporting, setIsExporting] = useState24(false);
3570
- const [error, setError] = useState24(null);
3571
- const exportNote = useCallback29(
3768
+ const [isExporting, setIsExporting] = useState28(false);
3769
+ const [error, setError] = useState28(null);
3770
+ const exportNote = useCallback33(
3572
3771
  async (noteId) => {
3573
3772
  if (!client || !isReady) {
3574
3773
  throw new Error("Miden client is not ready");
@@ -3590,7 +3789,7 @@ function useExportNote() {
3590
3789
  },
3591
3790
  [client, isReady, runExclusive]
3592
3791
  );
3593
- const reset = useCallback29(() => {
3792
+ const reset = useCallback33(() => {
3594
3793
  setIsExporting(false);
3595
3794
  setError(null);
3596
3795
  }, []);
@@ -3603,12 +3802,12 @@ function useExportNote() {
3603
3802
  }
3604
3803
 
3605
3804
  // src/hooks/useSyncControl.ts
3606
- import { useCallback as useCallback30 } from "react";
3805
+ import { useCallback as useCallback34 } from "react";
3607
3806
  function useSyncControl() {
3608
3807
  const isPaused = useMidenStore((state) => state.syncPaused);
3609
3808
  const setSyncPaused = useMidenStore((state) => state.setSyncPaused);
3610
- const pauseSync = useCallback30(() => setSyncPaused(true), [setSyncPaused]);
3611
- const resumeSync = useCallback30(() => setSyncPaused(false), [setSyncPaused]);
3809
+ const pauseSync = useCallback34(() => setSyncPaused(true), [setSyncPaused]);
3810
+ const resumeSync = useCallback34(() => setSyncPaused(false), [setSyncPaused]);
3612
3811
  return {
3613
3812
  pauseSync,
3614
3813
  resumeSync,
@@ -3811,8 +4010,12 @@ export {
3811
4010
  useNoteStream,
3812
4011
  useNotes,
3813
4012
  usePswapCancel,
4013
+ usePswapCancelByOrder,
3814
4014
  usePswapConsume,
3815
4015
  usePswapCreate,
4016
+ usePswapLineage,
4017
+ usePswapLineages,
4018
+ usePswapLineagesFor,
3816
4019
  useSend,
3817
4020
  useSessionAccount,
3818
4021
  useSigner,