@0xbow/privacy-pools-core-sdk 0.0.0-c42a71a3 → 0.0.0-e101aa

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 (20) hide show
  1. package/dist/esm/{fetchArtifacts.esm-DhinGr0a.js → fetchArtifacts.esm-Bx-wAcix.js} +2 -2
  2. package/dist/esm/{fetchArtifacts.esm-DhinGr0a.js.map → fetchArtifacts.esm-Bx-wAcix.js.map} +1 -1
  3. package/dist/esm/{fetchArtifacts.node-BarT-ack.js → fetchArtifacts.node-hJM5tGnz.js} +2 -2
  4. package/dist/esm/{fetchArtifacts.node-BarT-ack.js.map → fetchArtifacts.node-hJM5tGnz.js.map} +1 -1
  5. package/dist/esm/{index-ynv4K_cq.js → index-DKBVXntl.js} +29 -38
  6. package/dist/esm/{index-ynv4K_cq.js.map → index-DKBVXntl.js.map} +1 -1
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/node/{fetchArtifacts.esm-aY2Tx1qe.js → fetchArtifacts.esm-DMpHpySp.js} +2 -2
  9. package/dist/node/{fetchArtifacts.esm-aY2Tx1qe.js.map → fetchArtifacts.esm-DMpHpySp.js.map} +1 -1
  10. package/dist/node/{fetchArtifacts.node-CF90z74C.js → fetchArtifacts.node-DhSwIt3O.js} +2 -2
  11. package/dist/node/{fetchArtifacts.node-CF90z74C.js.map → fetchArtifacts.node-DhSwIt3O.js.map} +1 -1
  12. package/dist/node/{index-BgfrdIiJ.js → index-Q1Q7Va3Q.js} +29 -38
  13. package/dist/node/{index-BgfrdIiJ.js.map → index-Q1Q7Va3Q.js.map} +1 -1
  14. package/dist/node/index.mjs +1 -1
  15. package/dist/types/{fetchArtifacts.esm-s8imnxFN.js → fetchArtifacts.esm-BmDEMaUO.js} +1 -1
  16. package/dist/types/{fetchArtifacts.node-BwpGMlwi.js → fetchArtifacts.node-ClHhvnhY.js} +1 -1
  17. package/dist/types/{index-BZkN1dA8.js → index-BITDYIPX.js} +28 -37
  18. package/dist/types/index.js +1 -1
  19. package/package.json +1 -1
  20. package/src/core/account.service.ts +26 -26
@@ -1,4 +1,4 @@
1
- export { n as AccountError, A as AccountService, B as BlockchainProvider, o as CircuitName, j as Circuits, C as CommitmentService, m as ContractError, k as ContractInteractionsService, D as DataService, E as ErrorCode, I as InvalidRpcUrl, P as PrivacyPoolSDK, l as ProofError, S as SDKError, W as WithdrawalService, e as bigintToHash, f as bigintToHex, i as calculateContext, a as generateDepositSecrets, g as generateMasterKeys, d as generateMerkleProof, b as generateWithdrawalSecrets, c as getCommitment, h as hashPrecommitment } from './index-BgfrdIiJ.js';
1
+ export { n as AccountError, A as AccountService, B as BlockchainProvider, o as CircuitName, j as Circuits, C as CommitmentService, m as ContractError, k as ContractInteractionsService, D as DataService, E as ErrorCode, I as InvalidRpcUrl, P as PrivacyPoolSDK, l as ProofError, S as SDKError, W as WithdrawalService, e as bigintToHash, f as bigintToHex, i as calculateContext, a as generateDepositSecrets, g as generateMasterKeys, d as generateMerkleProof, b as generateWithdrawalSecrets, c as getCommitment, h as hashPrecommitment } from './index-Q1Q7Va3Q.js';
2
2
  import 'viem/accounts';
3
3
  import 'buffer';
4
4
  import 'http';
@@ -1,4 +1,4 @@
1
- import { F as FetchArtifact } from './index-BZkN1dA8.js';
1
+ import { F as FetchArtifact } from './index-BITDYIPX.js';
2
2
  import 'viem/accounts';
3
3
  import 'buffer';
4
4
  import 'http';
@@ -1,4 +1,4 @@
1
- import { F as FetchArtifact } from './index-BZkN1dA8.js';
1
+ import { F as FetchArtifact } from './index-BITDYIPX.js';
2
2
  import 'viem/accounts';
