@permissionless-technologies/upp-sdk 0.4.23 → 0.5.0

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 (52) hide show
  1. package/dist/{chunk-TVF6FYTQ.js → chunk-27SFQEYY.js} +80 -41
  2. package/dist/chunk-27SFQEYY.js.map +1 -0
  3. package/dist/chunk-53JACDGZ.js +131 -0
  4. package/dist/chunk-53JACDGZ.js.map +1 -0
  5. package/dist/{chunk-R4O6FOIN.js → chunk-5CZ7R4CT.js} +2 -2
  6. package/dist/{chunk-R4O6FOIN.js.map → chunk-5CZ7R4CT.js.map} +1 -1
  7. package/dist/chunk-HB43C26P.cjs +139 -0
  8. package/dist/chunk-HB43C26P.cjs.map +1 -0
  9. package/dist/{chunk-UWW4GFZ3.cjs → chunk-JVFP4Q2B.cjs} +2 -2
  10. package/dist/{chunk-UWW4GFZ3.cjs.map → chunk-JVFP4Q2B.cjs.map} +1 -1
  11. package/dist/{chunk-5MK5R7M7.cjs → chunk-MSBRBR3X.cjs} +80 -41
  12. package/dist/chunk-MSBRBR3X.cjs.map +1 -0
  13. package/dist/core/index.cjs +28 -20
  14. package/dist/core/index.d.cts +2 -2
  15. package/dist/core/index.d.ts +2 -2
  16. package/dist/core/index.js +5 -5
  17. package/dist/{index-CpfUNGm9.d.ts → index-BRgBwiBM.d.ts} +179 -2
  18. package/dist/{index-hNuffoCo.d.cts → index-BuUCObcz.d.cts} +1167 -714
  19. package/dist/{index-De5B4r0l.d.ts → index-C7OdmKfs.d.ts} +1167 -714
  20. package/dist/{index-AooYZ0kF.d.cts → index-brLSTa0y.d.cts} +179 -2
  21. package/dist/index.cjs +1691 -969
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +4 -4
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +1445 -728
  26. package/dist/index.js.map +1 -1
  27. package/dist/indexer/index.cjs +6 -6
  28. package/dist/indexer/index.d.cts +5 -5
  29. package/dist/indexer/index.d.ts +5 -5
  30. package/dist/indexer/index.js +1 -1
  31. package/dist/react/index.cjs +30 -28
  32. package/dist/react/index.cjs.map +1 -1
  33. package/dist/react/index.d.cts +8 -4
  34. package/dist/react/index.d.ts +8 -4
  35. package/dist/react/index.js +30 -28
  36. package/dist/react/index.js.map +1 -1
  37. package/dist/{transfer-M3PKP4PY.cjs → transfer-AJWQANX7.cjs} +10 -10
  38. package/dist/{transfer-M3PKP4PY.cjs.map → transfer-AJWQANX7.cjs.map} +1 -1
  39. package/dist/{transfer-BGzySIhC.d.ts → transfer-BxiDgCvx.d.ts} +2 -0
  40. package/dist/{transfer-RA7R3KQY.js → transfer-SEC6K5A5.js} +4 -4
  41. package/dist/{transfer-RA7R3KQY.js.map → transfer-SEC6K5A5.js.map} +1 -1
  42. package/dist/{transfer-BhB-UuBP.d.cts → transfer-p-NXHdGY.d.cts} +2 -0
  43. package/package.json +3 -4
  44. package/src/contracts/interfaces/IUniversalPrivatePool.sol +52 -93
  45. package/src/deployments/11155111.json +28 -17
  46. package/src/deployments/31337.json +28 -14
  47. package/dist/chunk-5MK5R7M7.cjs.map +0 -1
  48. package/dist/chunk-632LPXPX.cjs +0 -49
  49. package/dist/chunk-632LPXPX.cjs.map +0 -1
  50. package/dist/chunk-TVF6FYTQ.js.map +0 -1
  51. package/dist/chunk-UMWY4ICQ.js +0 -43
  52. package/dist/chunk-UMWY4ICQ.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkUWW4GFZ3_cjs = require('../chunk-UWW4GFZ3.cjs');
3
+ var chunkJVFP4Q2B_cjs = require('../chunk-JVFP4Q2B.cjs');
4
4
  var chunkERQE57IA_cjs = require('../chunk-ERQE57IA.cjs');
5
5
  require('../chunk-G7VZBCD6.cjs');
6
6
 
@@ -8,23 +8,23 @@ require('../chunk-G7VZBCD6.cjs');
8
8
 
