@cloak.dev/sdk 0.1.2 → 0.1.4

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 (3) hide show
  1. package/dist/index.cjs +130 -78
  2. package/dist/index.js +130 -78
  3. package/package.json +10 -10
package/dist/index.cjs CHANGED
@@ -4978,6 +4978,7 @@ async function buildMerkleTree(commitments, height = MERKLE_TREE_HEIGHT2) {
4978
4978
 
4979
4979
  // src/utils/relay-client.ts
4980
4980
  var import_bs58 = __toESM(require("bs58"), 1);
4981
+ var bs58 = import_bs58.default.default || import_bs58.default;
4981
4982
  var TRANSACT_TAG = 0;
4982
4983
  var TRANSACT_SWAP_TAG = 1;
4983
4984
  var DEPOSIT_TAG = 1;
@@ -5177,7 +5178,7 @@ async function buildMerkleTreeFromChain(connection, programId, merkleTree, onPro
5177
5178
  for (const ix of tx.transaction.message.instructions) {
5178
5179
  if (!("programId" in ix) || !("data" in ix)) continue;
5179
5180
  if (ix.programId.toBase58() !== programIdBase58) continue;
5180
- const data = import_bs58.default.decode(ix.data);
5181
+ const data = bs58.decode(ix.data);
5181
5182
  const extracted = extractCommitmentsFromInstruction(data);
5182
5183
  for (const commitment of extracted) {
5183
5184
  commitments.push(BigInt("0x" + Buffer.from(commitment).toString("hex")));
@@ -6083,6 +6084,7 @@ function collectLookupCandidatesFromInstructions(instructions, payer, existingAl
6083
6084
  }
6084
6085
  async function createEphemeralALT(connection, depositor, onProgress, additionalAddresses = []) {
6085
6086
  const MAX_ALT_ADDRESSES = 20;
6087
+ const MAX_ALT_CREATE_RETRIES = 3;
6086
6088
  const altAddresses = dedupePubkeys([
6087
6089
  ...getCommonALTAddresses(),
6088
6090
  ...additionalAddresses
@@ -6093,46 +6095,59 @@ async function createEphemeralALT(connection, depositor, onProgress, additionalA
6093
6095
  `ALT address set truncated (${addressesForCreate.length}/${altAddresses.length}); packet savings may be limited.`
6094
6096
  );
6095
6097
  }
6096
- const slot = await connection.getSlot();
6097
- const [createIx, altAddress] = import_web37.AddressLookupTableProgram.createLookupTable({
6098
- authority: depositor.publicKey,
6099
- payer: depositor.publicKey,
6100
- recentSlot: slot
6101
- });
6102
- const extendIx = import_web37.AddressLookupTableProgram.extendLookupTable({
6103
- payer: depositor.publicKey,
6104
- authority: depositor.publicKey,
6105
- lookupTable: altAddress,
6106
- addresses: addressesForCreate
6107
- });
6108
- const tx = new import_web37.Transaction().add(createIx).add(extendIx);
6109
- const { blockhash } = await connection.getLatestBlockhash();
6110
- tx.recentBlockhash = blockhash;
6111
- tx.feePayer = depositor.publicKey;
6112
- if (depositor.keypair) {
6113
- await (0, import_web37.sendAndConfirmTransaction)(connection, tx, [depositor.keypair], { commitment: "confirmed" });
6114
- } else if (depositor.signTransaction) {
6115
- const signedTx = await depositor.signTransaction(tx);
6116
- const sig = await connection.sendRawTransaction(signedTx.serialize());
6117
- const latestBH = await connection.getLatestBlockhash();
6118
- await connection.confirmTransaction({ signature: sig, blockhash: latestBH.blockhash, lastValidBlockHeight: latestBH.lastValidBlockHeight }, "confirmed");
6119
- } else {
6120
- throw new Error("Cannot create ALT: no signing method provided");
6121
- }
6122
- for (let i = 0; i < 30; i++) {
6123
- await new Promise((r) => setTimeout(r, 500));
6124
- const result = await connection.getAddressLookupTable(altAddress);
6125
- if (result.value && result.value.isActive()) {
6126
- onProgress?.(`ALT created and active: ${altAddress.toBase58()}`);
6127
- return [result.value];
6098
+ for (let altAttempt = 0; altAttempt < MAX_ALT_CREATE_RETRIES; altAttempt++) {
6099
+ try {
6100
+ const slot = await connection.getSlot("finalized");
6101
+ const [createIx, altAddress] = import_web37.AddressLookupTableProgram.createLookupTable({
6102
+ authority: depositor.publicKey,
6103
+ payer: depositor.publicKey,
6104
+ recentSlot: slot
6105
+ });
6106
+ const extendIx = import_web37.AddressLookupTableProgram.extendLookupTable({
6107
+ payer: depositor.publicKey,
6108
+ authority: depositor.publicKey,
6109
+ lookupTable: altAddress,
6110
+ addresses: addressesForCreate
6111
+ });
6112
+ const tx = new import_web37.Transaction().add(createIx).add(extendIx);
6113
+ const { blockhash } = await connection.getLatestBlockhash();
6114
+ tx.recentBlockhash = blockhash;
6115
+ tx.feePayer = depositor.publicKey;
6116
+ if (depositor.keypair) {
6117
+ await (0, import_web37.sendAndConfirmTransaction)(connection, tx, [depositor.keypair], { commitment: "confirmed" });
6118
+ } else if (depositor.signTransaction) {
6119
+ const signedTx = await depositor.signTransaction(tx);
6120
+ const sig = await connection.sendRawTransaction(signedTx.serialize());
6121
+ const latestBH = await connection.getLatestBlockhash();
6122
+ await connection.confirmTransaction({ signature: sig, blockhash: latestBH.blockhash, lastValidBlockHeight: latestBH.lastValidBlockHeight }, "confirmed");
6123
+ } else {
6124
+ throw new Error("Cannot create ALT: no signing method provided");
6125
+ }
6126
+ for (let i = 0; i < 30; i++) {
6127
+ await new Promise((r) => setTimeout(r, 500));
6128
+ const result = await connection.getAddressLookupTable(altAddress);
6129
+ if (result.value && result.value.isActive()) {
6130
+ onProgress?.(`ALT created and active: ${altAddress.toBase58()}`);
6131
+ return [result.value];
6132
+ }
6133
+ }
6134
+ const finalResult = await connection.getAddressLookupTable(altAddress);
6135
+ if (finalResult.value) {
6136
+ onProgress?.("ALT created (activation pending)");
6137
+ return [finalResult.value];
6138
+ }
6139
+ throw new Error("Failed to create ALT: not active after 15 seconds");
6140
+ } catch (err) {
6141
+ const msg = err?.message ?? String(err);
6142
+ if (msg.includes("not a recent slot") && altAttempt < MAX_ALT_CREATE_RETRIES - 1) {
6143
+ onProgress?.(`ALT creation failed (stale slot), retrying (${altAttempt + 2}/${MAX_ALT_CREATE_RETRIES})...`);
6144
+ await new Promise((r) => setTimeout(r, 2e3));
6145
+ continue;
6146
+ }
6147
+ throw err;
6128
6148
  }
6129
6149
  }
6130
- const finalResult = await connection.getAddressLookupTable(altAddress);
6131
- if (finalResult.value) {
6132
- onProgress?.("ALT created (activation pending)");
6133
- return [finalResult.value];
6134
- }
6135
- throw new Error("Failed to create ALT: not active after 15 seconds");
6150
+ throw new Error(`Failed to create ALT after ${MAX_ALT_CREATE_RETRIES} retries`);
6136
6151
  }
6137
6152
  async function submitTransactionDirect(connection, programId, depositor, proofBytes, publicInputsBytes, nullifiers, mint, recipient, riskOracleQueue, riskQuoteUrl, getRiskQuoteInstruction, onProgress, addressLookupTableAccounts, rangeApiKey, encryptedNoteBytes, relayUrl, altAddresses) {
6138
6153
  onProgress?.("Building transaction...");
@@ -6163,6 +6178,10 @@ async function submitTransactionDirect(connection, programId, depositor, proofBy
6163
6178
  onProgress?.("Creating address lookup table (chain notes require v0 tx to fit)...");
6164
6179
  addressLookupTableAccounts = await createEphemeralALT(connection, depositor, onProgress);
6165
6180
  }
6181
+ if (isDeposit && isSplPool && (!addressLookupTableAccounts || addressLookupTableAccounts.length === 0)) {
6182
+ onProgress?.("Creating address lookup table (SPL deposit requires v0 tx)...");
6183
+ addressLookupTableAccounts = await createEphemeralALT(connection, depositor, onProgress);
6184
+ }
6166
6185
  const publicAmountBytes = publicInputsBytes.slice(32, 40);
6167
6186
  const publicAmountBuffer = Buffer.from(publicAmountBytes);
6168
6187
  const publicAmount = publicAmountBuffer.readBigInt64LE(0);
@@ -6797,7 +6816,7 @@ async function transact(params, options) {
6797
6816
  }
6798
6817
  merkleTree = null;
6799
6818
  }
6800
- if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree)) {
6819
+ if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree) && !hasCachedTree) {
6801
6820
  try {
6802
6821
  const shouldRequestRelaySync = forceSync || requiredRelayIndex >= 0;
6803
6822
  const syncTimeoutMs = shouldRequestRelaySync ? Math.min(3e4, relayRequestTimeoutMs()) : 3500;
@@ -6822,7 +6841,7 @@ async function transact(params, options) {
6822
6841
  merkleTree = null;
6823
6842
  }
6824
6843
  }
6825
- if (merkleTree && treeState) {
6844
+ if (merkleTree && treeState && !hasCachedTree) {
6826
6845
  const relayRoot = merkleTree.root().toString(16).padStart(64, "0");
6827
6846
  const lengthDiff = treeState.nextIndex - merkleTree.length;
6828
6847
  if (merkleTree.length === 0) {
@@ -6953,7 +6972,7 @@ async function transact(params, options) {
6953
6972
  const disableNearTipFallbackEnv = typeof process !== "undefined" && !!process.env && (process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "1" || process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "true");
6954
6973
  const hasSiblingHints = !!utxo.siblingCommitment || !!utxo.leftSiblingCommitment;
6955
6974
  const baseNearTipEligible = chainDistanceFromTip !== null && chainDistanceFromTip >= 0 && chainDistanceFromTip <= nearTipMaxDistance;
6956
- const allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
6975
+ let allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
6957
6976
  if (!relayTreeDisabledForMint && !useSiblingInfo) {
6958
6977
  onProgress?.(`Relay tree missing index ${utxo.index} (length: ${treeLength}) with sibling cache disabled; proof may require retry after relay sync.`);
6959
6978
  } else if (!relayTreeDisabledForMint && relayUrl && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
@@ -6964,9 +6983,10 @@ async function transact(params, options) {
6964
6983
  onProgress?.(`Relay tree is lagging (missing index ${utxo.index}, length: ${treeLength}); using guarded on-chain proof fallback.`);
6965
6984
  }
6966
6985
  if (relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
6967
- throw new Error(
6968
- `Relay tree missing required commitment index ${utxo.index} (tree length: ${treeLength}); waiting for relay sync is required.`
6986
+ onProgress?.(
6987
+ `Relay tree missing index ${utxo.index} (tree length: ${treeLength}) \u2014 falling through to on-chain proof.`
6969
6988
  );
6989
+ allowNearTipOnChainFallback = true;
6970
6990
  }
6971
6991
  if (allowNearTipOnChainFallback && relayTreeDisabledForMint) {
6972
6992
  onProgress?.(
@@ -7200,11 +7220,19 @@ async function transact(params, options) {
7200
7220
  onProgress?.(`Merkle proof error (stale sibling data), will regenerate with fresh tree...`);
7201
7221
  lastError = new Error(`Circuit assertion failed: ${errorMsg}`);
7202
7222
  if (forceChainIndexing) {
7203
- onProgress?.("On-chain fallback proof failed; returning to relay-sync mode.");
7204
- forceChainIndexing = false;
7223
+ onProgress?.("On-chain frontier proof failed; escalating to full chain tree rebuild...");
7224
+ try {
7225
+ merkleTree = await buildMerkleTreeFromChain(connection, programId, pdas.merkleTree, onProgress);
7226
+ onProgress?.(`Chain tree rebuilt with ${merkleTree.length} leaves.`);
7227
+ } catch (chainBuildErr) {
7228
+ onProgress?.(`Chain tree rebuild failed (${chainBuildErr?.message?.slice(0, 80)}); returning to relay-sync mode.`);
7229
+ forceChainIndexing = false;
7230
+ merkleTree = null;
7231
+ }
7232
+ } else {
7233
+ merkleTree = null;
7205
7234
  }
7206
7235
  treeState = null;
7207
- merkleTree = null;
7208
7236
  useSiblingInfo = false;
7209
7237
  const waitMs = Math.min(retryDelayMs * Math.pow(2, Math.min(submissionAttempts, 4)), 5e3);
7210
7238
  if (waitMs > 0) {
@@ -7551,19 +7579,26 @@ async function transact(params, options) {
7551
7579
  throw new Error(`Transaction failed: ${lastError.message}`);
7552
7580
  }
7553
7581
  if (relayUrl && outputCommitments.length >= 2) {
7554
- const reconcileSeedIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0 ? commitmentIndices : lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
7555
- const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
7556
- relayUrl,
7557
- mint,
7558
- reconcileSeedIndices,
7559
- [outputCommitments[0], outputCommitments[1]],
7560
- onProgress
7561
- );
7562
- if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
7582
+ const hasOnChainIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0;
7583
+ if (!hasOnChainIndices) {
7584
+ const reconcileSeedIndices = lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
7585
+ const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
7586
+ relayUrl,
7587
+ mint,
7588
+ reconcileSeedIndices,
7589
+ [outputCommitments[0], outputCommitments[1]],
7590
+ onProgress
7591
+ );
7592
+ if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
7593
+ onProgress?.(
7594
+ `Adjusted commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
7595
+ );
7596
+ commitmentIndices = reconciledIndices;
7597
+ }
7598
+ } else {
7563
7599
  onProgress?.(
7564
- `Adjusted commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
7600
+ `Using on-chain commitment indices [${commitmentIndices[0]}, ${commitmentIndices[1]}] (skipping relay reconciliation).`
7565
7601
  );
7566
- commitmentIndices = reconciledIndices;
7567
7602
  }
7568
7603
  }
7569
7604
  const siblingCommitments = [
@@ -7916,7 +7951,7 @@ async function swapUtxo(params, options) {
7916
7951
  }
7917
7952
  merkleTree = null;
7918
7953
  }
7919
- if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree)) {
7954
+ if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree) && !hasCachedTree) {
7920
7955
  try {
7921
7956
  const shouldRequestRelaySync = forceSync || requiredRelayIndex >= 0;
7922
7957
  const syncTimeoutMs = shouldRequestRelaySync ? Math.min(3e4, relayRequestTimeoutMs()) : 3500;
@@ -7941,7 +7976,7 @@ async function swapUtxo(params, options) {
7941
7976
  merkleTree = null;
7942
7977
  }
7943
7978
  }
7944
- if (merkleTree && merkleState) {
7979
+ if (merkleTree && merkleState && !hasCachedTree) {
7945
7980
  const relayRoot = merkleTree.root().toString(16).padStart(64, "0");
7946
7981
  const lengthDiff = merkleState.nextIndex - merkleTree.length;
7947
7982
  if (merkleTree.length === 0) {
@@ -8069,7 +8104,7 @@ async function swapUtxo(params, options) {
8069
8104
  const disableNearTipFallbackEnv = typeof process !== "undefined" && !!process.env && (process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "1" || process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "true");
8070
8105
  const hasSiblingHints = !!utxo.siblingCommitment || !!utxo.leftSiblingCommitment;
8071
8106
  const baseNearTipEligible = chainDistanceFromTip !== null && chainDistanceFromTip >= 0 && chainDistanceFromTip <= nearTipMaxDistance;
8072
- const allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
8107
+ let allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
8073
8108
  if (!relayTreeDisabledForMint && !useSiblingInfo) {
8074
8109
  onProgress?.(`Relay tree missing index ${utxo.index} (length: ${treeLength}) with sibling cache disabled; proof may require retry after relay sync.`);
8075
8110
  } else if (!relayTreeDisabledForMint && relayUrl && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
@@ -8080,9 +8115,10 @@ async function swapUtxo(params, options) {
8080
8115
  onProgress?.(`Relay tree is lagging (missing index ${utxo.index}, length: ${treeLength}); using guarded on-chain proof fallback.`);
8081
8116
  }
8082
8117
  if (relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
8083
- throw new Error(
8084
- `Relay tree missing required commitment index ${utxo.index} (tree length: ${treeLength}); waiting for relay sync is required.`
8118
+ onProgress?.(
8119
+ `Relay tree missing index ${utxo.index} (tree length: ${treeLength}) \u2014 falling through to on-chain proof.`
8085
8120
  );
8121
+ allowNearTipOnChainFallback = true;
8086
8122
  }
8087
8123
  if (allowNearTipOnChainFallback && relayTreeDisabledForMint) {
8088
8124
  onProgress?.(
@@ -8286,10 +8322,18 @@ async function swapUtxo(params, options) {
8286
8322
  onProgress?.(`Merkle proof error (stale sibling data), will regenerate with fresh tree...`);
8287
8323
  lastError = new Error(`Circuit assertion failed: ${errorMsg}`);
8288
8324
  if (forceChainIndexing) {
8289
- onProgress?.("On-chain fallback proof failed; returning to relay-sync mode.");
8290
- forceChainIndexing = false;
8325
+ onProgress?.("On-chain frontier proof failed; escalating to full chain tree rebuild...");
8326
+ try {
8327
+ merkleTree = await buildMerkleTreeFromChain(connection, programId, pdas.merkleTree, onProgress);
8328
+ onProgress?.(`Chain tree rebuilt with ${merkleTree.length} leaves.`);
8329
+ } catch (chainBuildErr) {
8330
+ onProgress?.(`Chain tree rebuild failed (${chainBuildErr?.message?.slice(0, 80)}); returning to relay-sync mode.`);
8331
+ forceChainIndexing = false;
8332
+ merkleTree = null;
8333
+ }
8334
+ } else {
8335
+ merkleTree = null;
8291
8336
  }
8292
- merkleTree = null;
8293
8337
  merkleState = null;
8294
8338
  useSiblingInfo = false;
8295
8339
  const waitMs = Math.min(retryDelayMs * Math.pow(2, Math.min(attempt, 4)), 5e3);
@@ -8484,19 +8528,26 @@ async function swapUtxo(params, options) {
8484
8528
  throw new Error(`Swap transaction failed: ${lastError.message}`);
8485
8529
  }
8486
8530
  if (relayUrl && outputCommitments.length >= 2) {
8487
- const reconcileSeedIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0 ? commitmentIndices : lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
8488
- const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
8489
- relayUrl,
8490
- swapPoolMint,
8491
- reconcileSeedIndices,
8492
- [outputCommitments[0], outputCommitments[1]],
8493
- onProgress
8494
- );
8495
- if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
8531
+ const hasOnChainIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0;
8532
+ if (!hasOnChainIndices) {
8533
+ const reconcileSeedIndices = lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
8534
+ const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
8535
+ relayUrl,
8536
+ swapPoolMint,
8537
+ reconcileSeedIndices,
8538
+ [outputCommitments[0], outputCommitments[1]],
8539
+ onProgress
8540
+ );
8541
+ if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
8542
+ onProgress?.(
8543
+ `Adjusted swap commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
8544
+ );
8545
+ commitmentIndices = reconciledIndices;
8546
+ }
8547
+ } else {
8496
8548
  onProgress?.(
8497
- `Adjusted swap commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
8549
+ `Using on-chain swap commitment indices [${commitmentIndices[0]}, ${commitmentIndices[1]}] (skipping relay reconciliation).`
8498
8550
  );
8499
- commitmentIndices = reconciledIndices;
8500
8551
  }
8501
8552
  }
8502
8553
  const siblingCommitments = [
@@ -8562,6 +8613,7 @@ async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta,
8562
8613
  var import_bs582 = __toESM(require("bs58"), 1);
8563
8614
  var import_web38 = require("@solana/web3.js");
8564
8615
  var import_spl_token2 = require("@solana/spl-token");
8616
+ var bs582 = import_bs582.default.default || import_bs582.default;
8565
8617
  var TRANSACT_TAG2 = 0;
8566
8618
  var TRANSACT_SWAP_TAG2 = 1;
8567
8619
  var PROOF_LEN2 = 256;
@@ -8745,7 +8797,7 @@ function normalizeIxData(rawData) {
8745
8797
  if (rawData instanceof Uint8Array) return rawData;
8746
8798
  if (typeof rawData === "string") {
8747
8799
  try {
8748
- const decoded = import_bs582.default.decode(rawData);
8800
+ const decoded = bs582.decode(rawData);
8749
8801
  return new Uint8Array(decoded);
8750
8802
  } catch {
8751
8803
  if (typeof Buffer !== "undefined") {
package/dist/index.js CHANGED
@@ -4517,7 +4517,8 @@ async function buildMerkleTree(commitments, height = MERKLE_TREE_HEIGHT2) {
4517
4517
  }
4518
4518
 
4519
4519
  // src/utils/relay-client.ts
4520
- import bs58 from "bs58";
4520
+ import _bs58 from "bs58";
4521
+ var bs58 = _bs58.default || _bs58;
4521
4522
  var TRANSACT_TAG = 0;
4522
4523
  var TRANSACT_SWAP_TAG = 1;
4523
4524
  var DEPOSIT_TAG = 1;
@@ -5636,6 +5637,7 @@ function collectLookupCandidatesFromInstructions(instructions, payer, existingAl
5636
5637
  }
5637
5638
  async function createEphemeralALT(connection, depositor, onProgress, additionalAddresses = []) {
5638
5639
  const MAX_ALT_ADDRESSES = 20;
5640
+ const MAX_ALT_CREATE_RETRIES = 3;
5639
5641
  const altAddresses = dedupePubkeys([
5640
5642
  ...getCommonALTAddresses(),
5641
5643
  ...additionalAddresses
@@ -5646,46 +5648,59 @@ async function createEphemeralALT(connection, depositor, onProgress, additionalA
5646
5648
  `ALT address set truncated (${addressesForCreate.length}/${altAddresses.length}); packet savings may be limited.`
5647
5649
  );
5648
5650
  }
5649
- const slot = await connection.getSlot();
5650
- const [createIx, altAddress] = AddressLookupTableProgram.createLookupTable({
5651
- authority: depositor.publicKey,
5652
- payer: depositor.publicKey,
5653
- recentSlot: slot
5654
- });
5655
- const extendIx = AddressLookupTableProgram.extendLookupTable({
5656
- payer: depositor.publicKey,
5657
- authority: depositor.publicKey,
5658
- lookupTable: altAddress,
5659
- addresses: addressesForCreate
5660
- });
5661
- const tx = new Transaction3().add(createIx).add(extendIx);
5662
- const { blockhash } = await connection.getLatestBlockhash();
5663
- tx.recentBlockhash = blockhash;
5664
- tx.feePayer = depositor.publicKey;
5665
- if (depositor.keypair) {
5666
- await sendAndConfirmTransaction(connection, tx, [depositor.keypair], { commitment: "confirmed" });
5667
- } else if (depositor.signTransaction) {
5668
- const signedTx = await depositor.signTransaction(tx);
5669
- const sig = await connection.sendRawTransaction(signedTx.serialize());
5670
- const latestBH = await connection.getLatestBlockhash();
5671
- await connection.confirmTransaction({ signature: sig, blockhash: latestBH.blockhash, lastValidBlockHeight: latestBH.lastValidBlockHeight }, "confirmed");
5672
- } else {
5673
- throw new Error("Cannot create ALT: no signing method provided");
5674
- }
5675
- for (let i = 0; i < 30; i++) {
5676
- await new Promise((r) => setTimeout(r, 500));
5677
- const result = await connection.getAddressLookupTable(altAddress);
5678
- if (result.value && result.value.isActive()) {
5679
- onProgress?.(`ALT created and active: ${altAddress.toBase58()}`);
5680
- return [result.value];
5651
+ for (let altAttempt = 0; altAttempt < MAX_ALT_CREATE_RETRIES; altAttempt++) {
5652
+ try {
5653
+ const slot = await connection.getSlot("finalized");
5654
+ const [createIx, altAddress] = AddressLookupTableProgram.createLookupTable({
5655
+ authority: depositor.publicKey,
5656
+ payer: depositor.publicKey,
5657
+ recentSlot: slot
5658
+ });
5659
+ const extendIx = AddressLookupTableProgram.extendLookupTable({
5660
+ payer: depositor.publicKey,
5661
+ authority: depositor.publicKey,
5662
+ lookupTable: altAddress,
5663
+ addresses: addressesForCreate
5664
+ });
5665
+ const tx = new Transaction3().add(createIx).add(extendIx);
5666
+ const { blockhash } = await connection.getLatestBlockhash();
5667
+ tx.recentBlockhash = blockhash;
5668
+ tx.feePayer = depositor.publicKey;
5669
+ if (depositor.keypair) {
5670
+ await sendAndConfirmTransaction(connection, tx, [depositor.keypair], { commitment: "confirmed" });
5671
+ } else if (depositor.signTransaction) {
5672
+ const signedTx = await depositor.signTransaction(tx);
5673
+ const sig = await connection.sendRawTransaction(signedTx.serialize());
5674
+ const latestBH = await connection.getLatestBlockhash();
5675
+ await connection.confirmTransaction({ signature: sig, blockhash: latestBH.blockhash, lastValidBlockHeight: latestBH.lastValidBlockHeight }, "confirmed");
5676
+ } else {
5677
+ throw new Error("Cannot create ALT: no signing method provided");
5678
+ }
5679
+ for (let i = 0; i < 30; i++) {
5680
+ await new Promise((r) => setTimeout(r, 500));
5681
+ const result = await connection.getAddressLookupTable(altAddress);
5682
+ if (result.value && result.value.isActive()) {
5683
+ onProgress?.(`ALT created and active: ${altAddress.toBase58()}`);
5684
+ return [result.value];
5685
+ }
5686
+ }
5687
+ const finalResult = await connection.getAddressLookupTable(altAddress);
5688
+ if (finalResult.value) {
5689
+ onProgress?.("ALT created (activation pending)");
5690
+ return [finalResult.value];
5691
+ }
5692
+ throw new Error("Failed to create ALT: not active after 15 seconds");
5693
+ } catch (err) {
5694
+ const msg = err?.message ?? String(err);
5695
+ if (msg.includes("not a recent slot") && altAttempt < MAX_ALT_CREATE_RETRIES - 1) {
5696
+ onProgress?.(`ALT creation failed (stale slot), retrying (${altAttempt + 2}/${MAX_ALT_CREATE_RETRIES})...`);
5697
+ await new Promise((r) => setTimeout(r, 2e3));
5698
+ continue;
5699
+ }
5700
+ throw err;
5681
5701
  }
5682
5702
  }
5683
- const finalResult = await connection.getAddressLookupTable(altAddress);
5684
- if (finalResult.value) {
5685
- onProgress?.("ALT created (activation pending)");
5686
- return [finalResult.value];
5687
- }
5688
- throw new Error("Failed to create ALT: not active after 15 seconds");
5703
+ throw new Error(`Failed to create ALT after ${MAX_ALT_CREATE_RETRIES} retries`);
5689
5704
  }
5690
5705
  async function submitTransactionDirect(connection, programId, depositor, proofBytes, publicInputsBytes, nullifiers, mint, recipient, riskOracleQueue, riskQuoteUrl, getRiskQuoteInstruction, onProgress, addressLookupTableAccounts, rangeApiKey, encryptedNoteBytes, relayUrl, altAddresses) {
5691
5706
  onProgress?.("Building transaction...");
@@ -5716,6 +5731,10 @@ async function submitTransactionDirect(connection, programId, depositor, proofBy
5716
5731
  onProgress?.("Creating address lookup table (chain notes require v0 tx to fit)...");
5717
5732
  addressLookupTableAccounts = await createEphemeralALT(connection, depositor, onProgress);
5718
5733
  }
5734
+ if (isDeposit && isSplPool && (!addressLookupTableAccounts || addressLookupTableAccounts.length === 0)) {
5735
+ onProgress?.("Creating address lookup table (SPL deposit requires v0 tx)...");
5736
+ addressLookupTableAccounts = await createEphemeralALT(connection, depositor, onProgress);
5737
+ }
5719
5738
  const publicAmountBytes = publicInputsBytes.slice(32, 40);
5720
5739
  const publicAmountBuffer = Buffer.from(publicAmountBytes);
5721
5740
  const publicAmount = publicAmountBuffer.readBigInt64LE(0);
@@ -6350,7 +6369,7 @@ async function transact(params, options) {
6350
6369
  }
6351
6370
  merkleTree = null;
6352
6371
  }
6353
- if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree)) {
6372
+ if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree) && !hasCachedTree) {
6354
6373
  try {
6355
6374
  const shouldRequestRelaySync = forceSync || requiredRelayIndex >= 0;
6356
6375
  const syncTimeoutMs = shouldRequestRelaySync ? Math.min(3e4, relayRequestTimeoutMs()) : 3500;
@@ -6375,7 +6394,7 @@ async function transact(params, options) {
6375
6394
  merkleTree = null;
6376
6395
  }
6377
6396
  }
6378
- if (merkleTree && treeState) {
6397
+ if (merkleTree && treeState && !hasCachedTree) {
6379
6398
  const relayRoot = merkleTree.root().toString(16).padStart(64, "0");
6380
6399
  const lengthDiff = treeState.nextIndex - merkleTree.length;
6381
6400
  if (merkleTree.length === 0) {
@@ -6506,7 +6525,7 @@ async function transact(params, options) {
6506
6525
  const disableNearTipFallbackEnv = typeof process !== "undefined" && !!process.env && (process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "1" || process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "true");
6507
6526
  const hasSiblingHints = !!utxo.siblingCommitment || !!utxo.leftSiblingCommitment;
6508
6527
  const baseNearTipEligible = chainDistanceFromTip !== null && chainDistanceFromTip >= 0 && chainDistanceFromTip <= nearTipMaxDistance;
6509
- const allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
6528
+ let allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
6510
6529
  if (!relayTreeDisabledForMint && !useSiblingInfo) {
6511
6530
  onProgress?.(`Relay tree missing index ${utxo.index} (length: ${treeLength}) with sibling cache disabled; proof may require retry after relay sync.`);
6512
6531
  } else if (!relayTreeDisabledForMint && relayUrl && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
@@ -6517,9 +6536,10 @@ async function transact(params, options) {
6517
6536
  onProgress?.(`Relay tree is lagging (missing index ${utxo.index}, length: ${treeLength}); using guarded on-chain proof fallback.`);
6518
6537
  }
6519
6538
  if (relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
6520
- throw new Error(
6521
- `Relay tree missing required commitment index ${utxo.index} (tree length: ${treeLength}); waiting for relay sync is required.`
6539
+ onProgress?.(
6540
+ `Relay tree missing index ${utxo.index} (tree length: ${treeLength}) \u2014 falling through to on-chain proof.`
6522
6541
  );
6542
+ allowNearTipOnChainFallback = true;
6523
6543
  }
6524
6544
  if (allowNearTipOnChainFallback && relayTreeDisabledForMint) {
6525
6545
  onProgress?.(
@@ -6753,11 +6773,19 @@ async function transact(params, options) {
6753
6773
  onProgress?.(`Merkle proof error (stale sibling data), will regenerate with fresh tree...`);
6754
6774
  lastError = new Error(`Circuit assertion failed: ${errorMsg}`);
6755
6775
  if (forceChainIndexing) {
6756
- onProgress?.("On-chain fallback proof failed; returning to relay-sync mode.");
6757
- forceChainIndexing = false;
6776
+ onProgress?.("On-chain frontier proof failed; escalating to full chain tree rebuild...");
6777
+ try {
6778
+ merkleTree = await buildMerkleTreeFromChain(connection, programId, pdas.merkleTree, onProgress);
6779
+ onProgress?.(`Chain tree rebuilt with ${merkleTree.length} leaves.`);
6780
+ } catch (chainBuildErr) {
6781
+ onProgress?.(`Chain tree rebuild failed (${chainBuildErr?.message?.slice(0, 80)}); returning to relay-sync mode.`);
6782
+ forceChainIndexing = false;
6783
+ merkleTree = null;
6784
+ }
6785
+ } else {
6786
+ merkleTree = null;
6758
6787
  }
6759
6788
  treeState = null;
6760
- merkleTree = null;
6761
6789
  useSiblingInfo = false;
6762
6790
  const waitMs = Math.min(retryDelayMs * Math.pow(2, Math.min(submissionAttempts, 4)), 5e3);
6763
6791
  if (waitMs > 0) {
@@ -7104,19 +7132,26 @@ async function transact(params, options) {
7104
7132
  throw new Error(`Transaction failed: ${lastError.message}`);
7105
7133
  }
7106
7134
  if (relayUrl && outputCommitments.length >= 2) {
7107
- const reconcileSeedIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0 ? commitmentIndices : lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
7108
- const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
7109
- relayUrl,
7110
- mint,
7111
- reconcileSeedIndices,
7112
- [outputCommitments[0], outputCommitments[1]],
7113
- onProgress
7114
- );
7115
- if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
7135
+ const hasOnChainIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0;
7136
+ if (!hasOnChainIndices) {
7137
+ const reconcileSeedIndices = lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
7138
+ const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
7139
+ relayUrl,
7140
+ mint,
7141
+ reconcileSeedIndices,
7142
+ [outputCommitments[0], outputCommitments[1]],
7143
+ onProgress
7144
+ );
7145
+ if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
7146
+ onProgress?.(
7147
+ `Adjusted commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
7148
+ );
7149
+ commitmentIndices = reconciledIndices;
7150
+ }
7151
+ } else {
7116
7152
  onProgress?.(
7117
- `Adjusted commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
7153
+ `Using on-chain commitment indices [${commitmentIndices[0]}, ${commitmentIndices[1]}] (skipping relay reconciliation).`
7118
7154
  );
7119
- commitmentIndices = reconciledIndices;
7120
7155
  }
7121
7156
  }
7122
7157
  const siblingCommitments = [
@@ -7469,7 +7504,7 @@ async function swapUtxo(params, options) {
7469
7504
  }
7470
7505
  merkleTree = null;
7471
7506
  }
7472
- if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree)) {
7507
+ if (needsTreeForProof && relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && (forceRefresh || !merkleTree) && !hasCachedTree) {
7473
7508
  try {
7474
7509
  const shouldRequestRelaySync = forceSync || requiredRelayIndex >= 0;
7475
7510
  const syncTimeoutMs = shouldRequestRelaySync ? Math.min(3e4, relayRequestTimeoutMs()) : 3500;
@@ -7494,7 +7529,7 @@ async function swapUtxo(params, options) {
7494
7529
  merkleTree = null;
7495
7530
  }
7496
7531
  }
7497
- if (merkleTree && merkleState) {
7532
+ if (merkleTree && merkleState && !hasCachedTree) {
7498
7533
  const relayRoot = merkleTree.root().toString(16).padStart(64, "0");
7499
7534
  const lengthDiff = merkleState.nextIndex - merkleTree.length;
7500
7535
  if (merkleTree.length === 0) {
@@ -7622,7 +7657,7 @@ async function swapUtxo(params, options) {
7622
7657
  const disableNearTipFallbackEnv = typeof process !== "undefined" && !!process.env && (process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "1" || process.env.CLOAK_DISABLE_NEAR_TIP_ONCHAIN_PROOF === "true");
7623
7658
  const hasSiblingHints = !!utxo.siblingCommitment || !!utxo.leftSiblingCommitment;
7624
7659
  const baseNearTipEligible = chainDistanceFromTip !== null && chainDistanceFromTip >= 0 && chainDistanceFromTip <= nearTipMaxDistance;
7625
- const allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
7660
+ let allowNearTipOnChainFallback = relayTreeDisabledForMint && !disableNearTipFallbackEnv && baseNearTipEligible && (forceEnableNearTipFallbackEnv || useSiblingInfo && hasSiblingHints);
7626
7661
  if (!relayTreeDisabledForMint && !useSiblingInfo) {
7627
7662
  onProgress?.(`Relay tree missing index ${utxo.index} (length: ${treeLength}) with sibling cache disabled; proof may require retry after relay sync.`);
7628
7663
  } else if (!relayTreeDisabledForMint && relayUrl && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
@@ -7633,9 +7668,10 @@ async function swapUtxo(params, options) {
7633
7668
  onProgress?.(`Relay tree is lagging (missing index ${utxo.index}, length: ${treeLength}); using guarded on-chain proof fallback.`);
7634
7669
  }
7635
7670
  if (relayUrl && !relayTreeDisabledForMint && !forceChainIndexing && utxo.index >= treeLength && !allowNearTipOnChainFallback) {
7636
- throw new Error(
7637
- `Relay tree missing required commitment index ${utxo.index} (tree length: ${treeLength}); waiting for relay sync is required.`
7671
+ onProgress?.(
7672
+ `Relay tree missing index ${utxo.index} (tree length: ${treeLength}) \u2014 falling through to on-chain proof.`
7638
7673
  );
7674
+ allowNearTipOnChainFallback = true;
7639
7675
  }
7640
7676
  if (allowNearTipOnChainFallback && relayTreeDisabledForMint) {
7641
7677
  onProgress?.(
@@ -7839,10 +7875,18 @@ async function swapUtxo(params, options) {
7839
7875
  onProgress?.(`Merkle proof error (stale sibling data), will regenerate with fresh tree...`);
7840
7876
  lastError = new Error(`Circuit assertion failed: ${errorMsg}`);
7841
7877
  if (forceChainIndexing) {
7842
- onProgress?.("On-chain fallback proof failed; returning to relay-sync mode.");
7843
- forceChainIndexing = false;
7878
+ onProgress?.("On-chain frontier proof failed; escalating to full chain tree rebuild...");
7879
+ try {
7880
+ merkleTree = await buildMerkleTreeFromChain(connection, programId, pdas.merkleTree, onProgress);
7881
+ onProgress?.(`Chain tree rebuilt with ${merkleTree.length} leaves.`);
7882
+ } catch (chainBuildErr) {
7883
+ onProgress?.(`Chain tree rebuild failed (${chainBuildErr?.message?.slice(0, 80)}); returning to relay-sync mode.`);
7884
+ forceChainIndexing = false;
7885
+ merkleTree = null;
7886
+ }
7887
+ } else {
7888
+ merkleTree = null;
7844
7889
  }
7845
- merkleTree = null;
7846
7890
  merkleState = null;
7847
7891
  useSiblingInfo = false;
7848
7892
  const waitMs = Math.min(retryDelayMs * Math.pow(2, Math.min(attempt, 4)), 5e3);
@@ -8037,19 +8081,26 @@ async function swapUtxo(params, options) {
8037
8081
  throw new Error(`Swap transaction failed: ${lastError.message}`);
8038
8082
  }
8039
8083
  if (relayUrl && outputCommitments.length >= 2) {
8040
- const reconcileSeedIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0 ? commitmentIndices : lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
8041
- const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
8042
- relayUrl,
8043
- swapPoolMint,
8044
- reconcileSeedIndices,
8045
- [outputCommitments[0], outputCommitments[1]],
8046
- onProgress
8047
- );
8048
- if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
8084
+ const hasOnChainIndices = commitmentIndices[0] >= 0 && commitmentIndices[1] >= 0;
8085
+ if (!hasOnChainIndices) {
8086
+ const reconcileSeedIndices = lastObservedNextIndexForOutputs !== null ? [lastObservedNextIndexForOutputs, lastObservedNextIndexForOutputs + 1] : commitmentIndices;
8087
+ const reconciledIndices = await reconcileCommitmentIndicesWithRelay(
8088
+ relayUrl,
8089
+ swapPoolMint,
8090
+ reconcileSeedIndices,
8091
+ [outputCommitments[0], outputCommitments[1]],
8092
+ onProgress
8093
+ );
8094
+ if (reconciledIndices[0] !== commitmentIndices[0] || reconciledIndices[1] !== commitmentIndices[1]) {
8095
+ onProgress?.(
8096
+ `Adjusted swap commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
8097
+ );
8098
+ commitmentIndices = reconciledIndices;
8099
+ }
8100
+ } else {
8049
8101
  onProgress?.(
8050
- `Adjusted swap commitment indices after relay reconciliation: [${commitmentIndices[0]}, ${commitmentIndices[1]}] -> [${reconciledIndices[0]}, ${reconciledIndices[1]}]`
8102
+ `Using on-chain swap commitment indices [${commitmentIndices[0]}, ${commitmentIndices[1]}] (skipping relay reconciliation).`
8051
8103
  );
8052
- commitmentIndices = reconciledIndices;
8053
8104
  }
8054
8105
  }
8055
8106
  const siblingCommitments = [
@@ -8112,11 +8163,12 @@ async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta,
8112
8163
  }
8113
8164
 
8114
8165
  // src/core/scanner.ts
8115
- import bs582 from "bs58";
8166
+ import _bs582 from "bs58";
8116
8167
  import {
8117
8168
  PublicKey as PublicKey7
8118
8169
  } from "@solana/web3.js";
8119
8170
  import { getAssociatedTokenAddressSync as getAssociatedTokenAddressSync2 } from "@solana/spl-token";
8171
+ var bs582 = _bs582.default || _bs582;
8120
8172
  var TRANSACT_TAG2 = 0;
8121
8173
  var TRANSACT_SWAP_TAG2 = 1;
8122
8174
  var PROOF_LEN2 = 256;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloak.dev/sdk",
3
- "description": "TypeScript SDK for Cloak",
4
- "version": "0.1.2",
3
+ "description": "Shield, send, and swap on Solana privately — TypeScript SDK with UTXO-based zero-knowledge transactions",
4
+ "version": "0.1.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "web3",
48
48
  "blockchain"
49
49
  ],
50
- "author": "Cloak Labs",
50
+ "author": "Cloak",
51
51
  "license": "Apache-2.0",
52
52
  "repository": {
53
53
  "type": "git",
@@ -61,15 +61,15 @@
61
61
  "@jup-ag/api": "^6.0.48",
62
62
  "@lightprotocol/hasher.rs": "^0.2.1",
63
63
  "@noble/hashes": "^1.8.0",
64
- "@solana/spl-token": "^0.4.0",
65
- "@solana/web3.js": "^1.0.0",
64
+ "@solana/spl-token": "0.4.14",
65
+ "@solana/web3.js": "^1.98.0",
66
66
  "bs58": "^6.0.0",
67
- "circomlibjs": "^0.1.7",
67
+ "circomlibjs": "0.1.7",
68
68
  "ffjavascript": "^0.3.0",
69
- "snarkjs": "^0.7.4",
69
+ "snarkjs": "0.7.6",
70
70
  "tweetnacl": "^1.0.3",
71
71
  "tweetnacl-util": "^0.15.1",
72
- "yaml": "^2.8.2"
72
+ "yaml": "^2.8.3"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@coral-xyz/anchor": "^0.32.1",
@@ -86,8 +86,8 @@
86
86
  "peerDependencies": {
87
87
  "@switchboard-xyz/common": "^5.6.1",
88
88
  "@switchboard-xyz/on-demand": "^3.8.2",
89
- "@solana/spl-token": "^0.4.0",
90
- "@solana/web3.js": "^1.0.0"
89
+ "@solana/spl-token": ">=0.4.9",
90
+ "@solana/web3.js": ">=1.98.0"
91
91
  },
92
92
  "peerDependenciesMeta": {
93
93
  "@switchboard-xyz/common": {