@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.
- package/dist/esm/{fetchArtifacts.esm-aHubC6Nb.js → fetchArtifacts.esm-B6qveiM8.js} +2 -2
- package/dist/esm/{fetchArtifacts.esm-aHubC6Nb.js.map → fetchArtifacts.esm-B6qveiM8.js.map} +1 -1
- package/dist/esm/{fetchArtifacts.node-DUdhNM9Z.js → fetchArtifacts.node-BPQQPsnb.js} +2 -2
- package/dist/esm/{fetchArtifacts.node-DUdhNM9Z.js.map → fetchArtifacts.node-BPQQPsnb.js.map} +1 -1
- package/dist/esm/{index-BQLhaPQL.js → index-CRtEyHEf.js} +2880 -78
- package/dist/esm/index-CRtEyHEf.js.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/index.d.mts +83 -8
- package/dist/node/{fetchArtifacts.esm-CRX34p8g.js → fetchArtifacts.esm-z-KXbilc.js} +2 -2
- package/dist/node/{fetchArtifacts.esm-CRX34p8g.js.map → fetchArtifacts.esm-z-KXbilc.js.map} +1 -1
- package/dist/node/{fetchArtifacts.node-CuPs4jZ1.js → fetchArtifacts.node-DvqhqpW9.js} +2 -2
- package/dist/node/{fetchArtifacts.node-CuPs4jZ1.js.map → fetchArtifacts.node-DvqhqpW9.js.map} +1 -1
- package/dist/node/{index-DB1uYJPF.js → index-BsmEKESv.js} +2880 -78
- package/dist/node/index-BsmEKESv.js.map +1 -0
- package/dist/node/index.mjs +1 -1
- package/dist/types/core/account.service.d.ts +4 -0
- package/dist/types/core/data.service.d.ts +28 -8
- package/dist/types/{fetchArtifacts.esm-CzBDJOwj.js → fetchArtifacts.esm-DF01Zpo3.js} +1 -1
- package/dist/types/{fetchArtifacts.node-CtMsXhR9.js → fetchArtifacts.node-BO6FBCAw.js} +1 -1
- package/dist/types/{index-BL6xN-P5.js → index-CH7gk4sK.js} +2879 -77
- package/dist/types/index.js +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/rateLimit.d.ts +51 -0
- package/package.json +4 -1
- package/src/core/account.service.ts +46 -24
- package/src/core/contracts.service.ts +2 -6
- package/src/core/data.service.ts +324 -95
- package/src/providers/blockchainProvider.ts +1 -3
- package/src/types/index.ts +1 -0
- package/src/types/rateLimit.ts +66 -0
- package/dist/esm/index-BQLhaPQL.js.map +0 -1
- package/dist/node/index-DB1uYJPF.js.map +0 -1
- package/dist/types/core/test.d.ts +0 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
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,
|
|
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
|
|
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
|
|
36
|
-
* @param
|
|
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
|
|
45
|
-
* @param
|
|
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
|
}
|