@permissionless-technologies/upp-sdk 0.4.13 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{chunk-O6ALW7DB.js → chunk-5WLAZA3M.js} +3 -3
  2. package/dist/{chunk-O6ALW7DB.js.map → chunk-5WLAZA3M.js.map} +1 -1
  3. package/dist/{chunk-4MWEJDTR.cjs → chunk-7Y6O4P2P.cjs} +3 -3
  4. package/dist/{chunk-4MWEJDTR.cjs.map → chunk-7Y6O4P2P.cjs.map} +1 -1
  5. package/dist/{chunk-KZ7PY2PR.cjs → chunk-CTBLNYYB.cjs} +2 -2
  6. package/dist/{chunk-KZ7PY2PR.cjs.map → chunk-CTBLNYYB.cjs.map} +1 -1
  7. package/dist/{chunk-23B5XSS4.cjs → chunk-CZLMCMYE.cjs} +90 -2
  8. package/dist/chunk-CZLMCMYE.cjs.map +1 -0
  9. package/dist/{chunk-3I6ERQO3.js → chunk-GQ6JMNJI.js} +3 -3
  10. package/dist/{chunk-3I6ERQO3.js.map → chunk-GQ6JMNJI.js.map} +1 -1
  11. package/dist/{chunk-RNUG3EFC.js → chunk-NIGEAKQP.js} +89 -3
  12. package/dist/chunk-NIGEAKQP.js.map +1 -0
  13. package/dist/{chunk-5BLMSTFQ.cjs → chunk-TBGDQM33.cjs} +4 -4
  14. package/dist/{chunk-5BLMSTFQ.cjs.map → chunk-TBGDQM33.cjs.map} +1 -1
  15. package/dist/{chunk-DUBWGEB5.js → chunk-YMZM2ABJ.js} +2 -2
  16. package/dist/{chunk-DUBWGEB5.js.map → chunk-YMZM2ABJ.js.map} +1 -1
  17. package/dist/core/index.cjs +100 -92
  18. package/dist/core/index.d.cts +2 -2
  19. package/dist/core/index.d.ts +2 -2
  20. package/dist/core/index.js +4 -4
  21. package/dist/core/proof-worker-entry.cjs +60 -0
  22. package/dist/core/proof-worker-entry.cjs.map +1 -0
  23. package/dist/core/proof-worker-entry.d.cts +2 -0
  24. package/dist/core/proof-worker-entry.d.ts +2 -0
  25. package/dist/core/proof-worker-entry.js +58 -0
  26. package/dist/core/proof-worker-entry.js.map +1 -0
  27. package/dist/{index-CKCDqv2e.d.cts → index-DKFupAA8.d.cts} +8 -3
  28. package/dist/{index-DLczKlnM.d.ts → index-M91G-og3.d.ts} +8 -3
  29. package/dist/{index--eNkOLiP.d.ts → index-S2fzWmLW.d.ts} +1 -1
  30. package/dist/{index-CRaFsQD3.d.cts → index-qTwnREeK.d.cts} +1 -1
  31. package/dist/index.cjs +108 -100
  32. package/dist/index.d.cts +3 -3
  33. package/dist/index.d.ts +3 -3
  34. package/dist/index.js +5 -5
  35. package/dist/indexer/index.cjs +6 -6
  36. package/dist/indexer/index.d.cts +5 -5
  37. package/dist/indexer/index.d.ts +5 -5
  38. package/dist/indexer/index.js +1 -1
  39. package/dist/react/index.cjs +69 -21
  40. package/dist/react/index.cjs.map +1 -1
  41. package/dist/react/index.d.cts +20 -3
  42. package/dist/react/index.d.ts +20 -3
  43. package/dist/react/index.js +52 -12
  44. package/dist/react/index.js.map +1 -1
  45. package/dist/{transfer-CwwsNdGL.d.cts → transfer-BDYID3Hn.d.cts} +75 -1
  46. package/dist/{transfer-Crvdq4VN.d.ts → transfer-DLukr6ed.d.ts} +75 -1
  47. package/dist/{transfer-LGR44CER.js → transfer-LT2VGGPZ.js} +4 -4
  48. package/dist/{transfer-LGR44CER.js.map → transfer-LT2VGGPZ.js.map} +1 -1
  49. package/dist/{transfer-UZBU47HC.cjs → transfer-OPGKWWX2.cjs} +10 -10
  50. package/dist/{transfer-UZBU47HC.cjs.map → transfer-OPGKWWX2.cjs.map} +1 -1
  51. package/package.json +5 -1
  52. package/dist/chunk-23B5XSS4.cjs.map +0 -1
  53. package/dist/chunk-RNUG3EFC.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk23B5XSS4_cjs = require('../chunk-23B5XSS4.cjs');
