@0xbow/privacy-pools-core-sdk 1.0.4 → 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-C_DNv-_D.js → fetchArtifacts.esm-B6qveiM8.js} +2 -2
- package/dist/esm/{fetchArtifacts.esm-C_DNv-_D.js.map → fetchArtifacts.esm-B6qveiM8.js.map} +1 -1
- package/dist/esm/{fetchArtifacts.node-BBPNjgiT.js → fetchArtifacts.node-BPQQPsnb.js} +2 -2
- package/dist/esm/{fetchArtifacts.node-BBPNjgiT.js.map → fetchArtifacts.node-BPQQPsnb.js.map} +1 -1
- package/dist/esm/{index-BxzIe_IR.js → index-CRtEyHEf.js} +2884 -107
- package/dist/esm/index-CRtEyHEf.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-z-KXbilc.js} +2 -2
- package/dist/node/{fetchArtifacts.esm-l-EDo53-.js.map → fetchArtifacts.esm-z-KXbilc.js.map} +1 -1
- package/dist/node/{fetchArtifacts.node-DYwQHSF4.js → fetchArtifacts.node-DvqhqpW9.js} +2 -2
- package/dist/node/{fetchArtifacts.node-DYwQHSF4.js.map → fetchArtifacts.node-DvqhqpW9.js.map} +1 -1
- package/dist/node/{index-DGsIfUGw.js → index-BsmEKESv.js} +2884 -107
- package/dist/node/index-BsmEKESv.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-DF01Zpo3.js} +1 -1
- package/dist/types/{fetchArtifacts.node-BcXsBNCT.js → fetchArtifacts.node-BO6FBCAw.js} +1 -1
- package/dist/types/{index-DbuAhDci.js → index-CH7gk4sK.js} +2883 -106
- 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 +324 -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/esm/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-CRtEyHEf.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'assert';
|
package/dist/index.d.mts
CHANGED
|
@@ -84,6 +84,58 @@ interface MasterKeys {
|
|
|
84
84
|
masterSecret: Secret;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Configuration options for rate-limited log fetching
|
|
89
|
+
*/
|
|
90
|
+
interface LogFetchConfig {
|
|
91
|
+
/**
|
|
92
|
+
* Maximum number of blocks to fetch in a single RPC call.
|
|
93
|
+
* Default: 10000 (typical limit for most RPC providers)
|
|
94
|
+
*/
|
|
95
|
+
blockChunkSize: number;
|
|
96
|
+
/**
|
|
97
|
+
* Maximum number of concurrent log fetch operations.
|
|
98
|
+
* Default: 3
|
|
99
|
+
*/
|
|
100
|
+
concurrency: number;
|
|
101
|
+
/**
|
|
102
|
+
* Delay in milliseconds between chunk requests (for additional throttling).
|
|
103
|
+
* Default: 0 (no delay)
|
|
104
|
+
*/
|
|
105
|
+
chunkDelayMs: number;
|
|
106
|
+
/**
|
|
107
|
+
* Whether to retry failed chunk fetches.
|
|
108
|
+
* Default: true
|
|
109
|
+
*/
|
|
110
|
+
retryOnFailure: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Maximum number of retries for a failed chunk.
|
|
113
|
+
* Default: 3
|
|
114
|
+
*/
|
|
115
|
+
maxRetries: number;
|
|
116
|
+
/**
|
|
117
|
+
* Base delay for exponential backoff on retries (ms).
|
|
118
|
+
* Default: 1000
|
|
119
|
+
*/
|
|
120
|
+
retryBaseDelayMs: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Default log fetch configuration
|
|
124
|
+
*/
|
|
125
|
+
declare const DEFAULT_LOG_FETCH_CONFIG: LogFetchConfig;
|
|
126
|
+
/**
|
|
127
|
+
* Per-chain log fetch configuration map
|
|
128
|
+
* Maps chainId to its specific LogFetchConfig
|
|
129
|
+
*/
|
|
130
|
+
type ChainLogFetchConfig = Map<number, Partial<LogFetchConfig>>;
|
|
131
|
+
/**
|
|
132
|
+
* Block range for chunked fetching
|
|
133
|
+
*/
|
|
134
|
+
interface BlockRange {
|
|
135
|
+
fromBlock: bigint;
|
|
136
|
+
toBlock: bigint;
|
|
137
|
+
}
|
|
138
|
+
|
|
87
139
|
/**
|
|
88
140
|
* Generates two master keys based on some provided seed or a random value.
|
|
89
141
|
*
|
|
@@ -841,18 +893,20 @@ declare class DataService {
|
|
|
841
893
|
private readonly chainConfigs;
|
|
842
894
|
private readonly clients;
|
|
843
895
|
private readonly logger;
|
|
896
|
+
private readonly logFetchConfigs;
|
|
844
897
|
/**
|
|
845
898
|
* Initialize the data service with chain configurations
|
|
846
899
|
*
|
|
847
900
|
* @param chainConfigs - Array of chain configurations containing chainId, RPC URL, and API key
|
|
901
|
+
* @param logFetchConfig - Per-chain configuration for rate-limited log fetching as a Map<chainId, config>.
|
|
902
|
+
* Each chain can have its own specific settings (e.g., different block chunk sizes).
|
|
848
903
|
* @throws {DataError} If client initialization fails for any chain
|
|
849
904
|
*/
|
|
850
|
-
constructor(chainConfigs: ChainConfig[]);
|
|
905
|
+
constructor(chainConfigs: ChainConfig[], logFetchConfig?: ChainLogFetchConfig);
|
|
851
906
|
/**
|
|
852
907
|
* Get deposit events for a specific chain
|
|
853
908
|
*
|
|
854
|
-
* @param
|
|
855
|
-
* @param options - Event filter options including fromBlock, toBlock, and other filters
|
|
909
|
+
* @param pool - Pool info containing chainId, address, and deployment block
|
|
856
910
|
* @returns Array of deposit events with properly typed fields (bigint for numbers, Hash for commitments)
|
|
857
911
|
* @throws {DataError} If client is not configured, network error occurs, or event data is invalid
|
|
858
912
|
*/
|
|
@@ -860,8 +914,8 @@ declare class DataService {
|
|
|
860
914
|
/**
|
|
861
915
|
* Get withdrawal events for a specific chain
|
|
862
916
|
*
|
|
863
|
-
* @param
|
|
864
|
-
* @param
|
|
917
|
+
* @param pool - Pool info containing chainId, address, and deployment block
|
|
918
|
+
* @param fromBlock - Optional starting block (defaults to pool deployment block)
|
|
865
919
|
* @returns Array of withdrawal events with properly typed fields (bigint for numbers, Hash for commitments)
|
|
866
920
|
* @throws {DataError} If client is not configured, network error occurs, or event data is invalid
|
|
867
921
|
*/
|
|
@@ -869,20 +923,39 @@ declare class DataService {
|
|
|
869
923
|
/**
|
|
870
924
|
* Get ragequit events for a specific chain
|
|
871
925
|
*
|
|
872
|
-
* @param
|
|
873
|
-
* @param
|
|
926
|
+
* @param pool - Pool info containing chainId, address, and deployment block
|
|
927
|
+
* @param fromBlock - Optional starting block (defaults to pool deployment block)
|
|
874
928
|
* @returns Array of ragequit events with properly typed fields (bigint for numbers, Hash for commitments)
|
|
875
929
|
* @throws {DataError} If client is not configured, network error occurs, or event data is invalid
|
|
876
930
|
*/
|
|
877
931
|
getRagequits(pool: PoolInfo, fromBlock?: bigint): Promise<RagequitEvent[]>;
|
|
932
|
+
/**
|
|
933
|
+
* Gets the current block number for a chain
|
|
934
|
+
*/
|
|
935
|
+
private getCurrentBlock;
|
|
936
|
+
/**
|
|
937
|
+
* Generates block ranges for chunked fetching
|
|
938
|
+
*/
|
|
939
|
+
private generateBlockRanges;
|
|
940
|
+
/**
|
|
941
|
+
* Fetches logs for a single block range with retry logic
|
|
942
|
+
*/
|
|
943
|
+
private fetchLogsWithRetry;
|
|
944
|
+
/**
|
|
945
|
+
* Helper to add delay between requests
|
|
946
|
+
*/
|
|
947
|
+
private sleep;
|
|
878
948
|
private getClientForChain;
|
|
879
949
|
private getConfigForChain;
|
|
950
|
+
private getLogFetchConfigForChain;
|
|
880
951
|
}
|
|
881
952
|
|
|
882
953
|
type AccountServiceConfig = {
|
|
883
954
|
mnemonic: string;
|
|
955
|
+
poolConcurrency?: number;
|
|
884
956
|
} | {
|
|
885
957
|
account: PrivacyPoolAccount;
|
|
958
|
+
poolConcurrency?: number;
|
|
886
959
|
};
|
|
887
960
|
/**
|
|
888
961
|
* Service responsible for managing privacy pool accounts and their associated commitments.
|
|
@@ -896,6 +969,7 @@ declare class AccountService {
|
|
|
896
969
|
private readonly dataService;
|
|
897
970
|
account: PrivacyPoolAccount;
|
|
898
971
|
private readonly logger;
|
|
972
|
+
private readonly poolConcurrency;
|
|
899
973
|
/**
|
|
900
974
|
* Creates a new AccountService instance.
|
|
901
975
|
*
|
|
@@ -903,6 +977,7 @@ declare class AccountService {
|
|
|
903
977
|
* @param config - Configuration for the account service (either mnemonic or existing account)
|
|
904
978
|
* @param config.mnemonic - Optional mnemonic for deterministic key generation
|
|
905
979
|
* @param config.account - Optional existing account to initialize with
|
|
980
|
+
* @param config.poolConcurrency - Optional maximum number of pools to fetch events for concurrently (default: 2)
|
|
906
981
|
*
|
|
907
982
|
* @throws {AccountError} If account initialization fails
|
|
908
983
|
*/
|
|
@@ -1099,14 +1174,13 @@ declare class AccountService {
|
|
|
1099
1174
|
*/
|
|
1100
1175
|
getRagequitEvents(pool: PoolInfo): Promise<Map<Hash, RagequitEvent>>;
|
|
1101
1176
|
/**
|
|
1102
|
-
* Fetches events for a given set of pools
|
|
1177
|
+
* Fetches events for a given set of pools
|
|
1103
1178
|
*
|
|
1104
1179
|
* @param pools - The pools to fetch events for
|
|
1105
|
-
* @param maxConcurrency - Maximum number of concurrent pool fetches (default: 5)
|
|
1106
1180
|
*
|
|
1107
1181
|
* @returns A map of pool scopes to their events
|
|
1108
1182
|
*/
|
|
1109
|
-
getEvents(pools: PoolInfo[]
|
|
1183
|
+
getEvents(pools: PoolInfo[]): Promise<PoolEventsResult>;
|
|
1110
1184
|
/**
|
|
1111
1185
|
* Processes deposit events for a given scope and adds them to the account
|
|
1112
1186
|
* Deterministically generate deposit secrets and check if they match on-chain deposits
|
|
@@ -1156,11 +1230,10 @@ declare class AccountService {
|
|
|
1156
1230
|
* @param dataService - The data service to use for fetching events
|
|
1157
1231
|
* @param source - The source to use for initializing the account. Either a mnemonic or an existing account service instance
|
|
1158
1232
|
* @param pools - The pools to fetch events for
|
|
1159
|
-
* @param maxConcurrency - Maximum number of concurrent pool fetches (default: 5)
|
|
1160
1233
|
*
|
|
1161
1234
|
* @remarks
|
|
1162
1235
|
* This method performs the following steps for each pool:
|
|
1163
|
-
* 1. Fetches deposit, withdrawal, and ragequit events for each pool
|
|
1236
|
+
* 1. Fetches deposit, withdrawal, and ragequit events for each pool
|
|
1164
1237
|
* 2. Processes deposit events and creates pool accounts
|
|
1165
1238
|
* 3. Processes withdrawal events and adds commitments to pool accounts
|
|
1166
1239
|
* 4. Processes ragequit events and adds ragequit to pool accounts
|
|
@@ -1176,7 +1249,7 @@ declare class AccountService {
|
|
|
1176
1249
|
mnemonic: string;
|
|
1177
1250
|
} | {
|
|
1178
1251
|
service: AccountService;
|
|
1179
|
-
}, pools: PoolInfo[]
|
|
1252
|
+
}, pools: PoolInfo[]): Promise<{
|
|
1180
1253
|
account: AccountService;
|
|
1181
1254
|
errors: PoolEventsError[];
|
|
1182
1255
|
}>;
|
|
@@ -1221,4 +1294,4 @@ declare class AccountService {
|
|
|
1221
1294
|
private _processWithdrawalsAndRagequits;
|
|
1222
1295
|
}
|
|
1223
1296
|
|
|
1224
|
-
export { type AccountCommitment, AccountError, AccountService, BlockchainProvider, type ChainConfig, CircuitName, type CircuitSignals, Circuits, type CircuitsInterface, type Commitment, type CommitmentPreimage, type CommitmentProof, CommitmentService, ContractError, ContractInteractionsService, DataService, type DepositEvent, ErrorCode, type EventFilterOptions, type Hash, type IBlockchainProvider, InvalidRpcUrl, type MasterKeys, type PoolAccount, type PoolEvents, type PoolEventsError, type PoolEventsResult, type PoolEventsSuccess, type PoolInfo, type Precommitment, type PrivacyPoolAccount, PrivacyPoolSDK, type ProcessedDepositEventsResult, ProofError, type RagequitEvent, SDKError, type Secret, type Withdrawal, type WithdrawalEvent, type WithdrawalProof, type WithdrawalProofInput, WithdrawalService, bigintToHash, bigintToHex, calculateContext, generateDepositSecrets, generateMasterKeys, generateMerkleProof, generateWithdrawalSecrets, getCommitment, hashPrecommitment };
|
|
1297
|
+
export { type AccountCommitment, AccountError, AccountService, type BlockRange, BlockchainProvider, type ChainConfig, type ChainLogFetchConfig, CircuitName, type CircuitSignals, Circuits, type CircuitsInterface, type Commitment, type CommitmentPreimage, type CommitmentProof, CommitmentService, ContractError, ContractInteractionsService, DEFAULT_LOG_FETCH_CONFIG, DataService, type DepositEvent, ErrorCode, type EventFilterOptions, type Hash, type IBlockchainProvider, InvalidRpcUrl, type LogFetchConfig, type MasterKeys, type PoolAccount, type PoolEvents, type PoolEventsError, type PoolEventsResult, type PoolEventsSuccess, type PoolInfo, type Precommitment, type PrivacyPoolAccount, PrivacyPoolSDK, type ProcessedDepositEventsResult, ProofError, type RagequitEvent, SDKError, type Secret, type Withdrawal, type WithdrawalEvent, type WithdrawalProof, type WithdrawalProofInput, WithdrawalService, bigintToHash, bigintToHex, calculateContext, generateDepositSecrets, generateMasterKeys, generateMerkleProof, generateWithdrawalSecrets, getCommitment, hashPrecommitment };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchArtifact } from './index-
|
|
1
|
+
import { F as FetchArtifact } from './index-BsmEKESv.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'http';
|
|
@@ -32,4 +32,4 @@ async function fetchVersionedArtifact(artifactUrl) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export { fetchVersionedArtifact };
|
|
35
|
-
//# sourceMappingURL=fetchArtifacts.esm-
|
|
35
|
+
//# sourceMappingURL=fetchArtifacts.esm-z-KXbilc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchArtifacts.esm-
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.esm-z-KXbilc.js","sources":["../../src/circuits/fetchArtifacts.esm.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEO,eAAe,sBAAsB,CAC1C,WAAgB,EAAA;AAEhB,IAAA,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC;AACpC,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;AACtB,QAAA,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC;;AAEtC,IAAA,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE;AACpC,IAAA,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC;AAC7B;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchArtifact } from './index-
|
|
1
|
+
import { F as FetchArtifact } from './index-BsmEKESv.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'http';
|
|
@@ -45,4 +45,4 @@ async function fetchVersionedArtifact(artifactUrl) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export { fetchVersionedArtifact };
|
|
48
|
-
//# sourceMappingURL=fetchArtifacts.node-
|
|
48
|
+
//# sourceMappingURL=fetchArtifacts.node-DvqhqpW9.js.map
|
package/dist/node/{fetchArtifacts.node-DYwQHSF4.js.map → fetchArtifacts.node-DvqhqpW9.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchArtifacts.node-
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.node-DvqhqpW9.js","sources":["../../src/circuits/fetchArtifacts.node.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEO,eAAe,sBAAsB,CAC1C,WAAgB,EAAA;AAEhB,IAAA,IAAI;QACF,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,IAAI,CAAC,EAAE,OAAO;QACvC,MAAM,WAAW,GAAoB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACnE,YAAA,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,KAAI;gBAC9C,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC;;qBACN;oBACL,OAAO,CAAC,IAAI,CAAC;;AAEjB,aAAC,CAAC;AACJ,SAAC,CAAC;AACF,QAAA,MAAM,GAAG,GAAG,MAAM,WAAW;AAC7B,QAAA,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC;;IAC1B,OAAO,KAAK,EAAE;AACd,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACpB,QAAA,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC;;AAExC;;;;"}
|