@0xbow/privacy-pools-core-sdk 1.0.2 → 1.0.4
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-D0mKkSYH.js → fetchArtifacts.esm-C_DNv-_D.js} +2 -2
- package/dist/esm/{fetchArtifacts.esm-D0mKkSYH.js.map → fetchArtifacts.esm-C_DNv-_D.js.map} +1 -1
- package/dist/esm/{fetchArtifacts.node-D2RwI1ei.js → fetchArtifacts.node-BBPNjgiT.js} +2 -2
- package/dist/esm/{fetchArtifacts.node-D2RwI1ei.js.map → fetchArtifacts.node-BBPNjgiT.js.map} +1 -1
- package/dist/esm/{index-CysEkDfm.js → index-BxzIe_IR.js} +43 -11
- package/dist/esm/index-BxzIe_IR.js.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/index.d.mts +6 -4
- package/dist/node/{fetchArtifacts.esm-GuREmUVE.js → fetchArtifacts.esm-l-EDo53-.js} +2 -2
- package/dist/node/{fetchArtifacts.esm-GuREmUVE.js.map → fetchArtifacts.esm-l-EDo53-.js.map} +1 -1
- package/dist/node/{fetchArtifacts.node-80qrImLq.js → fetchArtifacts.node-DYwQHSF4.js} +2 -2
- package/dist/node/{fetchArtifacts.node-80qrImLq.js.map → fetchArtifacts.node-DYwQHSF4.js.map} +1 -1
- package/dist/node/{index-bIu80opN.js → index-DGsIfUGw.js} +43 -11
- package/dist/node/index-DGsIfUGw.js.map +1 -0
- package/dist/node/index.mjs +1 -1
- package/dist/types/core/account.service.d.ts +6 -4
- package/dist/types/{fetchArtifacts.esm-Ok2Ropox.js → fetchArtifacts.esm-IMTIZwq7.js} +1 -1
- package/dist/types/{fetchArtifacts.node-DpNFJc75.js → fetchArtifacts.node-BcXsBNCT.js} +1 -1
- package/dist/types/{index-xpjDqElC.js → index-DbuAhDci.js} +42 -10
- package/dist/types/index.js +1 -1
- package/dist/types/utils/concurrency.d.ts +15 -0
- package/package.json +2 -1
- package/src/core/account.service.ts +35 -26
- package/src/core/data.service.ts +8 -6
- package/src/utils/concurrency.ts +32 -0
- package/dist/esm/index-CysEkDfm.js.map +0 -1
- package/dist/node/artifacts/commitment.vkey +0 -109
- package/dist/node/artifacts/commitment.wasm +0 -0
- package/dist/node/artifacts/commitment.zkey +0 -0
- package/dist/node/artifacts/withdraw.vkey +0 -129
- package/dist/node/artifacts/withdraw.wasm +0 -0
- package/dist/node/artifacts/withdraw.zkey +0 -0
- package/dist/node/index-bIu80opN.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchArtifact } from './index-
|
|
1
|
+
import { F as FetchArtifact } from './index-BxzIe_IR.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'assert';
|
|
@@ -15,4 +15,4 @@ async function fetchVersionedArtifact(artifactUrl) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export { fetchVersionedArtifact };
|
|
18
|
-
//# sourceMappingURL=fetchArtifacts.esm-
|
|
18
|
+
//# sourceMappingURL=fetchArtifacts.esm-C_DNv-_D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchArtifacts.esm-
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.esm-C_DNv-_D.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-BxzIe_IR.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'assert';
|
|
@@ -28,4 +28,4 @@ async function fetchVersionedArtifact(artifactUrl) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { fetchVersionedArtifact };
|
|
31
|
-
//# sourceMappingURL=fetchArtifacts.node-
|
|
31
|
+
//# sourceMappingURL=fetchArtifacts.node-BBPNjgiT.js.map
|
package/dist/esm/{fetchArtifacts.node-D2RwI1ei.js.map → fetchArtifacts.node-BBPNjgiT.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchArtifacts.node-
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.node-BBPNjgiT.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;;;;"}
|
|
@@ -45803,10 +45803,10 @@ const circuitToAsset = {
|
|
|
45803
45803
|
|
|
45804
45804
|
async function importFetchVersionedArtifact(isBrowser) {
|
|
45805
45805
|
if (isBrowser) {
|
|
45806
|
-
return import('./fetchArtifacts.esm-
|
|
45806
|
+
return import('./fetchArtifacts.esm-C_DNv-_D.js');
|
|
45807
45807
|
}
|
|
45808
45808
|
else {
|
|
45809
|
-
return import('./fetchArtifacts.node-
|
|
45809
|
+
return import('./fetchArtifacts.node-BBPNjgiT.js');
|
|
45810
45810
|
}
|
|
45811
45811
|
}
|
|
45812
45812
|
|
|
@@ -69321,6 +69321,31 @@ class Logger {
|
|
|
69321
69321
|
}
|
|
69322
69322
|
}
|
|
69323
69323
|
|
|
69324
|
+
/**
|
|
69325
|
+
* Executes an array of promise-returning functions with a maximum concurrency limit.
|
|
69326
|
+
* This prevents overwhelming RPC endpoints with too many concurrent requests.
|
|
69327
|
+
*
|
|
69328
|
+
* @param tasks - Array of functions that return promises
|
|
69329
|
+
* @param maxConcurrency - Maximum number of concurrent executions (default: 5)
|
|
69330
|
+
* @returns Promise that resolves to an array of settled results
|
|
69331
|
+
*
|
|
69332
|
+
* @example
|
|
69333
|
+
* ```typescript
|
|
69334
|
+
* const tasks = pools.map(pool => () => fetchPoolData(pool));
|
|
69335
|
+
* const results = await batchWithConcurrency(tasks, 5);
|
|
69336
|
+
* ```
|
|
69337
|
+
*/
|
|
69338
|
+
async function batchWithConcurrency(tasks, maxConcurrency = 5) {
|
|
69339
|
+
const results = [];
|
|
69340
|
+
// Process tasks in batches
|
|
69341
|
+
for (let i = 0; i < tasks.length; i += maxConcurrency) {
|
|
69342
|
+
const batch = tasks.slice(i, i + maxConcurrency);
|
|
69343
|
+
const batchResults = await Promise.allSettled(batch.map(task => task()));
|
|
69344
|
+
results.push(...batchResults);
|
|
69345
|
+
}
|
|
69346
|
+
return results;
|
|
69347
|
+
}
|
|
69348
|
+
|
|
69324
69349
|
class DataError extends SDKError {
|
|
69325
69350
|
constructor(message, code = ErrorCode.NETWORK_ERROR, details) {
|
|
69326
69351
|
super(message, code, details);
|
|
@@ -69764,15 +69789,17 @@ class AccountService {
|
|
|
69764
69789
|
}
|
|
69765
69790
|
}
|
|
69766
69791
|
/**
|
|
69767
|
-
* Fetches events for a given set of pools
|
|
69792
|
+
* Fetches events for a given set of pools with concurrency control
|
|
69768
69793
|
*
|
|
69769
69794
|
* @param pools - The pools to fetch events for
|
|
69795
|
+
* @param maxConcurrency - Maximum number of concurrent pool fetches (default: 5)
|
|
69770
69796
|
*
|
|
69771
69797
|
* @returns A map of pool scopes to their events
|
|
69772
69798
|
*/
|
|
69773
|
-
async getEvents(pools) {
|
|
69799
|
+
async getEvents(pools, maxConcurrency = 5) {
|
|
69774
69800
|
const events = new Map();
|
|
69775
|
-
|
|
69801
|
+
// Create tasks for batched execution
|
|
69802
|
+
const tasks = pools.map((pool) => async () => {
|
|
69776
69803
|
this.logger.info(`Fetching events for pool`, {
|
|
69777
69804
|
poolAddress: pool.address,
|
|
69778
69805
|
poolChainId: pool.chainId,
|
|
@@ -69789,7 +69816,9 @@ class AccountService {
|
|
|
69789
69816
|
withdrawalEvents,
|
|
69790
69817
|
ragequitEvents,
|
|
69791
69818
|
};
|
|
69792
|
-
})
|
|
69819
|
+
});
|
|
69820
|
+
// Execute with concurrency control
|
|
69821
|
+
const poolEventResults = await batchWithConcurrency(tasks, maxConcurrency);
|
|
69793
69822
|
for (const result of poolEventResults) {
|
|
69794
69823
|
if (result.status === "fulfilled") {
|
|
69795
69824
|
const { scope, depositEvents, withdrawalEvents, ragequitEvents } = result.value;
|
|
@@ -69928,10 +69957,11 @@ class AccountService {
|
|
|
69928
69957
|
* @param dataService - The data service to use for fetching events
|
|
69929
69958
|
* @param source - The source to use for initializing the account. Either a mnemonic or an existing account service instance
|
|
69930
69959
|
* @param pools - The pools to fetch events for
|
|
69960
|
+
* @param maxConcurrency - Maximum number of concurrent pool fetches (default: 5)
|
|
69931
69961
|
*
|
|
69932
69962
|
* @remarks
|
|
69933
69963
|
* This method performs the following steps for each pool:
|
|
69934
|
-
* 1. Fetches deposit, withdrawal, and ragequit events for each pool
|
|
69964
|
+
* 1. Fetches deposit, withdrawal, and ragequit events for each pool (with concurrency control)
|
|
69935
69965
|
* 2. Processes deposit events and creates pool accounts
|
|
69936
69966
|
* 3. Processes withdrawal events and adds commitments to pool accounts
|
|
69937
69967
|
* 4. Processes ragequit events and adds ragequit to pool accounts
|
|
@@ -69943,7 +69973,7 @@ class AccountService {
|
|
|
69943
69973
|
*
|
|
69944
69974
|
* @throws {AccountError} If account state reconstruction fails or if duplicate pools are found
|
|
69945
69975
|
*/
|
|
69946
|
-
static async initializeWithEvents(dataService, source, pools) {
|
|
69976
|
+
static async initializeWithEvents(dataService, source, pools, maxConcurrency = 5) {
|
|
69947
69977
|
// Log the start of the history retrieval process
|
|
69948
69978
|
const logger = new Logger({ prefix: "Account" });
|
|
69949
69979
|
logger.info(`Fetching events for pools`, { poolLength: pools.length });
|
|
@@ -69959,7 +69989,7 @@ class AccountService {
|
|
|
69959
69989
|
const account = new AccountService(dataService, "mnemonic" in source
|
|
69960
69990
|
? { mnemonic: source.mnemonic }
|
|
69961
69991
|
: { account: source.service.account });
|
|
69962
|
-
const events = await account.getEvents(pools);
|
|
69992
|
+
const events = await account.getEvents(pools, maxConcurrency);
|
|
69963
69993
|
for (const [scope, result] of events.entries()) {
|
|
69964
69994
|
if ("reason" in result) {
|
|
69965
69995
|
errors.push(result);
|
|
@@ -70170,7 +70200,9 @@ class DataService {
|
|
|
70170
70200
|
throw new Error(`Missing RPC URL for chain ${config.chainId}`);
|
|
70171
70201
|
}
|
|
70172
70202
|
const client = createPublicClient({
|
|
70173
|
-
transport: http(config.rpcUrl
|
|
70203
|
+
transport: http(config.rpcUrl, {
|
|
70204
|
+
timeout: 20_000,
|
|
70205
|
+
}),
|
|
70174
70206
|
});
|
|
70175
70207
|
this.clients.set(config.chainId, client);
|
|
70176
70208
|
}
|
|
@@ -70346,4 +70378,4 @@ class DataService {
|
|
|
70346
70378
|
}
|
|
70347
70379
|
|
|
70348
70380
|
export { AccountService as A, BlockchainProvider as B, CommitmentService as C, DataService as D, ErrorCode as E, FetchArtifact as F, InvalidRpcUrl as I, PrivacyPoolSDK as P, SDKError as S, WithdrawalService as W, generateDepositSecrets as a, generateWithdrawalSecrets as b, getCommitment as c, generateMerkleProof as d, bigintToHash as e, bigintToHex as f, generateMasterKeys as g, hashPrecommitment as h, calculateContext as i, Circuits as j, ContractInteractionsService as k, ProofError as l, ContractError as m, AccountError as n, CircuitName as o };
|
|
70349
|
-
//# sourceMappingURL=index-
|
|
70381
|
+
//# sourceMappingURL=index-BxzIe_IR.js.map
|