3
+ var chunkCZLMCMYE_cjs = require('../chunk-CZLMCMYE.cjs');
4
4
  var chunkXVIICZKW_cjs = require('../chunk-XVIICZKW.cjs');
5
5
  var chunkERQE57IA_cjs = require('../chunk-ERQE57IA.cjs');
6
6
  require('../chunk-UFEDJJSH.cjs');
@@ -107,7 +107,7 @@ function UPPAccountProvider({
107
107
  return;
108
108
  }
109
109
  const accountStorage = chunkERQE57IA_cjs.createAutoAdapter(`upp_account`);
110
- const adapter = new chunk23B5XSS4_cjs.StorableAccountAdapter(accountStorage, ethAddress);
110
+ const adapter = new chunkCZLMCMYE_cjs.StorableAccountAdapter(accountStorage, ethAddress);
111
111
  accountAdapterRef.current = adapter;
112
112
  const legacyKey = getStorageKey(ethAddress);
113
113
  const legacySaved = typeof window !== "undefined" ? localStorage.getItem(legacyKey) : null;
@@ -148,7 +148,7 @@ function UPPAccountProvider({
148
148
  const ownerHashHex2 = viem.toHex(account.keys.ownerHash, { size: 32 });
149
149
  const storagePrefix = `upp_${chainId}_${ownerHashHex2.slice(0, 12)}`;
150
150
  const noteStorage = chunkERQE57IA_cjs.createAutoAdapter(storagePrefix);
151
- const store = new chunk23B5XSS4_cjs.NoteStore(noteStorage, "notes");
151
+ const store = new chunkCZLMCMYE_cjs.NoteStore(noteStorage, "notes");
152
152
  noteStoreRef.current = store;
153
153
  noteStoreUnsub = store.onChange(() => {
154
154
  if (!cancelled) setNotes([...store.getNotes()]);
@@ -849,7 +849,7 @@ function UPPAccountProvider({
849
849
  const stealthAddress = react.useMemo(() => {
850
850
  if (!masterKeys) return null;
851
851
  try {
852
- const { encodeStealthAddress } = (chunk23B5XSS4_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunk23B5XSS4_cjs.stealth_exports));
852
+ const { encodeStealthAddress } = (chunkCZLMCMYE_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunkCZLMCMYE_cjs.stealth_exports));
853
853
  return encodeStealthAddress(masterKeys.ownerHash, masterKeys.viewingHash);
854
854
  } catch {
855
855
  return null;
@@ -858,7 +858,7 @@ function UPPAccountProvider({
858
858
  const starkStealthAddress = react.useMemo(() => {
859
859
  if (!starkMasterKeys) return null;
860
860
  try {
861
- const { encodeStarkStealthAddress } = (chunk23B5XSS4_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunk23B5XSS4_cjs.stealth_exports));
861
+ const { encodeStarkStealthAddress } = (chunkCZLMCMYE_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunkCZLMCMYE_cjs.stealth_exports));
862
862
  return encodeStarkStealthAddress(starkMasterKeys.starkOwnerHash, starkMasterKeys.starkViewingHash);
863
863
  } catch {
864
864
  return null;
@@ -1663,6 +1663,7 @@ function usePoolTransfer(config) {
1663
1663
  } = useUPPAccount();
1664
1664
  const [isPending, setIsPending] = react.useState(false);
1665
1665
  const [stage, setStage] = react.useState(null);
1666
+ const [provingProgress, setProvingProgress] = react.useState(null);
1666
1667
  const [error, setError] = react.useState(null);
1667
1668
  const configRef = react.useRef(config);
1668
1669
  configRef.current = config;
@@ -1705,7 +1706,7 @@ function usePoolTransfer(config) {
1705
1706
  const recipientNote = await createNoteForSelf(amount, origin, token);
1706
1707
  const changeNote = await createNoteForSelf(changeAmount, origin, token);
1707
1708
  const [transferModule, proofModule, aspModule] = await Promise.all([
1708
- import('../transfer-UZBU47HC.cjs'),
1709
+ import('../transfer-OPGKWWX2.cjs'),
1709
1710
  import('../proof-VINVGL4F.cjs'),
1710
1711
  import('../asp-CUE3NMBN.cjs')
1711
1712
  ]);
@@ -1743,10 +1744,12 @@ function usePoolTransfer(config) {
1743
1744
  recipientNoteWithAmount,
1744
1745
  changeNoteWithAmount
1745
1746
  );
1747
+ setProvingProgress(null);
1746
1748
  const { proof } = await generateUPPProof(
1747
1749
  "transfer",
1748
1750
  circuitInputs,
1749
- cfg.circuitBaseUrl ?? "/circuits/"
1751
+ cfg.circuitBaseUrl ?? "/circuits/",
1752
+ (s, msg) => setProvingProgress({ stage: s, message: msg })
1750
1753
  );
1751
1754
  const formattedProof = await formatPlonkProofForContract(proof);
1752
1755
  return {
@@ -1771,6 +1774,7 @@ function usePoolTransfer(config) {
1771
1774
  } finally {
1772
1775
  setIsPending(false);
1773
1776
  setStage(null);
1777
+ setProvingProgress(null);
1774
1778
  }
1775
1779
  },
1776
1780
  [isSetup, masterKeys, unspentNotes, createNoteForSelf]
@@ -1779,6 +1783,7 @@ function usePoolTransfer(config) {
1779
1783
  build,
1780
1784
  isPending,
1781
1785
  stage,
1786
+ provingProgress,
1782
1787
  error,
1783
1788
  reset
1784
1789
  };
@@ -1800,6 +1805,7 @@ function useWithdraw(config) {
1800
1805
  } = useUPPAccount();
1801
1806
  const [isPending, setIsPending] = react.useState(false);
1802
1807
  const [stage, setStage] = react.useState(null);
1808
+ const [provingProgress, setProvingProgress] = react.useState(null);
1803
1809
  const [error, setError] = react.useState(null);
1804
1810
  const configRef = react.useRef(config);
1805
1811
  configRef.current = config;
@@ -1854,7 +1860,7 @@ function useWithdraw(config) {
1854
1860
  const token = BigInt(selectedNote.token);
1855
1861
  setStage("creating_outputs");
1856
1862
  const [transferModule, proofModule, sdk] = await Promise.all([
1857
- import('../transfer-UZBU47HC.cjs'),
1863
+ import('../transfer-OPGKWWX2.cjs'),
1858
1864
  import('../proof-VINVGL4F.cjs'),
1859
1865
  import('../index.cjs')
1860
1866
  ]);
@@ -1918,10 +1924,12 @@ function useWithdraw(config) {
1918
1924
  aspPathElements: Array(ASP_TREE_DEPTH2).fill("0"),
1919
1925
  aspPathIndices: Array(ASP_TREE_DEPTH2).fill("0")
1920
1926
  };
1927
+ setProvingProgress(null);
1921
1928
  const { proof } = await generateUPPProof(
1922
1929
  "withdraw",
1923
1930
  circuitInputs,
1924
- cfg.circuitBaseUrl ?? "/circuits/"
1931
+ cfg.circuitBaseUrl ?? "/circuits/",
1932
+ (s, msg) => setProvingProgress({ stage: s, message: msg })
1925
1933
  );
1926
1934
  const formattedProof = await formatPlonkProofForContract(proof);
1927
1935
  const stateRoot = stateRootBI;
@@ -1947,6 +1955,7 @@ function useWithdraw(config) {
1947
1955
  } finally {
1948
1956
  setIsPending(false);
1949
1957
  setStage(null);
1958
+ setProvingProgress(null);
1950
1959
  }
1951
1960
  },
1952
1961
  [isSetup, masterKeys, unspentNotes]
@@ -1955,6 +1964,7 @@ function useWithdraw(config) {
1955
1964
  build,
1956
1965
  isPending,
1957
1966
  stage,
1967
+ provingProgress,
1958
1968
  error,
1959
1969
  reset
1960
1970
  };
@@ -2107,7 +2117,7 @@ function useSwapOrderBook(config) {
2107
2117
  try {
2108
2118
  const logs = await config.publicClient.getLogs({
2109
2119
  address: config.poolAddress,
2110
- event: chunk23B5XSS4_cjs.SWAP_ORDER_PLACED_EVENT,
2120
+ event: chunkCZLMCMYE_cjs.SWAP_ORDER_PLACED_EVENT,
2111
2121
  fromBlock: config.fromBlock ?? 0n,
2112
2122
  toBlock: "latest"
2113
2123
  });
@@ -2123,10 +2133,10 @@ function useSwapOrderBook(config) {
2123
2133
  blockNumber: log.blockNumber ?? 0n
2124
2134
  }));
2125
2135
  if (config.sellToken && config.buyToken) {
2126
- parsedOrders = chunk23B5XSS4_cjs.filterOrdersByTokenPair(parsedOrders, config.sellToken, config.buyToken);
2136
+ parsedOrders = chunkCZLMCMYE_cjs.filterOrdersByTokenPair(parsedOrders, config.sellToken, config.buyToken);
2127
2137
  }
2128
2138
  if (config.acceptableAspIds && config.acceptableAspIds.length > 0) {
2129
- parsedOrders = chunk23B5XSS4_cjs.filterOrdersByASP(parsedOrders, config.acceptableAspIds);
2139
+ parsedOrders = chunkCZLMCMYE_cjs.filterOrdersByASP(parsedOrders, config.acceptableAspIds);
2130
2140
  }
2131
2141
  const enriched = [];
2132
2142
  for (const order of parsedOrders) {
@@ -2177,6 +2187,7 @@ function useSwap(config) {
2177
2187
  } = useUPPAccount();
2178
2188
  const [isPending, setIsPending] = react.useState(false);
2179
2189
  const [stage, setStage] = react.useState(null);
2190
+ const [provingProgress, setProvingProgress] = react.useState(null);
2180
2191
  const [error, setError] = react.useState(null);
2181
2192
  const configRef = react.useRef(config);
2182
2193
  configRef.current = config;
@@ -2223,7 +2234,7 @@ function useSwap(config) {
2223
2234
  }
2224
2235
  setStage("creating_outputs");
2225
2236
  const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
2226
- import('../transfer-UZBU47HC.cjs'),
2237
+ import('../transfer-OPGKWWX2.cjs'),
2227
2238
  import('../proof-VINVGL4F.cjs'),
2228
2239
  import('../index.cjs'),
2229
2240
  import('../asp-CUE3NMBN.cjs')
@@ -2288,14 +2299,16 @@ function useSwap(config) {
2288
2299
  aspPathElements: padToDepth2(aspProofData.aspPathElements.map(String), "0", ASP_TREE_DEPTH3),
2289
2300
  aspPathIndices: padToDepth2(aspProofData.aspPathIndices.map(String), "0", ASP_TREE_DEPTH3)
2290
2301
  };
2302
+ setProvingProgress(null);
2291
2303
  const { proof } = await generateUPPProof(
2292
2304
  "withdraw",
2293
2305
  circuitInputs,
2294
- cfg.circuitBaseUrl ?? "/circuits/"
2306
+ cfg.circuitBaseUrl ?? "/circuits/",
2307
+ (s, msg) => setProvingProgress({ stage: s, message: msg })
2295
2308
  );
2296
2309
  const formattedProof = await formatPlonkProofForContract(proof);
2297
- const cancelSecret = chunk23B5XSS4_cjs.generateCancelSecret();
2298
- const cancelKeyHash = chunk23B5XSS4_cjs.computeCancelKeyHash(cancelSecret);
2310
+ const cancelSecret = chunkCZLMCMYE_cjs.generateCancelSecret();
2311
+ const cancelKeyHash = chunkCZLMCMYE_cjs.computeCancelKeyHash(cancelSecret);
2299
2312
  const currentBlock = await cfg.publicClient.getBlockNumber();
2300
2313
  const expiry = currentBlock + expiryBlocks;
2301
2314
  return {
@@ -2321,6 +2334,7 @@ function useSwap(config) {
2321
2334
  } finally {
2322
2335
  setIsPending(false);
2323
2336
  setStage(null);
2337
+ setProvingProgress(null);
2324
2338
  }
2325
2339
  },
2326
2340
  [isSetup, masterKeys, unspentNotes]
@@ -2343,7 +2357,7 @@ function useSwap(config) {
2343
2357
  noteOverride
2344
2358
  } = params;
2345
2359
  const cfg = configRef.current;
2346
- const giveAmount = chunk23B5XSS4_cjs.computeGiveAmount(takeAmount, rate);
2360
+ const giveAmount = chunkCZLMCMYE_cjs.computeGiveAmount(takeAmount, rate);
2347
2361
  setStage("selecting_notes");
2348
2362
  let selectedNote;
2349
2363
  if (noteOverride) {
@@ -2364,7 +2378,7 @@ function useSwap(config) {
2364
2378
  }
2365
2379
  setStage("creating_outputs");
2366
2380
  const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
2367
- import('../transfer-UZBU47HC.cjs'),
2381
+ import('../transfer-OPGKWWX2.cjs'),
2368
2382
  import('../proof-VINVGL4F.cjs'),
2369
2383
  import('../index.cjs'),
2370
2384
  import('../asp-CUE3NMBN.cjs')
@@ -2435,10 +2449,12 @@ function useSwap(config) {
2435
2449
  aspPathElements: padToDepth2(aspProofData.aspPathElements.map(String), "0", ASP_TREE_DEPTH3),
2436
2450
  aspPathIndices: padToDepth2(aspProofData.aspPathIndices.map(String), "0", ASP_TREE_DEPTH3)
2437
2451
  };
2452
+ setProvingProgress(null);
2438
2453
  const { proof } = await generateUPPProof(
2439
2454
  "withdraw",
2440
2455
  circuitInputs,
2441
- cfg.circuitBaseUrl ?? "/circuits/"
2456
+ cfg.circuitBaseUrl ?? "/circuits/",
2457
+ (s, msg) => setProvingProgress({ stage: s, message: msg })
2442
2458
  );
2443
2459
  const formattedProof = await formatPlonkProofForContract(proof);
2444
2460
  const { encodePacked: encodePacked3 } = await import('viem');
@@ -2466,6 +2482,7 @@ function useSwap(config) {
2466
2482
  } finally {
2467
2483
  setIsPending(false);
2468
2484
  setStage(null);
2485
+ setProvingProgress(null);
2469
2486
  }
2470
2487
  },
2471
2488
  [isSetup, masterKeys, unspentNotes, createNoteForSelf]
@@ -2521,6 +2538,7 @@ function useSwap(config) {
2521
2538
  } finally {
2522
2539
  setIsPending(false);
2523
2540
  setStage(null);
2541
+ setProvingProgress(null);
2524
2542
  }
2525
2543
  },
2526
2544
  [isSetup, masterKeys, createNoteForSelf]
@@ -2554,6 +2572,7 @@ function useSwap(config) {
2554
2572
  } finally {
2555
2573
  setIsPending(false);
2556
2574
  setStage(null);
2575
+ setProvingProgress(null);
2557
2576
  }
2558
2577
  },
2559
2578
  [isSetup, masterKeys, createNoteForSelf]
@@ -2583,7 +2602,7 @@ function useSwap(config) {
2583
2602
  createNoteForSelf(changeAmount, origin, token)
2584
2603
  ]);
2585
2604
  const [transferModule, proofModule, aspModule] = await Promise.all([
2586
- import('../transfer-UZBU47HC.cjs'),
2605
+ import('../transfer-OPGKWWX2.cjs'),
2587
2606
  import('../proof-VINVGL4F.cjs'),
2588
2607
  import('../asp-CUE3NMBN.cjs')
2589
2608
  ]);
@@ -2613,10 +2632,12 @@ function useSwap(config) {
2613
2632
  exactNoteWithAmount,
2614
2633
  changeNoteWithAmount
2615
2634
  );
2635
+ setProvingProgress(null);
2616
2636
  const { proof } = await generateUPPProof(
2617
2637
  "transfer",
2618
2638
  circuitInputs,
2619
- cfg.circuitBaseUrl ?? "/circuits/"
2639
+ cfg.circuitBaseUrl ?? "/circuits/",
2640
+ (s, msg) => setProvingProgress({ stage: s, message: msg })
2620
2641
  );
2621
2642
  const formattedProof = await formatPlonkProofForContract(proof);
2622
2643
  const { encodePacked: encodePacked3 } = await import('viem');
@@ -2674,12 +2695,14 @@ function useSwap(config) {
2674
2695
  } finally {
2675
2696
  setIsPending(false);
2676
2697
  setStage(null);
2698
+ setProvingProgress(null);
2677
2699
  }
2678
2700
  },
2679
2701
  [isSetup, masterKeys, createNoteForSelf]
2680
2702
  );
2681
2703
  return {
2682
2704
  stage,
2705
+ provingProgress,
2683
2706
  isPending,
2684
2707
  error,
2685
2708
  buildNoteSplit,
@@ -2690,7 +2713,31 @@ function useSwap(config) {
2690
2713
  reset
2691
2714
  };
2692
2715
  }
2716
+ function useProofWorker(worker) {
2717
+ const managerRef = react.useRef(null);
2718
+ react.useEffect(() => {
2719
+ if (!worker) {
2720
+ managerRef.current = null;
2721
+ return;
2722
+ }
2723
+ const manager = new chunkCZLMCMYE_cjs.ProofWorkerManager(worker);
2724
+ managerRef.current = manager;
2725
+ return () => {
2726
+ manager.terminate();
2727
+ managerRef.current = null;
2728
+ };
2729
+ }, [worker]);
2730
+ return managerRef.current;
2731
+ }
2693
2732
 
2733
+ Object.defineProperty(exports, "ProofWorkerManager", {
2734
+ enumerable: true,
2735
+ get: function () { return chunkCZLMCMYE_cjs.ProofWorkerManager; }
2736
+ });
2737
+ Object.defineProperty(exports, "generateUPPProofAsync", {
2738
+ enumerable: true,
2739
+ get: function () { return chunkCZLMCMYE_cjs.generateUPPProofAsync; }
2740
+ });
2694
2741
  Object.defineProperty(exports, "ASP_TREE_DEPTH", {
2695
2742
  enumerable: true,
2696
2743
  get: function () { return chunkXVIICZKW_cjs.ASP_TREE_DEPTH; }
@@ -2728,6 +2775,7 @@ exports.renderAvatarSVG = renderAvatarSVG;
2728
2775
  exports.storePersonalASPId = storePersonalASPId;
2729
2776
  exports.usePersonalASP = usePersonalASP;
2730
2777
  exports.usePoolTransfer = usePoolTransfer;
2778
+ exports.useProofWorker = useProofWorker;
2731
2779
  exports.useShield = useShield;
2732
2780
  exports.useSwap = useSwap;
2733
2781
  exports.useSwapOrderBook = useSwapOrderBook;