9
9
  Object.defineProperty(exports, "computeSearchTag", {
10
10
  enumerable: true,
11
- get: function () { return chunkUWW4GFZ3_cjs.computeSearchTag; }
11
+ get: function () { return chunkJVFP4Q2B_cjs.computeSearchTag; }
12
12
  });
13
13
  Object.defineProperty(exports, "makeRpcIndexer", {
14
14
  enumerable: true,
15
- get: function () { return chunkUWW4GFZ3_cjs.makeRpcIndexer; }
15
+ get: function () { return chunkJVFP4Q2B_cjs.makeRpcIndexer; }
16
16
  });
17
17
  Object.defineProperty(exports, "matchesSearchTag", {
18
18
  enumerable: true,
19
- get: function () { return chunkUWW4GFZ3_cjs.matchesSearchTag; }
19
+ get: function () { return chunkJVFP4Q2B_cjs.matchesSearchTag; }
20
20
  });
21
21
  Object.defineProperty(exports, "tryDecryptNote", {
22
22
  enumerable: true,
23
- get: function () { return chunkUWW4GFZ3_cjs.tryDecryptNote; }
23
+ get: function () { return chunkJVFP4Q2B_cjs.tryDecryptNote; }
24
24
  });
25
25
  Object.defineProperty(exports, "unpackNoteData", {
26
26
  enumerable: true,
27
- get: function () { return chunkUWW4GFZ3_cjs.unpackNoteData; }
27
+ get: function () { return chunkJVFP4Q2B_cjs.unpackNoteData; }
28
28
  });
29
29
  Object.defineProperty(exports, "createAutoAdapter", {
30
30
  enumerable: true,
@@ -1,10 +1,10 @@
1
- import { S as StorageAdapter } from '../index-AooYZ0kF.cjs';
2
- export { C as CommitmentInsertedArgs, a as IndexedNote, I as Indexer, f as IndexerState, L as LiveSyncConfig, b as NoteFilters, N as NoteStatus, j as NullifiedArgs, R as RpcIndexerConfig, h as SerializedNote, i as StealthTransactArgs, e as SyncConfig, d as SyncProgress, c as SyncResult, g as SyncState } from '../index-AooYZ0kF.cjs';
3
- import { _ as ___index_js } from '../index-hNuffoCo.cjs';
4
- export { m as makeRpcIndexer } from '../index-hNuffoCo.cjs';
1
+ import { S as StorageAdapter } from '../index-brLSTa0y.cjs';
2
+ export { C as CommitmentInsertedArgs, a as IndexedNote, I as Indexer, f as IndexerState, L as LiveSyncConfig, b as NoteFilters, N as NoteStatus, j as NullifiedArgs, R as RpcIndexerConfig, h as SerializedNote, i as StealthTransactArgs, e as SyncConfig, d as SyncProgress, c as SyncResult, g as SyncState } from '../index-brLSTa0y.cjs';
3
+ import { _ as ___index_js } from '../index-BuUCObcz.cjs';
4
+ export { m as makeRpcIndexer } from '../index-BuUCObcz.cjs';
5
5
  import { Hex } from 'viem';
6
6
  import { P as Point } from '../merkle-mteVOlDf.cjs';
7
- import '../transfer-BhB-UuBP.cjs';
7
+ import '../transfer-p-NXHdGY.cjs';
8
8
  import '../keccak-m31-B_AqBbRF.cjs';
9
9
  import '@permissionless-technologies/upc-sdk';
10
10
  import 'react/jsx-runtime';
@@ -1,10 +1,10 @@
1
- import { S as StorageAdapter } from '../index-CpfUNGm9.js';
2
- export { C as CommitmentInsertedArgs, a as IndexedNote, I as Indexer, f as IndexerState, L as LiveSyncConfig, b as NoteFilters, N as NoteStatus, j as NullifiedArgs, R as RpcIndexerConfig, h as SerializedNote, i as StealthTransactArgs, e as SyncConfig, d as SyncProgress, c as SyncResult, g as SyncState } from '../index-CpfUNGm9.js';
3
- import { _ as ___index_js } from '../index-De5B4r0l.js';
4
- export { m as makeRpcIndexer } from '../index-De5B4r0l.js';
1
+ import { S as StorageAdapter } from '../index-BRgBwiBM.js';
2
+ export { C as CommitmentInsertedArgs, a as IndexedNote, I as Indexer, f as IndexerState, L as LiveSyncConfig, b as NoteFilters, N as NoteStatus, j as NullifiedArgs, R as RpcIndexerConfig, h as SerializedNote, i as StealthTransactArgs, e as SyncConfig, d as SyncProgress, c as SyncResult, g as SyncState } from '../index-BRgBwiBM.js';
3
+ import { _ as ___index_js } from '../index-C7OdmKfs.js';
4
+ export { m as makeRpcIndexer } from '../index-C7OdmKfs.js';
5
5
  import { Hex } from 'viem';
6
6
  import { P as Point } from '../merkle-mteVOlDf.js';
7
- import '../transfer-BGzySIhC.js';
7
+ import '../transfer-BxiDgCvx.js';
8
8
  import '../keccak-m31-B_AqBbRF.js';
9
9
  import '@permissionless-technologies/upc-sdk';
10
10
  import 'react/jsx-runtime';
@@ -1,4 +1,4 @@
1
- export { computeSearchTag, makeRpcIndexer, matchesSearchTag, tryDecryptNote, unpackNoteData } from '../chunk-R4O6FOIN.js';
1
+ export { computeSearchTag, makeRpcIndexer, matchesSearchTag, tryDecryptNote, unpackNoteData } from '../chunk-5CZ7R4CT.js';
2
2
  export { createAutoAdapter, createIndexedDBAdapter, createLocalStorageAdapter, createMemoryAdapter, indexedDBAdapter, localStorageAdapter, memoryAdapter } from '../chunk-XV72HNHN.js';
3
3
  import '../chunk-Z6ZWNWWR.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -365,6 +365,8 @@ function UPPAccountProvider({
365
365
  const sdk = await loadSDK();
366
366
  const viewingSecret = masterKeys.viewingSecret;
367
367
  const spendingSecret = masterKeys.spendingSecret;
368
+ const scanFromBlock = BigInt(indexerConfig?.fromBlock ?? 0);
369
+ const swapModuleAddr = indexerConfig?.swapModuleAddress;
368
370
  const aesKeyHex = viem.keccak256(viem.toHex(viewingSecret, { size: 32 }));
369
371
  const aesKeyBytes = hexToBytes(aesKeyHex);
370
372
  const cryptoKey = await crypto.subtle.importKey(
@@ -394,7 +396,7 @@ function UPPAccountProvider({
394
396
  { name: "encryptedNote", type: "bytes", indexed: false }
395
397
  ]
396
398
  },
397
- fromBlock: 0n,
399
+ fromBlock: scanFromBlock,
398
400
  toBlock: "latest"
399
401
  });
400
402
  for (const log of shieldedLogs) {
@@ -425,7 +427,7 @@ function UPPAccountProvider({
425
427
  { name: "encryptedNote2", type: "bytes", indexed: false }
426
428
  ]
427
429
  },
428
- fromBlock: 0n,
430
+ fromBlock: scanFromBlock,
429
431
  toBlock: "latest"
430
432
  });
