@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/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
|
*/
|
|
@@ -1219,4 +1294,4 @@ declare class AccountService {
|
|
|
1219
1294
|
private _processWithdrawalsAndRagequits;
|
|
1220
1295
|
}
|
|
1221
1296
|
|
|
1222
|
-
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-CuPs4jZ1.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;;;;"}
|