3
3
  import 'buffer';
4
4
  import 'http';
@@ -15082,19 +15082,10 @@ var __setModuleDefault = Object.create ? (function(o, v) {
15082
15082
  o["default"] = v;
15083
15083
  };
15084
15084
 
15085
- var ownKeys = function(o) {
15086
- ownKeys = Object.getOwnPropertyNames || function (o) {
15087
- var ar = [];
15088
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
15089
- return ar;
15090
- };
15091
- return ownKeys(o);
15092
- };
15093
-
15094
15085
  function __importStar(mod) {
15095
15086
  if (mod && mod.__esModule) return mod;
15096
15087
  var result = {};
15097
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
15088
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
15098
15089
  __setModuleDefault(result, mod);
15099
15090
  return result;
15100
15091
  }
@@ -15176,25 +15167,12 @@ function __disposeResources(env) {
15176
15167
  return next();
15177
15168
  }
15178
15169
 
15179
- function __rewriteRelativeImportExtension(path, preserveJsx) {
15180
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
15181
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
15182
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
15183
- });
15184
- }
15185
- return path;
15186
- }
15187
-
15188
15170
  var tslib_es6 = {
15189
15171
  __extends: __extends,
15190
15172
  __assign: __assign,
15191
15173
  __rest: __rest,
15192
15174
  __decorate: __decorate,
15193
15175
  __param: __param,
15194
- __esDecorate: __esDecorate,
15195
- __runInitializers: __runInitializers,
15196
- __propKey: __propKey,
15197
- __setFunctionName: __setFunctionName,
15198
15176
  __metadata: __metadata,
15199
15177
  __awaiter: __awaiter,
15200
15178
  __generator: __generator,
@@ -15217,7 +15195,6 @@ var tslib_es6 = {
15217
15195
  __classPrivateFieldIn: __classPrivateFieldIn,
15218
15196
  __addDisposableResource: __addDisposableResource,
15219
15197
  __disposeResources: __disposeResources,
15220
- __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
15221
15198
  };
15222
15199
 
15223
15200
  var tslib_es6$1 = /*#__PURE__*/Object.freeze({
@@ -15247,7 +15224,6 @@ var tslib_es6$1 = /*#__PURE__*/Object.freeze({
15247
15224
  __propKey: __propKey,
15248
15225
  __read: __read,
15249
15226
  __rest: __rest,
15250
- __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
15251
15227
  __runInitializers: __runInitializers,
15252
15228
  __setFunctionName: __setFunctionName,
15253
15229
  __spread: __spread,
@@ -50363,9 +50339,9 @@ var hashingExports = requireHashing();
50363
50339
 
50364
50340
  /**
50365
50341
  * @module @zk-kit/utils
50366
- * @version 1.2.1
50342
+ * @version 1.4.1
50367
50343
  * @file Essential zero-knowledge utility library for JavaScript developers.
50368
- * @copyright Ethereum Foundation 2024
50344
+ * @copyright Ethereum Foundation 2025
50369
50345
  * @license MIT
50370
50346
  * @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
50371
50347
  */
@@ -50415,9 +50391,9 @@ function isArray(value) {
50415
50391
 
50416
50392
  /**
50417
50393
  * @module @zk-kit/utils
50418
- * @version 1.2.1
50394
+ * @version 1.4.1
50419
50395
  * @file Essential zero-knowledge utility library for JavaScript developers.
50420
- * @copyright Ethereum Foundation 2024
50396
+ * @copyright Ethereum Foundation 2025
50421
50397
  * @license MIT
50422
50398
  * @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
50423
50399
  */
@@ -50484,9 +50460,9 @@ function requireArray(parameterValue, parameterName) {
50484
50460
 
50485
50461
  /**
50486
50462
  * @module @zk-kit/lean-imt
50487
- * @version 2.2.2
50463
+ * @version 2.2.4
50488
50464
  * @file Lean Incremental Merkle tree implementation in TypeScript.
50489
- * @copyright Ethereum Foundation 2024
50465
+ * @copyright Ethereum Foundation 2025
50490
50466
  * @license MIT
50491
50467
  * @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/lean-imt}
50492
50468
  */
@@ -50617,7 +50593,7 @@ class LeanIMT {
50617
50593
  throw new Error("There are no leaves to add");
50618
50594
  }
50619
50595
  let startIndex = this.size >> 1;
50620
- this._nodes[0].push(...leaves);
50596
+ this._nodes[0] = this._nodes[0].concat(leaves);
50621
50597
  // Calculate how many tree levels will need to be added
50622
50598
  // using the number of leaves.
50623
50599
  const numberOfNewLevels = Math.ceil(Math.log2(this.size)) - this.depth;
@@ -50748,7 +50724,12 @@ class LeanIMT {
50748
50724
  }
50749
50725
  // The index might be different from the original index of the leaf, since
50750
50726
  // in some cases some siblings are not included (as explained above).
50751
- return { root: this.root, leaf, index: Number.parseInt(path.reverse().join(""), 2), siblings };
50727
+ return {
50728
+ root: this.root,
50729
+ leaf,
50730
+ index: path.length === 0 ? 0 : Number.parseInt(path.reverse().join(""), 2),
50731
+ siblings
50732
+ };
50752
50733
  }
50753
50734
  /**
50754
50735
  * It verifies a {@link LeanIMTMerkleProof} to confirm that a leaf indeed
@@ -51089,10 +51070,10 @@ const circuitToAsset = {
51089
51070
 
51090
51071
  async function importFetchVersionedArtifact(isBrowser) {
51091
51072
  if (isBrowser) {
51092
- return import('./fetchArtifacts.esm-s8imnxFN.js');
51073
+ return import('./fetchArtifacts.esm-BmDEMaUO.js');
51093
51074
  }
51094
51075
  else {
51095
- return import('./fetchArtifacts.node-BwpGMlwi.js');
51076
+ return import('./fetchArtifacts.node-ClHhvnhY.js');
51096
51077
  }
51097
51078
  }
51098
51079
 
@@ -76675,6 +76656,12 @@ class AccountService {
76675
76656
  addPoolAccount(scope, value, nullifier, secret, label, blockNumber, txHash) {
76676
76657
  const precommitment = this._hashPrecommitment(nullifier, secret);
76677
76658
  const commitment = this._hashCommitment(value, label, precommitment);
76659
+ this.logger.debug(`Commitment calculation details`, {
76660
+ value,
76661
+ label,
76662
+ precommitment,
76663
+ commitment,
76664
+ });
76678
76665
  const newAccount = {
76679
76666
  label,
76680
76667
  deposit: {
@@ -76794,7 +76781,11 @@ class AccountService {
76794
76781
  });
76795
76782
  const depositMap = new Map();
76796
76783
  for (const event of depositEvents) {
76797
- depositMap.set(event.precommitment, event);
76784
+ const existingEvent = depositMap.get(event.precommitment);
76785
+ // If no existing event, or current event is older (earlier block), use current event
76786
+ if (!existingEvent || event.blockNumber < existingEvent.blockNumber) {
76787
+ depositMap.set(event.precommitment, event);
76788
+ }
76798
76789
  }
76799
76790
  return depositMap;
76800
76791
  }
@@ -76896,7 +76887,7 @@ class AccountService {
76896
76887
  *
76897
76888
  */
76898
76889
  _processDepositEvents(scope, depositEvents) {
76899
- const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid and tx failures
76890
+ const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid tx failures
76900
76891
  const foundIndices = new Set();
76901
76892
  let consecutiveMisses = 0;
76902
76893
  for (let index = BigInt(0);; index++) {
@@ -1,4 +1,4 @@
1
- export { n as AccountError, A as AccountService, B as BlockchainProvider, o as CircuitName, j as Circuits, C as CommitmentService, m as ContractError, k as ContractInteractionsService, D as DataService, E as ErrorCode, I as InvalidRpcUrl, P as PrivacyPoolSDK, l as ProofError, S as SDKError, W as WithdrawalService, e as bigintToHash, f as bigintToHex, i as calculateContext, a as generateDepositSecrets, g as generateMasterKeys, d as generateMerkleProof, b as generateWithdrawalSecrets, c as getCommitment, h as hashPrecommitment } from './index-BZkN1dA8.js';
1
+ export { n as AccountError, A as AccountService, B as BlockchainProvider, o as CircuitName, j as Circuits, C as CommitmentService, m as ContractError, k as ContractInteractionsService, D as DataService, E as ErrorCode, I as InvalidRpcUrl, P as PrivacyPoolSDK, l as ProofError, S as SDKError, W as WithdrawalService, e as bigintToHash, f as bigintToHex, i as calculateContext, a as generateDepositSecrets, g as generateMasterKeys, d as generateMerkleProof, b as generateWithdrawalSecrets, c as getCommitment, h as hashPrecommitment } from './index-BITDYIPX.js';
2
2
  import 'viem/accounts';
3
3
  import 'buffer';
4
4
  import 'http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xbow/privacy-pools-core-sdk",
3
- "version": "0.0.0-c42a71a3",
3
+ "version": "0.0.0-e101aa",
4
4
  "description": "Typescript SDK for the Privacy Pool protocol",
5
5
  "repository": "https://github.com/0xbow-io/privacy-pools-core",
6
6
  "license": "Apache-2.0",
@@ -1,27 +1,15 @@
1
- import { poseidon } from "maci-crypto/build/ts/hashing.js";
2
- import { Hash, Secret } from "../types/commitment.js";
3
- import { Hex, bytesToNumber } from "viem";
4
- import { mnemonicToAccount } from "viem/accounts";
5
- import { DataService } from "./data.service.js";
6
- import {
7
- AccountCommitment,
8
- PoolAccount,
9
- PoolInfo,
10
- PrivacyPoolAccount,
11
- } from "../types/account.js";
12
- import {
13
- DepositEvent,
14
- PoolEventsError,
15
- PoolEventsResult,
16
- RagequitEvent,
17
- WithdrawalEvent,
18
- } from "../types/events.js";
19
-
20
- import { Logger } from "../utils/logger.js";
21
- import { LogLevel } from "../utils/logger.js";
22
- import { AccountError } from "../errors/account.error.js";
23
- import { ErrorCode } from "../errors/base.error.js";
24
- import { EventError } from "../errors/events.error.js";
1
+ import {poseidon} from "maci-crypto/build/ts/hashing.js";
2
+ import {Hash, Secret} from "../types/commitment.js";
3
+ import {bytesToNumber, Hex} from "viem";
4
+ import {mnemonicToAccount} from "viem/accounts";
5
+ import {DataService} from "./data.service.js";
6
+ import {AccountCommitment, PoolAccount, PoolInfo, PrivacyPoolAccount,} from "../types/account.js";
7
+ import {DepositEvent, PoolEventsError, PoolEventsResult, RagequitEvent, WithdrawalEvent,} from "../types/events.js";
8
+
9
+ import {Logger, LogLevel} from "../utils/logger.js";
10
+ import {AccountError} from "../errors/account.error.js";
11
+ import {ErrorCode} from "../errors/base.error.js";
12
+ import {EventError} from "../errors/events.error.js";
25
13
 
26
14
  type AccountServiceConfig =
27
15
  | {
@@ -327,6 +315,13 @@ export class AccountService {
327
315
  const precommitment = this._hashPrecommitment(nullifier, secret);
328
316
  const commitment = this._hashCommitment(value, label, precommitment);
329
317
 
318
+ this.logger.debug(`Commitment calculation details`, {
319
+ value,
320
+ label,
321
+ precommitment,
322
+ commitment,
323
+ })
324
+
330
325
  const newAccount: PoolAccount = {
331
326
  label,
332
327
  deposit: {
@@ -489,7 +484,12 @@ export class AccountService {
489
484
 
490
485
  const depositMap = new Map<Hash, DepositEvent>();
491
486
  for (const event of depositEvents) {
492
- depositMap.set(event.precommitment, event);
487
+ const existingEvent = depositMap.get(event.precommitment);
488
+
489
+ // If no existing event, or current event is older (earlier block), use current event
490
+ if (!existingEvent || event.blockNumber < existingEvent.blockNumber) {
491
+ depositMap.set(event.precommitment, event);
492
+ }
493
493
  }
494
494
 
495
495
  return depositMap;
@@ -622,7 +622,7 @@ export class AccountService {
622
622
  scope: Hash,
623
623
  depositEvents: Map<Hash, DepositEvent>
624
624
  ): void {
625
- const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid and tx failures
625
+ const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid tx failures
626
626
 
627
627
  const foundIndices = new Set<bigint>();
628
628
  let consecutiveMisses = 0;