@0xbow/privacy-pools-core-sdk 1.0.4 → 1.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.
- package/dist/esm/{fetchArtifacts.esm-C_DNv-_D.js → fetchArtifacts.esm-DbVRphob.js} +2 -2
- package/dist/esm/{fetchArtifacts.esm-C_DNv-_D.js.map → fetchArtifacts.esm-DbVRphob.js.map} +1 -1
- package/dist/esm/{fetchArtifacts.node-BBPNjgiT.js → fetchArtifacts.node-D-fJGtzV.js} +2 -2
- package/dist/esm/{fetchArtifacts.node-BBPNjgiT.js.map → fetchArtifacts.node-D-fJGtzV.js.map} +1 -1
- package/dist/esm/{index-BxzIe_IR.js → index-DkNRxKxP.js} +2889 -109
- package/dist/esm/index-DkNRxKxP.js.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/index.d.mts +87 -14
- package/dist/node/{fetchArtifacts.esm-l-EDo53-.js → fetchArtifacts.esm-BIT-b_1_.js} +2 -2
- package/dist/node/{fetchArtifacts.esm-l-EDo53-.js.map → fetchArtifacts.esm-BIT-b_1_.js.map} +1 -1
- package/dist/node/{fetchArtifacts.node-DYwQHSF4.js → fetchArtifacts.node-CKwwU50E.js} +2 -2
- package/dist/node/{fetchArtifacts.node-DYwQHSF4.js.map → fetchArtifacts.node-CKwwU50E.js.map} +1 -1
- package/dist/node/{index-DGsIfUGw.js → index-C3RV9Cri.js} +2889 -109
- package/dist/node/index-C3RV9Cri.js.map +1 -0
- package/dist/node/index.mjs +1 -1
- package/dist/types/core/account.service.d.ts +8 -6
- package/dist/types/core/data.service.d.ts +28 -8
- package/dist/types/{fetchArtifacts.esm-IMTIZwq7.js → fetchArtifacts.esm-DT5RuODl.js} +1 -1
- package/dist/types/{fetchArtifacts.node-BcXsBNCT.js → fetchArtifacts.node-D_iVIPqW.js} +1 -1
- package/dist/types/{index-DbuAhDci.js → index-CHy3YamH.js} +2888 -108
- 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 -2
- package/src/core/account.service.ts +52 -39
- package/src/core/data.service.ts +325 -95
- package/src/types/index.ts +1 -0
- package/src/types/rateLimit.ts +66 -0
- package/dist/esm/index-BxzIe_IR.js.map +0 -1
- package/dist/node/index-DGsIfUGw.js.map +0 -1
- package/dist/types/utils/concurrency.d.ts +0 -15
- package/src/utils/concurrency.ts +0 -32
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-C3RV9Cri.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
|
*/
|
|
@@ -223,14 +227,13 @@ export declare class AccountService {
|
|
|
223
227
|
*/
|
|
224
228
|
getRagequitEvents(pool: PoolInfo): Promise<Map<Hash, RagequitEvent>>;
|
|
225
229
|
/**
|
|
226
|
-
* Fetches events for a given set of pools
|
|
230
|
+
* Fetches events for a given set of pools
|
|
227
231
|
*
|
|
228
232
|
* @param pools - The pools to fetch events for
|
|
229
|
-
* @param maxConcurrency - Maximum number of concurrent pool fetches (default: 5)
|
|
230
233
|
*
|
|
231
234
|
* @returns A map of pool scopes to their events
|
|
232
235
|
*/
|
|
233
|
-
getEvents(pools: PoolInfo[]
|
|
236
|
+
getEvents(pools: PoolInfo[]): Promise<PoolEventsResult>;
|
|
234
237
|
/**
|
|
235
238
|
* Processes deposit events for a given scope and adds them to the account
|
|
236
239
|
* Deterministically generate deposit secrets and check if they match on-chain deposits
|
|
@@ -280,11 +283,10 @@ export declare class AccountService {
|
|
|
280
283
|
* @param dataService - The data service to use for fetching events
|
|
281
284
|
* @param source - The source to use for initializing the account. Either a mnemonic or an existing account service instance
|
|
282
285
|
* @param pools - The pools to fetch events for
|
|
283
|
-
* @param maxConcurrency - Maximum number of concurrent pool fetches (default: 5)
|
|
284
286
|
*
|
|
285
287
|
* @remarks
|
|
286
288
|
* This method performs the following steps for each pool:
|
|
287
|
-
* 1. Fetches deposit, withdrawal, and ragequit events for each pool
|
|
289
|
+
* 1. Fetches deposit, withdrawal, and ragequit events for each pool
|
|
288
290
|
* 2. Processes deposit events and creates pool accounts
|
|
289
291
|
* 3. Processes withdrawal events and adds commitments to pool accounts
|
|
290
292
|
* 4. Processes ragequit events and adds ragequit to pool accounts
|
|
@@ -300,7 +302,7 @@ export declare class AccountService {
|
|
|
300
302
|
mnemonic: string;
|
|
301
303
|
} | {
|
|
302
304
|
service: AccountService;
|
|
303
|
-
}, pools: PoolInfo[]
|
|
305
|
+
}, pools: PoolInfo[]): Promise<{
|
|
304
306
|
account: AccountService;
|
|
305
307
|
errors: PoolEventsError[];
|
|
306
308
|
}>;
|
|
@@ -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
|
}
|