@umbra-privacy/sdk 2.0.5 → 2.1.1

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.
@@ -1734,6 +1734,21 @@ interface ScannedUtxoResult {
1734
1734
  publicSelfBurnable: ScannedUtxoData[];
1735
1735
  /** Public-balance deposit UTXOs sent to you by others via public ATA. */
1736
1736
  publicReceived: ScannedUtxoData[];
1737
+ /**
1738
+ * The insertion index to pass as `startInsertionIndex` on the next scan call.
1739
+ *
1740
+ * Computed as `max(insertionIndex across all indexer results) + 1` when the
1741
+ * indexer returned at least one UTXO, or `startInsertionIndex` when none were
1742
+ * returned (i.e., the tree range was empty).
1743
+ *
1744
+ * @example
1745
+ * ```typescript
1746
+ * const result = await scan(treeIndex, savedStartIndex);
1747
+ * // process result.selfBurnable, result.received, etc.
1748
+ * savedStartIndex = result.nextScanStartIndex;
1749
+ * ```
1750
+ */
1751
+ nextScanStartIndex: U32;
1737
1752
  }
1738
1753
  /**
1739
1754
  * Result of a batch merkle proof fetch from the indexer.
@@ -1734,6 +1734,21 @@ interface ScannedUtxoResult {
1734
1734
  publicSelfBurnable: ScannedUtxoData[];
1735
1735
  /** Public-balance deposit UTXOs sent to you by others via public ATA. */
1736
1736
  publicReceived: ScannedUtxoData[];
1737
+ /**
1738
+ * The insertion index to pass as `startInsertionIndex` on the next scan call.
1739
+ *
1740
+ * Computed as `max(insertionIndex across all indexer results) + 1` when the
1741
+ * indexer returned at least one UTXO, or `startInsertionIndex` when none were
1742
+ * returned (i.e., the tree range was empty).
1743
+ *
1744
+ * @example
1745
+ * ```typescript
1746
+ * const result = await scan(treeIndex, savedStartIndex);
1747
+ * // process result.selfBurnable, result.received, etc.
1748
+ * savedStartIndex = result.nextScanStartIndex;
1749
+ * ```
1750
+ */
1751
+ nextScanStartIndex: U32;
1737
1752
  }
