@permissionless-technologies/upp-sdk 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -638,6 +638,8 @@ interface SplitNoteParams {
638
638
  targetAmount: bigint;
639
639
  /** ASP ID to use for the proof (defaults to DEMO_ASP_ID if not provided) */
640
640
  aspId?: bigint;
641
+ /** Pre-fetched ASP proof from the service */
642
+ aspProof?: ASPProofParam;
641
643
  }
642
644
  interface SplitNoteBuildData {
643
645
  /** Transfer proof for contract call */
@@ -689,6 +691,12 @@ interface UseSwapReturn {
689
691
  /** Reset state */
690
692
  reset: () => void;
691
693
  }
694
+ /** Pre-fetched ASP proof from the platform's ASP service */
695
+ interface ASPProofParam {
696
+ root: bigint;
697
+ pathElements: bigint[];
698
+ pathIndices: number[];
699
+ }
692
700
  interface PlaceOrderParams {
693
701
  /** Token to sell */
694
702
  sellToken: Address;
@@ -702,8 +710,10 @@ interface PlaceOrderParams {
702
710
  requiredFillerAspId?: bigint;
703
711
  /** Number of blocks until expiry */
704
712
  expiryBlocks: bigint;
705
- /** ASP ID — must be a registered personal ASP */
713
+ /** ASP ID */
706
714
  aspId: bigint;
715
+ /** Pre-fetched ASP proof from the service. If omitted, falls back to local computation. */
716
+ aspProof?: ASPProofParam;
707
717
  /** Explicit note to spend (skips note selection). Used after auto-split. */
708
718
  noteOverride?: ShieldedNote;
709
719
  }
@@ -718,8 +728,10 @@ interface FillOrderParams {
718
728
  sellToken: Address;
719
729
  /** The order's buyToken (filler pays this) */
720
730
  buyToken: Address;
721
- /** ASP ID — must be a registered personal ASP */
731
+ /** ASP ID */
722
732
  aspId: bigint;
733
+ /** Pre-fetched ASP proof from the service. If omitted, falls back to local computation. */
734
+ aspProof?: ASPProofParam;
723
735
  /** Explicit note to spend (skips note selection). Used after auto-split. */
724
736
  noteOverride?: ShieldedNote;
725
737
  }
@@ -638,6 +638,8 @@ interface SplitNoteParams {
638
638
  targetAmount: bigint;
639
639
  /** ASP ID to use for the proof (defaults to DEMO_ASP_ID if not provided) */
640
640
  aspId?: bigint;
641
+ /** Pre-fetched ASP proof from the service */
642
+ aspProof?: ASPProofParam;
641
643
  }
642
644
  interface SplitNoteBuildData {
643
645
  /** Transfer proof for contract call */
@@ -689,6 +691,12 @@ interface UseSwapReturn {
689
691
  /** Reset state */
690
692
  reset: () => void;
691
693
  }
694
+ /** Pre-fetched ASP proof from the platform's ASP service */
695
+ interface ASPProofParam {
696
+ root: bigint;
697
+ pathElements: bigint[];
698
+ pathIndices: number[];
699
+ }
692
700
  interface PlaceOrderParams {
693
701
  /** Token to sell */
694
702
  sellToken: Address;
@@ -702,8 +710,10 @@ interface PlaceOrderParams {
702
710
  requiredFillerAspId?: bigint;
703
711
  /** Number of blocks until expiry */
704
712
  expiryBlocks: bigint;
705
- /** ASP ID — must be a registered personal ASP */
713
+ /** ASP ID */
706
714
  aspId: bigint;
715
+ /** Pre-fetched ASP proof from the service. If omitted, falls back to local computation. */
716
+ aspProof?: ASPProofParam;
707
717
  /** Explicit note to spend (skips note selection). Used after auto-split. */
708
718
  noteOverride?: ShieldedNote;
709
719
  }
@@ -718,8 +728,10 @@ interface FillOrderParams {
718
728
  sellToken: Address;
719
729
  /** The order's buyToken (filler pays this) */
720
730
  buyToken: Address;
721
- /** ASP ID — must be a registered personal ASP */
731
+ /** ASP ID */
722
732
  aspId: bigint;
733
+ /** Pre-fetched ASP proof from the service. If omitted, falls back to local computation. */
734
+ aspProof?: ASPProofParam;
723
735
  /** Explicit note to spend (skips note selection). Used after auto-split. */
724
736
  noteOverride?: ShieldedNote;
725
737
  }
@@ -1601,7 +1601,7 @@ function usePoolTransfer(config) {
1601
1601
  const recipientNote = await createNoteForSelf(amount, origin, token);
1602
1602
  const changeNote = await createNoteForSelf(changeAmount, origin, token);
1603
1603
  const [transferModule, proofModule, aspModule] = await Promise.all([
1604
- import('../transfer-QK3QUIA3.js'),
1604
+ import('../transfer-F6YOQTUL.js'),
1605
1605
  import('../proof-C4YBP6RY.js'),
1606
1606
  import('../asp-ZA3RGN7G.js')
1607
1607
  ]);
@@ -1760,7 +1760,7 @@ function useWithdraw(config) {
1760
1760
  const token = BigInt(selectedNote.token);
1761
1761
  setStage("creating_outputs");
1762
1762
  const [transferModule, proofModule, sdk] = await Promise.all([
1763
- import('../transfer-QK3QUIA3.js'),
1763
+ import('../transfer-F6YOQTUL.js'),
1764
1764
  import('../proof-C4YBP6RY.js'),
1765
1765
  import('../index.js')
1766
1766
  ]);
@@ -1988,6 +1988,7 @@ function storePersonalASPId(chainId, address, aspId) {
1988
1988
  }
1989
1989
  init_poseidon();
1990
1990
  var STATE_TREE_DEPTH2 = 32;
1991
+ var ASP_TREE_DEPTH3 = 20;
1991
1992
  function padToDepth2(arr, padValue, depth) {
1992
1993
  if (arr.length >= depth) return arr.slice(0, depth);
1993
1994
  return [...arr, ...Array(depth - arr.length).fill(padValue)];
@@ -2139,7 +2140,7 @@ function useSwap(config) {
2139
2140
  }
2140
2141
  setStage("creating_outputs");
2141
2142
  const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
2142
- import('../transfer-QK3QUIA3.js'),
2143
+ import('../transfer-F6YOQTUL.js'),
2143
2144
  import('../proof-C4YBP6RY.js'),
2144
2145
  import('../index.js'),
2145
2146
  import('../asp-ZA3RGN7G.js')
@@ -2186,7 +2187,7 @@ function useSwap(config) {
2186
2187
  BigInt(actualLeafIndex),
2187
2188
  storedCommitment
2188
2189
  ]);
2189
- const aspProofData = await generateASPProof2(aspId, origin, cfg.aspApprovedOrigins);
2190
+ const aspProofData = params.aspProof ? { aspId, aspRoot: params.aspProof.root, aspPathElements: params.aspProof.pathElements, aspPathIndices: params.aspProof.pathIndices } : await generateASPProof2(aspId, origin, cfg.aspApprovedOrigins);
2190
2191
  const circuitInputs = {
2191
2192
  stateRoot: stateRootBI.toString(),
2192
2193
  aspRoot: aspProofData.aspRoot.toString(),
@@ -2202,8 +2203,8 @@ function useSwap(config) {
2202
2203
  inputLeafIndex: actualLeafIndex.toString(),
2203
2204
  inputPathElements: padToDepth2(merkleProof.pathElements.map(String), "0", STATE_TREE_DEPTH2),
2204
2205
  inputPathIndices: padToDepth2(merkleProof.pathIndices.map(String), "0", STATE_TREE_DEPTH2),
2205
- aspPathElements: aspProofData.aspPathElements.map(String),
2206
- aspPathIndices: aspProofData.aspPathIndices.map(String)
2206
+ aspPathElements: padToDepth2(aspProofData.aspPathElements.map(String), "0", ASP_TREE_DEPTH3),
2207
+ aspPathIndices: padToDepth2(aspProofData.aspPathIndices.map(String), "0", ASP_TREE_DEPTH3)
2207
2208
  };
2208
2209
  const { proof } = await generateUPPProof(
2209
2210
  "withdraw",
@@ -2291,7 +2292,7 @@ function useSwap(config) {
2291
2292
  }
2292
2293
  setStage("creating_outputs");
2293
2294
  const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
2294
- import('../transfer-QK3QUIA3.js'),
2295
+ import('../transfer-F6YOQTUL.js'),
2295
2296
  import('../proof-C4YBP6RY.js'),
2296
2297
  import('../index.js'),
2297
2298
  import('../asp-ZA3RGN7G.js')
@@ -2344,7 +2345,7 @@ function useSwap(config) {
2344
2345
  BigInt(actualLeafIndex),
2345
2346
  storedCommitmentF
2346
2347
  ]);
2347
- const aspProofData = await generateASPProof2(aspId, origin, cfg.aspApprovedOrigins);
2348
+ const aspProofData = params.aspProof ? { aspId, aspRoot: params.aspProof.root, aspPathElements: params.aspProof.pathElements, aspPathIndices: params.aspProof.pathIndices } : await generateASPProof2(aspId, origin, cfg.aspApprovedOrigins);
2348
2349
  const circuitInputs = {
2349
2350
  stateRoot: stateRootBI.toString(),
2350
2351
  aspRoot: aspProofData.aspRoot.toString(),
@@ -2360,8 +2361,8 @@ function useSwap(config) {
2360
2361
  inputLeafIndex: actualLeafIndex.toString(),
2361
2362
  inputPathElements: padToDepth2(merkleProof.pathElements.map(String), "0", STATE_TREE_DEPTH2),
2362
2363
  inputPathIndices: padToDepth2(merkleProof.pathIndices.map(String), "0", STATE_TREE_DEPTH2),
2363
- aspPathElements: aspProofData.aspPathElements.map(String),
2364
- aspPathIndices: aspProofData.aspPathIndices.map(String)
2364
+ aspPathElements: padToDepth2(aspProofData.aspPathElements.map(String), "0", ASP_TREE_DEPTH3),
2365
+ aspPathIndices: padToDepth2(aspProofData.aspPathIndices.map(String), "0", ASP_TREE_DEPTH3)
2365
2366
  };
2366
2367
  const { proof } = await generateUPPProof(
2367
2368
  "withdraw",
@@ -2521,7 +2522,7 @@ function useSwap(config) {
2521
2522
  createNoteForSelf(changeAmount, origin, token)
2522
2523
  ]);
2523
2524
  const [transferModule, proofModule, aspModule] = await Promise.all([
2524
- import('../transfer-QK3QUIA3.js'),
2525
+ import('../transfer-F6YOQTUL.js'),
2525
2526
  import('../proof-C4YBP6RY.js'),
2526
2527
  import('../asp-ZA3RGN7G.js')
2527
2528
  ]);
@@ -2541,7 +2542,7 @@ function useSwap(config) {
2541
2542
  token
2542
2543
  };
2543
2544
  const [noteProof] = await getMerkleProofsForNotes([spendableNote], leaves, tree);
2544
- const aspProof = await generateASPProof2(splitAspId ?? DEMO_ASP_ID, origin, cfg.aspApprovedOrigins);
2545
+ const aspProof = params.aspProof ? { aspId: splitAspId ?? DEMO_ASP_ID, aspRoot: params.aspProof.root, aspPathElements: params.aspProof.pathElements, aspPathIndices: params.aspProof.pathIndices } : await generateASPProof2(splitAspId ?? DEMO_ASP_ID, origin, cfg.aspApprovedOrigins);
2545
2546
  setStage("generating_proof");
2546
2547
  const exactNoteWithAmount = { ...exactNoteData, amount: targetAmount };
2547
2548
  const changeNoteWithAmount = { ...changeNoteData, amount: changeAmount };