@0xbow/privacy-pools-core-sdk 1.0.3 → 1.1.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 (33) hide show
  1. package/dist/esm/{fetchArtifacts.esm-aHubC6Nb.js → fetchArtifacts.esm-B6qveiM8.js} +2 -2
  2. package/dist/esm/{fetchArtifacts.esm-aHubC6Nb.js.map → fetchArtifacts.esm-B6qveiM8.js.map} +1 -1
  3. package/dist/esm/{fetchArtifacts.node-DUdhNM9Z.js → fetchArtifacts.node-BPQQPsnb.js} +2 -2
  4. package/dist/esm/{fetchArtifacts.node-DUdhNM9Z.js.map → fetchArtifacts.node-BPQQPsnb.js.map} +1 -1
  5. package/dist/esm/{index-BQLhaPQL.js → index-CRtEyHEf.js} +2880 -78
  6. package/dist/esm/index-CRtEyHEf.js.map +1 -0
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/index.d.mts +83 -8
  9. package/dist/node/{fetchArtifacts.esm-CRX34p8g.js → fetchArtifacts.esm-z-KXbilc.js} +2 -2
  10. package/dist/node/{fetchArtifacts.esm-CRX34p8g.js.map → fetchArtifacts.esm-z-KXbilc.js.map} +1 -1
  11. package/dist/node/{fetchArtifacts.node-CuPs4jZ1.js → fetchArtifacts.node-DvqhqpW9.js} +2 -2
  12. package/dist/node/{fetchArtifacts.node-CuPs4jZ1.js.map → fetchArtifacts.node-DvqhqpW9.js.map} +1 -1
  13. package/dist/node/{index-DB1uYJPF.js → index-BsmEKESv.js} +2880 -78
  14. package/dist/node/index-BsmEKESv.js.map +1 -0
  15. package/dist/node/index.mjs +1 -1
  16. package/dist/types/core/account.service.d.ts +4 -0
  17. package/dist/types/core/data.service.d.ts +28 -8
  18. package/dist/types/{fetchArtifacts.esm-CzBDJOwj.js → fetchArtifacts.esm-DF01Zpo3.js} +1 -1
  19. package/dist/types/{fetchArtifacts.node-CtMsXhR9.js → fetchArtifacts.node-BO6FBCAw.js} +1 -1
  20. package/dist/types/{index-BL6xN-P5.js → index-CH7gk4sK.js} +2879 -77
  21. package/dist/types/index.js +1 -1
  22. package/dist/types/types/index.d.ts +1 -0
  23. package/dist/types/types/rateLimit.d.ts +51 -0
  24. package/package.json +4 -1
  25. package/src/core/account.service.ts +46 -24
  26. package/src/core/contracts.service.ts +2 -6
  27. package/src/core/data.service.ts +324 -95
  28. package/src/providers/blockchainProvider.ts +1 -3
  29. package/src/types/index.ts +1 -0
  30. package/src/types/rateLimit.ts +66 -0
  31. package/dist/esm/index-BQLhaPQL.js.map +0 -1
  32. package/dist/node/index-DB1uYJPF.js.map +0 -1
  33. package/dist/types/core/test.d.ts +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-DB1uYJPF.js';
1
+ export { o as AccountError, A as AccountService, B as BlockchainProvider, p as CircuitName, k as Circuits, C as CommitmentService, n as ContractError, l as ContractInteractionsService, a as DEFAULT_LOG_FETCH_CONFIG, D as DataService, E as ErrorCode, I as InvalidRpcUrl, P as PrivacyPoolSDK, m as ProofError, S as SDKError, W as WithdrawalService, f as bigintToHash, i as bigintToHex, j as calculateContext, b as generateDepositSecrets, g as generateMasterKeys, e as generateMerkleProof, c as generateWithdrawalSecrets, d as getCommitment, h as hashPrecommitment } from './index-BsmEKESv.js';
2
2
  import 'viem/accounts';
3
3
  import 'buffer';
4
4
  import 'http';
@@ -5,8 +5,10 @@ import { AccountCommitment, PoolAccount, PoolInfo, PrivacyPoolAccount } from "..
5
5
  import { DepositEvent, PoolEventsError, PoolEventsResult, RagequitEvent, WithdrawalEvent } from "../types/events.js";
6
6
  type AccountServiceConfig = {
7
7
  mnemonic: string;
8
+ poolConcurrency?: number;
8
9
  } | {
9
10
  account: PrivacyPoolAccount;
11
+ poolConcurrency?: number;
10
12
  };