1738
1753
  /**
1739
1754
  * Result of a batch merkle proof fetch from the indexer.
@@ -1,4 +1,4 @@
1
- import { o as AesDecryptorFunction, p as AesEncryptorFunction, d as IUmbraClient } from '../client-DkVBHMWb.cjs';
1
+ import { o as AesDecryptorFunction, p as AesEncryptorFunction, d as IUmbraClient } from '../client-Cb53GYes.cjs';
2
2
  import { b as SubBrandedType, B as Bytes, f as U256, U as U128, S as SubSubBrandedType, a as SubSubSubBrandedType } from '../types-C_V_CaKK.cjs';
3
3
  import { T as PseudorandomU512DeriverFunction, a5 as Kmac256Function, x as MasterSeedBasedFieldElementDeriverFunction, N as PoseidonHashFunction, D as DailyViewingKeyGeneratorFunction, E as EphemeralMasterSeedDeriverFunction, k as EphemeralRescueCommitmentBlindingFactorDeriverFunction, l as EphemeralUtxoH2RandomSecretDeriverFunction, m as EphemeralUtxoMasterViewingKeyBlindingFactorDeriverFunction, n as EphemeralUtxoMasterViewingKeyDeriverFunction, o as EphemeralUtxoNullifierDeriverFunction, p as EphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriverFunction, q as EphemeralUtxoPoseidonPrivateKeyDeriverFunction, w as HourlyViewingKeyGeneratorFunction, b as MasterViewingKeyBlindingFactorDeriverFunction, a as MasterViewingKeyDeriverFunction, C as Curve25519KeypairGeneratorFunction, z as MintViewingKeyDeriverFunction, M as MintX25519KeypairDeriverFunction, A as MinuteViewingKeyGeneratorFunction, G as MonthlyViewingKeyGeneratorFunction, d as PolynomialCommitmentFactorDeriverFunction, c as PoseidonBlindingFactorDeriverFunction, O as PoseidonKeystreamBlindingFactorDeriverFunction, P as PoseidonPrivateKeyDeriverFunction, R as RescueCommitmentBlindingFactorDeriverFunction, a1 as SecondViewingKeyGeneratorFunction, a4 as YearlyViewingKeyGeneratorFunction, r as FieldArithmetic, X as RescueCipherDeps, Y as RescueCipherInstance, $ as RescuePrimeHashDeps, a0 as RescuePrimeHashFunction, Q as PoseidonKeystreamGeneratorFunction, S as PoseidonPrfFunction, K as KeystreamCommitmentFunction, J as PoseidonDecryptorFunction, L as PoseidonEncryptorFunction, u as H2GeneratorFns, a6 as RandomNonceGeneratorFunction, f as RcEncryptorWithNonceFunction, a7 as X25519GetSharedSecretFunction, V as RcDecryptorFunction, W as RcEncryptorFunction, e as RcKeyGeneratorFunction, j as ChallengePowersDeps, g as ChallengePowersFunction, F as FiatShamirChallengeGeneratorFunction, B as ModuloPowCurve25519Function, I as PolynomialEvaluatorDeps, h as PolynomialEvaluatorFunction, a2 as UserCommitmentGeneratorDeps, U as UserCommitmentGeneratorFunction } from '../interfaces-43cReBcS.cjs';
4
4
  export { H as H2CircuitProvableHashFunction, s as H2CircuitProvableParams, t as H2FullParams, v as H2HashFunction, y as MasterSeedGeneratorFunction, i as PoseidonAggregatorHashFunction, Z as RescueKeyDerivationFunction, _ as RescuePermuteFunction, a3 as ViewingKeyGeneratorOptions } from '../interfaces-43cReBcS.cjs';
@@ -1,4 +1,4 @@
1
- import { o as AesDecryptorFunction, p as AesEncryptorFunction, d as IUmbraClient } from '../client-V4AF6Bz9.js';
1
+ import { o as AesDecryptorFunction, p as AesEncryptorFunction, d as IUmbraClient } from '../client-CJ5S6Qln.js';
2
2
  import { b as SubBrandedType, B as Bytes, f as U256, U as U128, S as SubSubBrandedType, a as SubSubSubBrandedType } from '../types-C_V_CaKK.js';
3
3
  import { T as PseudorandomU512DeriverFunction, a5 as Kmac256Function, x as MasterSeedBasedFieldElementDeriverFunction, N as PoseidonHashFunction, D as DailyViewingKeyGeneratorFunction, E as EphemeralMasterSeedDeriverFunction, k as EphemeralRescueCommitmentBlindingFactorDeriverFunction, l as EphemeralUtxoH2RandomSecretDeriverFunction, m as EphemeralUtxoMasterViewingKeyBlindingFactorDeriverFunction, n as EphemeralUtxoMasterViewingKeyDeriverFunction, o as EphemeralUtxoNullifierDeriverFunction, p as EphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriverFunction, q as EphemeralUtxoPoseidonPrivateKeyDeriverFunction, w as HourlyViewingKeyGeneratorFunction, b as MasterViewingKeyBlindingFactorDeriverFunction, a as MasterViewingKeyDeriverFunction, C as Curve25519KeypairGeneratorFunction, z as MintViewingKeyDeriverFunction, M as MintX25519KeypairDeriverFunction, A as MinuteViewingKeyGeneratorFunction, G as MonthlyViewingKeyGeneratorFunction, d as PolynomialCommitmentFactorDeriverFunction, c as PoseidonBlindingFactorDeriverFunction, O as PoseidonKeystreamBlindingFactorDeriverFunction, P as PoseidonPrivateKeyDeriverFunction, R as RescueCommitmentBlindingFactorDeriverFunction, a1 as SecondViewingKeyGeneratorFunction, a4 as YearlyViewingKeyGeneratorFunction, r as FieldArithmetic, X as RescueCipherDeps, Y as RescueCipherInstance, $ as RescuePrimeHashDeps, a0 as RescuePrimeHashFunction, Q as PoseidonKeystreamGeneratorFunction, S as PoseidonPrfFunction, K as KeystreamCommitmentFunction, J as PoseidonDecryptorFunction, L as PoseidonEncryptorFunction, u as H2GeneratorFns, a6 as RandomNonceGeneratorFunction, f as RcEncryptorWithNonceFunction, a7 as X25519GetSharedSecretFunction, V as RcDecryptorFunction, W as RcEncryptorFunction, e as RcKeyGeneratorFunction, j as ChallengePowersDeps, g as ChallengePowersFunction, F as FiatShamirChallengeGeneratorFunction, B as ModuloPowCurve25519Function, I as PolynomialEvaluatorDeps, h as PolynomialEvaluatorFunction, a2 as UserCommitmentGeneratorDeps, U as UserCommitmentGeneratorFunction } from '../interfaces-z_xYJlgV.js';
4
4
  export { H as H2CircuitProvableHashFunction, s as H2CircuitProvableParams, t as H2FullParams, v as H2HashFunction, y as MasterSeedGeneratorFunction, i as PoseidonAggregatorHashFunction, Z as RescueKeyDerivationFunction, _ as RescuePermuteFunction, a3 as ViewingKeyGeneratorOptions } from '../interfaces-z_xYJlgV.js';
@@ -1,4 +1,4 @@
1
- import { s as ComputationMonitorOptions, u as ComputationMonitorResult, v as ComputationMonitorResultWithSignature, I as IUmbraSigner, G as GetLatestBlockhash, T as TransactionForwarder, c as ComputationMonitor, L as GetMasterSeedFunction, d as IUmbraClient, A as AccountInfoProviderFunction, p as AesEncryptorFunction, a as GetEpochInfo, B as BatchMerkleProofFetcherFunction, k as ClaimableUtxoData } from './client-DkVBHMWb.cjs';
1
+ import { s as ComputationMonitorOptions, u as ComputationMonitorResult, v as ComputationMonitorResultWithSignature, I as IUmbraSigner, G as GetLatestBlockhash, T as TransactionForwarder, c as ComputationMonitor, L as GetMasterSeedFunction, d as IUmbraClient, A as AccountInfoProviderFunction, p as AesEncryptorFunction, a as GetEpochInfo, B as BatchMerkleProofFetcherFunction, k as ClaimableUtxoData } from './client-Cb53GYes.cjs';
2
2
  import { V as RcDecryptorFunction, a as MasterViewingKeyDeriverFunction, b as MasterViewingKeyBlindingFactorDeriverFunction, P as PoseidonPrivateKeyDeriverFunction, c as PoseidonBlindingFactorDeriverFunction, C as Curve25519KeypairGeneratorFunction, a1 as SecondViewingKeyGeneratorFunction, o as EphemeralUtxoNullifierDeriverFunction, l as EphemeralUtxoH2RandomSecretDeriverFunction, O as PoseidonKeystreamBlindingFactorDeriverFunction, N as PoseidonHashFunction, f as RcEncryptorWithNonceFunction, F as FiatShamirChallengeGeneratorFunction, U as UserCommitmentGeneratorFunction, u as H2GeneratorFns, K as KeystreamCommitmentFunction, L as PoseidonEncryptorFunction, Q as PoseidonKeystreamGeneratorFunction, n as EphemeralUtxoMasterViewingKeyDeriverFunction, m as EphemeralUtxoMasterViewingKeyBlindingFactorDeriverFunction, q as EphemeralUtxoPoseidonPrivateKeyDeriverFunction, p as EphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriverFunction, i as PoseidonAggregatorHashFunction, e as RcKeyGeneratorFunction, M as MintX25519KeypairDeriverFunction } from './interfaces-43cReBcS.cjs';
3
3
  import './interfaces-D2NO6kDD.cjs';
4
4
  import * as _solana_kit from '@solana/kit';
@@ -1,4 +1,4 @@
1
- import { s as ComputationMonitorOptions, u as ComputationMonitorResult, v as ComputationMonitorResultWithSignature, I as IUmbraSigner, G as GetLatestBlockhash, T as TransactionForwarder, c as ComputationMonitor, L as GetMasterSeedFunction, d as IUmbraClient, A as AccountInfoProviderFunction, p as AesEncryptorFunction, a as GetEpochInfo, B as BatchMerkleProofFetcherFunction, k as ClaimableUtxoData } from './client-V4AF6Bz9.js';
1
+ import { s as ComputationMonitorOptions, u as ComputationMonitorResult, v as ComputationMonitorResultWithSignature, I as IUmbraSigner, G as GetLatestBlockhash, T as TransactionForwarder, c as ComputationMonitor, L as GetMasterSeedFunction, d as IUmbraClient, A as AccountInfoProviderFunction, p as AesEncryptorFunction, a as GetEpochInfo, B as BatchMerkleProofFetcherFunction, k as ClaimableUtxoData } from './client-CJ5S6Qln.js';
2
2
  import { V as RcDecryptorFunction, a as MasterViewingKeyDeriverFunction, b as MasterViewingKeyBlindingFactorDeriverFunction, P as PoseidonPrivateKeyDeriverFunction, c as PoseidonBlindingFactorDeriverFunction, C as Curve25519KeypairGeneratorFunction, a1 as SecondViewingKeyGeneratorFunction, o as EphemeralUtxoNullifierDeriverFunction, l as EphemeralUtxoH2RandomSecretDeriverFunction, O as PoseidonKeystreamBlindingFactorDeriverFunction, N as PoseidonHashFunction, f as RcEncryptorWithNonceFunction, F as FiatShamirChallengeGeneratorFunction, U as UserCommitmentGeneratorFunction, u as H2GeneratorFns, K as KeystreamCommitmentFunction, L as PoseidonEncryptorFunction, Q as PoseidonKeystreamGeneratorFunction, n as EphemeralUtxoMasterViewingKeyDeriverFunction, m as EphemeralUtxoMasterViewingKeyBlindingFactorDeriverFunction, q as EphemeralUtxoPoseidonPrivateKeyDeriverFunction, p as EphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriverFunction, i as PoseidonAggregatorHashFunction, e as RcKeyGeneratorFunction, M as MintX25519KeypairDeriverFunction } from './interfaces-z_xYJlgV.js';
3
3
  import './interfaces-B8xKNl_6.js';
4
4
  import * as _solana_kit from '@solana/kit';
package/dist/index.cjs CHANGED
@@ -1187,6 +1187,7 @@ function getClaimableUtxoScannerFunction(args, deps) {
1187
1187
  const absoluteEndIndex = endInsertionIndex === void 0 ? treeEndAbsoluteIndex : treeOffset + endInsertionIndex;
1188
1188
  const allDecrypted = [];
1189
1189
  let cursor = absoluteStartIndex;
1190
+ let lastSeenInsertionIndex = null;
1190
1191
  while (cursor <= absoluteEndIndex) {
1191
1192
  let result;
1192
1193
  try {
@@ -1199,16 +1200,22 @@ function getClaimableUtxoScannerFunction(args, deps) {
1199
1200
  error instanceof Error ? error : void 0
1200
1201
  );
1201
1202
  }
1203
+ const treeUtxos = [];
1202
1204
  for (const [, utxo] of result.items) {
1203
1205
  if (utxo.treeIndex !== treeIndex) {
1204
1206
  continue;
1205
1207
  }
1206
- const decrypted = await tryDecryptUtxo(
1207
- utxo,
1208
- clientX25519PrivateKey,
1209
- aesDecryptor,
1210
- x25519GetSharedSecret
1211
- );
1208
+ if (lastSeenInsertionIndex === null || utxo.insertionIndex > lastSeenInsertionIndex) {
1209
+ lastSeenInsertionIndex = utxo.insertionIndex;
1210
+ }
1211
+ treeUtxos.push(utxo);
1212
+ }
1213
+ const decryptedResults = await Promise.all(
1214
+ treeUtxos.map(
1215
+ (utxo) => tryDecryptUtxo(utxo, clientX25519PrivateKey, aesDecryptor, x25519GetSharedSecret)
1216
+ )
1217
+ );
1218
+ for (const decrypted of decryptedResults) {
1212
1219
  if (decrypted !== null) {
1213
1220
  allDecrypted.push(decrypted);
1214
1221
  }
@@ -1221,8 +1228,9 @@ function getClaimableUtxoScannerFunction(args, deps) {
1221
1228
  }
1222
1229
  cursor = result.nextCursor;
1223
1230
  }
1231
+ const nextScanStartIndex = lastSeenInsertionIndex !== null ? lastSeenInsertionIndex + 1n : startInsertionIndex;
1224
1232
  if (allDecrypted.length === 0) {
1225
- return { selfBurnable: [], received: [], publicSelfBurnable: [], publicReceived: [] };
1233
+ return { selfBurnable: [], received: [], publicSelfBurnable: [], publicReceived: [], nextScanStartIndex };
1226
1234
  }
1227
1235
  const selfBurnableUtxos = [];
1228
1236
  const receivedUtxos = [];
@@ -1252,7 +1260,8 @@ function getClaimableUtxoScannerFunction(args, deps) {
1252
1260
  selfBurnable: selfBurnableUtxos,
1253
1261
  received: receivedUtxos,
1254
1262
  publicSelfBurnable: publicSelfBurnableUtxos,
1255
- publicReceived: publicReceivedUtxos
1263
+ publicReceived: publicReceivedUtxos,
1264
+ nextScanStartIndex
1256
1265
  };
1257
1266
  }, "fetchClaimableUtxos");
1258
1267
  }