@0xbow/privacy-pools-core-sdk 0.0.0-c42a71a3 → 0.0.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 (25) hide show
  1. package/dist/esm/{fetchArtifacts.esm-DhinGr0a.js → fetchArtifacts.esm-TV4yMbDL.js} +2 -2
  2. package/dist/esm/{fetchArtifacts.esm-DhinGr0a.js.map → fetchArtifacts.esm-TV4yMbDL.js.map} +1 -1
  3. package/dist/esm/{fetchArtifacts.node-BarT-ack.js → fetchArtifacts.node-DC_rCgt3.js} +2 -2
  4. package/dist/esm/{fetchArtifacts.node-BarT-ack.js.map → fetchArtifacts.node-DC_rCgt3.js.map} +1 -1
  5. package/dist/esm/{index-ynv4K_cq.js → index-Bw-RoJy9.js} +52 -43
  6. package/dist/esm/index-Bw-RoJy9.js.map +1 -0
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/node/{fetchArtifacts.esm-aY2Tx1qe.js → fetchArtifacts.esm-i9-c1RlE.js} +2 -2
  9. package/dist/node/{fetchArtifacts.esm-aY2Tx1qe.js.map → fetchArtifacts.esm-i9-c1RlE.js.map} +1 -1
  10. package/dist/node/{fetchArtifacts.node-CF90z74C.js → fetchArtifacts.node-C5OS73zV.js} +2 -2
  11. package/dist/node/{fetchArtifacts.node-CF90z74C.js.map → fetchArtifacts.node-C5OS73zV.js.map} +1 -1
  12. package/dist/node/{index-BgfrdIiJ.js → index-BogHNKL8.js} +52 -43
  13. package/dist/node/index-BogHNKL8.js.map +1 -0
  14. package/dist/node/index.mjs +1 -1
  15. package/dist/types/{fetchArtifacts.esm-s8imnxFN.js → fetchArtifacts.esm-CwvN5XjW.js} +1 -1
  16. package/dist/types/{fetchArtifacts.node-BwpGMlwi.js → fetchArtifacts.node-VEzDC3k8.js} +1 -1
  17. package/dist/types/{index-BZkN1dA8.js → index-CPuQ9H-0.js} +51 -42
  18. package/dist/types/index.js +1 -1
  19. package/package.json +1 -1
  20. package/src/core/account.service.ts +8 -4
  21. package/src/core/contracts.service.ts +14 -2
  22. package/src/core/data.service.ts +12 -6
  23. package/src/providers/blockchainProvider.ts +7 -1
  24. package/dist/esm/index-ynv4K_cq.js.map +0 -1
  25. package/dist/node/index-BgfrdIiJ.js.map +0 -1
@@ -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-BogHNKL8.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-CPuQ9H-0.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-CPuQ9H-0.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
@@ -51028,7 +51009,13 @@ class BlockchainProvider {
51028
51009
  }
51029
51010
  this.client = createPublicClient({
51030
51011
  chain: mainnet,
51031
- transport: http(rpcUrl),
51012
+ transport: http(rpcUrl, {
51013
+ timeout: 20_000, // 20 seconds timeout for RPC requests
51014
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
51015
+ fetchOptions: {
51016
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
51017
+ },
51018
+ }),
51032
51019
  });
51033
51020
  }
51034
51021
  /** @inheritdoc */