11
13
  /**
12
14
  * Service responsible for managing privacy pool accounts and their associated commitments.
@@ -20,6 +22,7 @@ export declare class AccountService {
20
22
  private readonly dataService;
21
23
  account: PrivacyPoolAccount;
22
24
  private readonly logger;
25
+ private readonly poolConcurrency;
23
26
  /**
24
27
  * Creates a new AccountService instance.
25
28
  *
@@ -27,6 +30,7 @@ export declare class AccountService {
27
30
  * @param config - Configuration for the account service (either mnemonic or existing account)
28
31
  * @param config.mnemonic - Optional mnemonic for deterministic key generation
29
32
  * @param config.account - Optional existing account to initialize with
33
+ * @param config.poolConcurrency - Optional maximum number of pools to fetch events for concurrently (default: 2)
30
34
  *
31
35
  * @throws {AccountError} If account initialization fails
32
36
  */
@@ -1,5 +1,6 @@
1
- import { ChainConfig, DepositEvent, WithdrawalEvent, RagequitEvent } from "../types/events.js";
1
+ import { ChainConfig, DepositEvent, RagequitEvent, WithdrawalEvent } from "../types/events.js";
2
2
  import { PoolInfo } from "../types/account.js";
3
+ import { ChainLogFetchConfig } from "../types/rateLimit.js";
3
4
  /**
4
5
  * Service responsible for fetching and managing privacy pool events across multiple chains.
5
6
  * Handles event retrieval, parsing, and validation for deposits, withdrawals, and ragequits.
@@ -13,18 +14,20 @@ export declare class DataService {
13
14
  private readonly chainConfigs;
14
15
  private readonly clients;
15
16
  private readonly logger;
17
+ private readonly logFetchConfigs;
16
18
  /**
17
19
  * Initialize the data service with chain configurations
18
20
  *
19
21
  * @param chainConfigs - Array of chain configurations containing chainId, RPC URL, and API key
22
+ * @param logFetchConfig - Per-chain configuration for rate-limited log fetching as a Map<chainId, config>.
23
+ * Each chain can have its own specific settings (e.g., different block chunk sizes).
20
24
  * @throws {DataError} If client initialization fails for any chain
21
25
  */
22
- constructor(chainConfigs: ChainConfig[]);
26
+ constructor(chainConfigs: ChainConfig[], logFetchConfig?: ChainLogFetchConfig);
23
27
  /**
24
28
  * Get deposit events for a specific chain
25
29
  *
26
- * @param chainId - Chain ID to fetch events from
27
- * @param options - Event filter options including fromBlock, toBlock, and other filters
30
+ * @param pool - Pool info containing chainId, address, and deployment block
28
31
  * @returns Array of deposit events with properly typed fields (bigint for numbers, Hash for commitments)
29
32
  * @throws {DataError} If client is not configured, network error occurs, or event data is invalid
30
33
  */
@@ -32,8 +35,8 @@ export declare class DataService {
32
35
  /**
33
36
  * Get withdrawal events for a specific chain
34
37
  *
35
- * @param chainId - Chain ID to fetch events from
36
- * @param options - Event filter options including fromBlock, toBlock, and other filters
38
+ * @param pool - Pool info containing chainId, address, and deployment block
39
+ * @param fromBlock - Optional starting block (defaults to pool deployment block)
37
40
  * @returns Array of withdrawal events with properly typed fields (bigint for numbers, Hash for commitments)
38
41
  * @throws {DataError} If client is not configured, network error occurs, or event data is invalid
39
42
  */
@@ -41,12 +44,29 @@ export declare class DataService {
41
44
  /**
42
45
  * Get ragequit events for a specific chain
43
46
  *
44
- * @param chainId - Chain ID to fetch events from
45
- * @param options - Event filter options including fromBlock, toBlock, and other filters
47
+ * @param pool - Pool info containing chainId, address, and deployment block
48
+ * @param fromBlock - Optional starting block (defaults to pool deployment block)
46
49
  * @returns Array of ragequit events with properly typed fields (bigint for numbers, Hash for commitments)
47
50
  * @throws {DataError} If client is not configured, network error occurs, or event data is invalid
48
51
  */
49
52
  getRagequits(pool: PoolInfo, fromBlock?: bigint): Promise<RagequitEvent[]>;
53
+ /**
54
+ * Gets the current block number for a chain
55
+ */
56
+ private getCurrentBlock;
57
+ /**
58
+ * Generates block ranges for chunked fetching
59
+ */
60
+ private generateBlockRanges;
61
+ /**
62
+ * Fetches logs for a single block range with retry logic
63
+ */
64
+ private fetchLogsWithRetry;
65
+ /**
66
+ * Helper to add delay between requests
67
+ */
68
+ private sleep;
50
69
  private getClientForChain;
51
70
  private getConfigForChain;
71
+ private getLogFetchConfigForChain;
52
72
  }
@@ -1,4 +1,4 @@
1
- import { F as FetchArtifact } from './index-BL6xN-P5.js';
1
+ import { F as FetchArtifact } from './index-CH7gk4sK.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-BL6xN-P5.js';
1
+ import { F as FetchArtifact } from './index-CH7gk4sK.js';
2
2
  import 'viem/accounts';
3
3
  import 'buffer';
4
4
  import 'http';