431
433
  try {
@@ -440,7 +442,7 @@ function UPPAccountProvider({
440
442
  { name: "timestamp", type: "uint256", indexed: false }
441
443
  ]
442
444
  },
443
- fromBlock: 0n,
445
+ fromBlock: scanFromBlock,
444
446
  toBlock: "latest"
445
447
  });
446
448
  for (const log of ciLogs) {
@@ -476,9 +478,9 @@ function UPPAccountProvider({
476
478
  } catch (e) {
477
479
  console.warn("[syncNotes] Failed to scan Transferred events:", e);
478
480
  }
479
- try {
481
+ if (swapModuleAddr) try {
480
482
  const filledLogs = await client.getLogs({
481
- address: contractAddress,
483
+ address: swapModuleAddr,
482
484
  event: {
483
485
  type: "event",
484
486
  name: "SwapOrderFilled",
@@ -493,7 +495,7 @@ function UPPAccountProvider({
493
495
  { name: "encryptedFillerNote", type: "bytes", indexed: false }
494
496
  ]
495
497
  },
496
- fromBlock: 0n,
498
+ fromBlock: scanFromBlock,
497
499
  toBlock: "latest"
498
500
  });
499
501
  for (const log of filledLogs) {
@@ -510,9 +512,9 @@ function UPPAccountProvider({
510
512
  } catch (e) {
511
513
  console.warn("[syncNotes] Failed to scan SwapOrderFilled events:", e);
512
514
  }
513
- try {
515
+ if (swapModuleAddr) try {
514
516
  const claimedLogs = await client.getLogs({
515
- address: contractAddress,
517
+ address: swapModuleAddr,
516
518
  event: {
517
519
  type: "event",
518
520
  name: "SwapOrderClaimed",
@@ -526,7 +528,7 @@ function UPPAccountProvider({
526
528
  { name: "encryptedRefundNote", type: "bytes", indexed: false }
527
529
  ]
528
530
  },
529
- fromBlock: 0n,
531
+ fromBlock: scanFromBlock,
530
532
  toBlock: "latest"
531
533
  });
532
534
  for (const log of claimedLogs) {
@@ -553,9 +555,9 @@ function UPPAccountProvider({
553
555
  } catch (e) {
554
556
  console.warn("[syncNotes] Failed to scan SwapOrderClaimed events:", e);
555
557
  }
556
- try {
558
+ if (swapModuleAddr) try {
557
559
  const cancelledLogs = await client.getLogs({
558
- address: contractAddress,
560
+ address: swapModuleAddr,
559
561
  event: {
560
562
  type: "event",
561
563
  name: "SwapOrderCancelled",
@@ -566,7 +568,7 @@ function UPPAccountProvider({
566
568
  { name: "encryptedRefundNote", type: "bytes", indexed: false }
567
569
  ]
568
570
  },
569
- fromBlock: 0n,
571
+ fromBlock: scanFromBlock,
570
572
  toBlock: "latest"
571
573
  });
572
574
  for (const log of cancelledLogs) {
@@ -679,7 +681,7 @@ function UPPAccountProvider({
679
681
  { name: "timestamp", type: "uint256", indexed: false }
680
682
  ]
681
683
  },
682
- fromBlock: 0n,
684
+ fromBlock: scanFromBlock,
683
685
  toBlock: "latest"
684
686
  });
685
687
  for (const log of ciLogs) {
@@ -795,7 +797,7 @@ function UPPAccountProvider({
795
797
  // Note: `notes` is intentionally NOT in the dependency array to prevent
796
798
  // sync loops. The callback reads notes from noteStoreRef.current directly.
797
799
  // eslint-disable-next-line react-hooks/exhaustive-deps
798
- [masterKeys, cryptoReady, persistNotes]
800
+ [masterKeys, cryptoReady, persistNotes, indexerConfig?.fromBlock]
799
801
  );
800
802
  const startLiveSync = react.useCallback(
801
803
  (contractAddress, client) => {
@@ -1711,7 +1713,7 @@ function usePoolTransfer(config) {
1711
1713
  const recipientNote = await createNoteForSelf(amount, origin, token);
1712
1714
  const changeNote = await createNoteForSelf(changeAmount, origin, token);
1713
1715
  const [transferModule, proofModule, aspModule] = await Promise.all([
1714
- import('../transfer-M3PKP4PY.cjs'),
1716
+ import('../transfer-AJWQANX7.cjs'),
1715
1717
  import('../proof-X3MVQFFZ.cjs'),
1716
1718
  import('../asp-CUE3NMBN.cjs')
1717
1719
  ]);
@@ -1869,7 +1871,7 @@ function useWithdraw(config) {
1869
1871
  const token = BigInt(selectedNote.token);
1870
1872
  setStage("creating_outputs");
1871
1873
  const [transferModule, proofModule, sdk] = await Promise.all([
1872
- import('../transfer-M3PKP4PY.cjs'),
1874
+ import('../transfer-AJWQANX7.cjs'),
1873
1875
  import('../proof-X3MVQFFZ.cjs'),
1874
1876
  import('../index.cjs')
1875
1877
  ]);
@@ -2129,7 +2131,7 @@ function useSwapOrderBook(config) {
2129
2131
  setError(null);
2130
2132
  try {
2131
2133
  const logs = await config.publicClient.getLogs({
2132
- address: config.poolAddress,
2134
+ address: config.swapModuleAddress,
2133
2135
  event: chunkIYRCJAME_cjs.SWAP_ORDER_PLACED_EVENT,
2134
2136
  fromBlock: config.fromBlock ?? 0n,
2135
2137
  toBlock: "latest"
@@ -2155,7 +2157,7 @@ function useSwapOrderBook(config) {
2155
2157
  for (const order of parsedOrders) {
2156
2158
  try {
2157
2159
  const result = await config.publicClient.readContract({
2158
- address: config.poolAddress,
2160
+ address: config.swapModuleAddress,
2159
2161
  abi: SWAP_ORDERS_ABI,
2160
2162
  functionName: "swapOrders",
2161
2163
  args: [order.orderId]
@@ -2179,7 +2181,7 @@ function useSwapOrderBook(config) {
2179
2181
  } finally {
2180
2182
  setIsLoading(false);
2181
2183
  }
2182
- }, [config.publicClient, config.poolAddress, config.sellToken, config.buyToken, config.acceptableAspIds, config.fromBlock]);
2184
+ }, [config.publicClient, config.swapModuleAddress, config.sellToken, config.buyToken, config.acceptableAspIds, config.fromBlock]);
2183
2185
  react.useEffect(() => {
2184
2186
  refresh();
2185
2187
  const interval = config.pollInterval ?? 15e3;
@@ -2247,7 +2249,7 @@ function useSwap(config) {
2247
2249
  }
2248
2250
  setStage("creating_outputs");
2249
2251
  const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
2250
- import('../transfer-M3PKP4PY.cjs'),
2252
+ import('../transfer-AJWQANX7.cjs'),
2251
2253
  import('../proof-X3MVQFFZ.cjs'),
2252
2254
  import('../index.cjs'),
2253
2255
  import('../asp-CUE3NMBN.cjs')
@@ -2395,7 +2397,7 @@ function useSwap(config) {
2395
2397
  }
2396
2398
  setStage("creating_outputs");
2397
2399
  const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
2398
- import('../transfer-M3PKP4PY.cjs'),
2400
+ import('../transfer-AJWQANX7.cjs'),
2399
2401
  import('../proof-X3MVQFFZ.cjs'),
2400
2402
  import('../index.cjs'),
2401
2403
  import('../asp-CUE3NMBN.cjs')
@@ -2633,7 +2635,7 @@ function useSwap(config) {
2633
2635
  createNoteForSelf(changeAmount, origin, token)
2634
2636
  ]);
2635
2637
  const [transferModule, proofModule, aspModule] = await Promise.all([
2636
- import('../transfer-M3PKP4PY.cjs'),
2638
+ import('../transfer-AJWQANX7.cjs'),
2637
2639
  import('../proof-X3MVQFFZ.cjs'),
2638
2640
  import('../asp-CUE3NMBN.cjs')
2639
2641
  ]);
@@ -2831,18 +2833,18 @@ function useCircuitCache(baseUrl) {
2831
2833
  }
2832
2834
  function usePrivateBalance(config) {
2833
2835
  const { unspentNotes, syncNotes, isSyncing: isNoteSyncing } = useUPPAccount();
2834
- const { poolAddress, publicClient, walletAddress, tokenList, autoSync = true, fromBlock = 0n } = config;
2836
+ const { poolAddress, publicClient, walletAddress, tokenList, autoSync = true, fromBlock = 0n, swapModuleAddress } = config;
2835
2837
  const [unclaimedOrders, setUnclaimedOrders] = react.useState(/* @__PURE__ */ new Map());
2836
2838
  const [isOrderSyncing, setIsOrderSyncing] = react.useState(false);
2837
2839
  const hasAutoSynced = react.useRef(false);
2838
2840
  const configRef = react.useRef(config);
2839
2841
  configRef.current = config;
2840
2842
  const syncUnclaimedOrders = react.useCallback(async () => {
2841
- if (!publicClient || !poolAddress) return;
2843
+ if (!publicClient || !swapModuleAddress) return;
2842
2844
  setIsOrderSyncing(true);
2843
2845
  try {
2844
2846
  const placedLogs = await publicClient.getLogs({
2845
- address: poolAddress,
2847
+ address: swapModuleAddress,
2846
2848
  event: chunkIYRCJAME_cjs.SWAP_ORDER_PLACED_EVENT,
2847
2849
  fromBlock,
2848
2850
  toBlock: "latest"
@@ -2859,7 +2861,7 @@ function usePrivateBalance(config) {
2859
2861
  });
2860
2862
  }
2861
2863
  const filledLogs = await publicClient.getLogs({
2862
- address: poolAddress,
2864
+ address: swapModuleAddress,
2863
2865
  event: chunkIYRCJAME_cjs.SWAP_ORDER_FILLED_EVENT,
2864
2866
  fromBlock,
2865
2867
  toBlock: "latest"
@@ -2878,7 +2880,7 @@ function usePrivateBalance(config) {
2878
2880
  }
2879
2881
  }
2880
2882
  const claimedLogs = await publicClient.getLogs({
2881
- address: poolAddress,
2883
+ address: swapModuleAddress,
2882
2884
  event: chunkIYRCJAME_cjs.SWAP_ORDER_CLAIMED_EVENT,
2883
2885
  fromBlock,
2884
2886
  toBlock: "latest"
@@ -2887,7 +2889,7 @@ function usePrivateBalance(config) {
2887
2889
  orders.delete(log.args.orderId.toLowerCase());
2888
2890
  }
2889
2891
  const cancelledLogs = await publicClient.getLogs({
2890
- address: poolAddress,
2892
+ address: swapModuleAddress,
2891
2893
  event: chunkIYRCJAME_cjs.SWAP_ORDER_CANCELLED_EVENT,
2892
2894
  fromBlock,
2893
2895
  toBlock: "latest"