@@ -51089,10 +51076,10 @@ const circuitToAsset = {
51089
51076
 
51090
51077
  async function importFetchVersionedArtifact(isBrowser) {
51091
51078
  if (isBrowser) {
51092
- return import('./fetchArtifacts.esm-s8imnxFN.js');
51079
+ return import('./fetchArtifacts.esm-CwvN5XjW.js');
51093
51080
  }
51094
51081
  else {
51095
- return import('./fetchArtifacts.node-BwpGMlwi.js');
51082
+ return import('./fetchArtifacts.node-VEzDC3k8.js');
51096
51083
  }
51097
51084
  }
51098
51085
 
@@ -53254,12 +53241,24 @@ class ContractInteractionsService {
53254
53241
  this.account = privateKeyToAccount(accountPrivateKey);
53255
53242
  this.walletClient = createWalletClient({
53256
53243
  chain: chain,
53257
- transport: http(rpcUrl),
53244
+ transport: http(rpcUrl, {
53245
+ timeout: 20_000, // 20 seconds timeout for RPC requests
53246
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
53247
+ fetchOptions: {
53248
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
53249
+ },
53250
+ }),
53258
53251
  account: this.account,
53259
53252
  });
53260
53253
  this.publicClient = createPublicClient({
53261
53254
  chain: chain,
53262
- transport: http(rpcUrl),
53255
+ transport: http(rpcUrl, {
53256
+ timeout: 20_000, // 20 seconds timeout for RPC requests
53257
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
53258
+ fetchOptions: {
53259
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
53260
+ },
53261
+ }),
53263
53262
  });
53264
53263
  this.entrypointAddress = entrypointAddress;
53265
53264
  }
@@ -76460,7 +76459,7 @@ class AccountService {
76460
76459
  */
76461
76460
  constructor(dataService, config) {
76462
76461
  this.dataService = dataService;
76463
- this.logger = new Logger({ prefix: "Account", level: LogLevel.DEBUG });
76462
+ this.logger = new Logger({ prefix: "Account" });
76464
76463
  if ("mnemonic" in config) {
76465
76464
  this.account = this._initializeAccount(config.mnemonic);
76466
76465
  }
@@ -76794,7 +76793,11 @@ class AccountService {
76794
76793
  });
76795
76794
  const depositMap = new Map();
76796
76795
  for (const event of depositEvents) {
76797
- depositMap.set(event.precommitment, event);
76796
+ const existingEvent = depositMap.get(event.precommitment);
76797
+ // If no existing event, or current event is older (earlier block), use current event
76798
+ if (!existingEvent || event.blockNumber < existingEvent.blockNumber) {
76799
+ depositMap.set(event.precommitment, event);
76800
+ }
76798
76801
  }
76799
76802
  return depositMap;
76800
76803
  }
@@ -76896,7 +76899,7 @@ class AccountService {
76896
76899
  *
76897
76900
  */
76898
76901
  _processDepositEvents(scope, depositEvents) {
76899
- const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid and tx failures
76902
+ const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid tx failures
76900
76903
  const foundIndices = new Set();
76901
76904
  let consecutiveMisses = 0;
76902
76905
  for (let index = BigInt(0);; index++) {
@@ -77249,7 +77252,13 @@ class DataService {
77249
77252
  throw new Error(`Missing RPC URL for chain ${config.chainId}`);
77250
77253
  }
77251
77254
  const client = createPublicClient({
77252
- transport: http(config.rpcUrl),
77255
+ transport: http(config.rpcUrl, {
77256
+ timeout: 20_000, // 20 seconds timeout for RPC requests
77257
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
77258
+ fetchOptions: {
77259
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
77260
+ },
77261
+ }),
77253
77262
  });
77254
77263
  this.clients.set(config.chainId, client);
77255
77264
  }
@@ -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-CPuQ9H-0.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",
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",
@@ -18,7 +18,6 @@ import {
18
18
  } from "../types/events.js";
19
19
 
20
20
  import { Logger } from "../utils/logger.js";
21
- import { LogLevel } from "../utils/logger.js";
22
21
  import { AccountError } from "../errors/account.error.js";
23
22
  import { ErrorCode } from "../errors/base.error.js";
24
23
  import { EventError } from "../errors/events.error.js";
@@ -57,7 +56,7 @@ export class AccountService {
57
56
  private readonly dataService: DataService,
58
57
  config: AccountServiceConfig
59
58
  ) {
60
- this.logger = new Logger({ prefix: "Account", level: LogLevel.DEBUG });
59
+ this.logger = new Logger({ prefix: "Account" });
61
60
  if ("mnemonic" in config) {
62
61
  this.account = this._initializeAccount(config.mnemonic);
63
62
  } else {
@@ -489,7 +488,12 @@ export class AccountService {
489
488
 
490
489
  const depositMap = new Map<Hash, DepositEvent>();
491
490
  for (const event of depositEvents) {
492
- depositMap.set(event.precommitment, event);
491
+ const existingEvent = depositMap.get(event.precommitment);
492
+
493
+ // If no existing event, or current event is older (earlier block), use current event
494
+ if (!existingEvent || event.blockNumber < existingEvent.blockNumber) {
495
+ depositMap.set(event.precommitment, event);
496
+ }
493
497
  }
494
498
 
495
499
  return depositMap;
@@ -622,7 +626,7 @@ export class AccountService {
622
626
  scope: Hash,
623
627
  depositEvents: Map<Hash, DepositEvent>
624
628
  ): void {
625
- const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid and tx failures
629
+ const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid tx failures
626
630
 
627
631
  const foundIndices = new Set<bigint>();
628
632
  let consecutiveMisses = 0;
@@ -55,13 +55,25 @@ export class ContractInteractionsService implements ContractInteractions {
55
55
 
56
56
  this.walletClient = createWalletClient({
57
57
  chain: chain,
58
- transport: http(rpcUrl),
58
+ transport: http(rpcUrl, {
59
+ timeout: 20_000, // 20 seconds timeout for RPC requests
60
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
61
+ fetchOptions: {
62
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
63
+ },
64
+ }),
59
65
  account: this.account,
60
66
  });
61
67
 
62
68
  this.publicClient = createPublicClient({
63
69
  chain: chain,
64
- transport: http(rpcUrl),
70
+ transport: http(rpcUrl, {
71
+ timeout: 20_000, // 20 seconds timeout for RPC requests
72
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
73
+ fetchOptions: {
74
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
75
+ },
76
+ }),
65
77
  });
66
78
 
67
79
  this.entrypointAddress = entrypointAddress;
@@ -24,7 +24,7 @@ const RAGEQUIT_EVENT = parseAbiItem('event Ragequit(address indexed _ragequitter
24
24
  /**
25
25
  * Service responsible for fetching and managing privacy pool events across multiple chains.
26
26
  * Handles event retrieval, parsing, and validation for deposits, withdrawals, and ragequits.
27
- *
27
+ *
28
28
  * @remarks
29
29
  * This service uses viem's PublicClient to efficiently fetch and process blockchain events.
30
30
  * It supports multiple chains and provides robust error handling and validation.
@@ -36,7 +36,7 @@ export class DataService {
36
36
 
37
37
  /**
38
38
  * Initialize the data service with chain configurations
39
- *
39
+ *
40
40
  * @param chainConfigs - Array of chain configurations containing chainId, RPC URL, and API key
41
41
  * @throws {DataError} If client initialization fails for any chain
42
42
  */
@@ -50,7 +50,13 @@ export class DataService {
50
50
  }
51
51
 
52
52
  const client = createPublicClient({
53
- transport: http(config.rpcUrl),
53
+ transport: http(config.rpcUrl, {
54
+ timeout: 20_000, // 20 seconds timeout for RPC requests
55
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
56
+ fetchOptions: {
57
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
58
+ },
59
+ }),
54
60
  });
55
61
  this.clients.set(config.chainId, client);
56
62
  }
@@ -65,7 +71,7 @@ export class DataService {
65
71
 
66
72
  /**
67
73
  * Get deposit events for a specific chain
68
- *
74
+ *
69
75
  * @param chainId - Chain ID to fetch events from
70
76
  * @param options - Event filter options including fromBlock, toBlock, and other filters
71
77
  * @returns Array of deposit events with properly typed fields (bigint for numbers, Hash for commitments)
@@ -130,7 +136,7 @@ export class DataService {
130
136
 
131
137
  /**
132
138
  * Get withdrawal events for a specific chain
133
- *
139
+ *
134
140
  * @param chainId - Chain ID to fetch events from
135
141
  * @param options - Event filter options including fromBlock, toBlock, and other filters
136
142
  * @returns Array of withdrawal events with properly typed fields (bigint for numbers, Hash for commitments)
@@ -192,7 +198,7 @@ export class DataService {
192
198
 
193
199
  /**
194
200
  * Get ragequit events for a specific chain
195
- *
201
+ *
196
202
  * @param chainId - Chain ID to fetch events from
197
203
  * @param options - Event filter options including fromBlock, toBlock, and other filters
198
204
  * @returns Array of ragequit events with properly typed fields (bigint for numbers, Hash for commitments)
@@ -15,7 +15,13 @@ export class BlockchainProvider implements IBlockchainProvider {
15
15
 
16
16
  this.client = createPublicClient({
17
17
  chain: mainnet,
18
- transport: http(rpcUrl),
18
+ transport: http(rpcUrl, {
19
+ timeout: 20_000, // 20 seconds timeout for RPC requests
20
+ retryCount: 0, // Disable retries to prevent multiple timeout attempts
21
+ fetchOptions: {
22
+ signal: AbortSignal.timeout(20_000), // Explicit fetch timeout at 20 seconds
23
+ },
24
+ }),
19
25
  });
20
26
  }
21
27