Rename DepositsService to TornadoService and export saveEventsPromise

This commit is contained in:
Tornado Contrib 2024-05-01 09:04:01 +00:00
parent e7412f3d98
commit 4623e386a1
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
7 changed files with 35 additions and 32 deletions

@ -38,6 +38,7 @@ export declare class BaseEventsService<EventType extends MinimalEvents> {
deployedBlock: number;
batchEventsService: BatchEventsService;
fetchDataOptions?: fetchDataOptions;
saveEventsPromise?: Promise<void>;
constructor({ netId, provider, graphApi, subgraphName, contract, type, deployedBlock, fetchDataOptions, }: BaseEventsServiceConstructor);
getInstanceName(): string;
getType(): string;
@ -81,7 +82,7 @@ export declare class BaseEventsService<EventType extends MinimalEvents> {
lastBlock: number | null;
}>;
}
export type BaseDepositsServiceConstructor = {
export type BaseTornadoServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
@ -97,12 +98,12 @@ export type DepositsGraphParams = BaseGraphParams & {
amount: string;
currency: string;
};
export declare class BaseDepositsService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> {
export declare class BaseTornadoService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> {
amount: string;
currency: string;
batchTransactionService: BatchTransactionService;
batchBlockService: BatchBlockService;
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, }: BaseDepositsServiceConstructor);
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, }: BaseTornadoServiceConstructor);
getInstanceName(): string;
getGraphMethod(): string;
getGraphParams(): DepositsGraphParams;

@ -1,14 +1,14 @@
import { BatchBlockOnProgress, BatchEventOnProgress } from '../batch';
import { BaseDepositsService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseDepositsServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseEchoServiceConstructor, BaseEchoService } from './base';
import { BaseTornadoService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseTornadoServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseEchoServiceConstructor, BaseEchoService } from './base';
import type { BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, RegistersEvents, AllGovernanceEvents, EchoEvents } from './types';
export type NodeDepositsServiceConstructor = BaseDepositsServiceConstructor & {
export type NodeTornadoServiceConstructor = BaseTornadoServiceConstructor & {
cacheDirectory?: string;
userDirectory?: string;
};
export declare class NodeDepositsService extends BaseDepositsService {
export declare class NodeTornadoService extends BaseTornadoService {
cacheDirectory?: string;
userDirectory?: string;
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeDepositsServiceConstructor);
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeTornadoServiceConstructor);
updateEventProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void;
updateTransactionProgress({ currentIndex, totalIndex }: Parameters<BatchBlockOnProgress>[0]): void;
updateBlockProgress({ currentIndex, totalIndex }: Parameters<BatchBlockOnProgress>[0]): void;

10
dist/index.js vendored

@ -4638,7 +4638,7 @@ class BaseEventsService {
});
const lastBlock = newEvents ? newEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : null;
this.validateEvents({ events: allEvents, lastBlock });
yield this.saveEvents({ events: allEvents, lastBlock });
this.saveEventsPromise = this.saveEvents({ events: allEvents, lastBlock });
return {
events: allEvents,
lastBlock
@ -4646,7 +4646,7 @@ class BaseEventsService {
});
}
}
class BaseDepositsService extends BaseEventsService {
class BaseTornadoService extends BaseEventsService {
constructor({
netId,
provider,
@ -5144,7 +5144,7 @@ var __async$9 = (__this, __arguments, generator) => {
step((generator = generator.apply(__this, __arguments)).next());
});
};
class NodeDepositsService extends BaseDepositsService {
class NodeTornadoService extends BaseTornadoService {
constructor({
netId,
provider,
@ -7889,12 +7889,12 @@ function calculateSnarkProof(input, circuit, provingKey) {
});
}
exports.BaseDepositsService = BaseDepositsService;
exports.BaseEchoService = BaseEchoService;
exports.BaseEncryptedNotesService = BaseEncryptedNotesService;
exports.BaseEventsService = BaseEventsService;
exports.BaseGovernanceService = BaseGovernanceService;
exports.BaseRegistryService = BaseRegistryService;
exports.BaseTornadoService = BaseTornadoService;
exports.BatchBlockService = BatchBlockService;
exports.BatchEventsService = BatchEventsService;
exports.BatchTransactionService = BatchTransactionService;
@ -7918,11 +7918,11 @@ exports.MerkleTreeService = MerkleTreeService;
exports.Mimc = Mimc;
exports.Multicall__factory = Multicall__factory;
exports.NetId = NetId;
exports.NodeDepositsService = NodeDepositsService;
exports.NodeEchoService = NodeEchoService;
exports.NodeEncryptedNotesService = NodeEncryptedNotesService;
exports.NodeGovernanceService = NodeGovernanceService;
exports.NodeRegistryService = NodeRegistryService;
exports.NodeTornadoService = NodeTornadoService;
exports.NoteAccount = NoteAccount;
exports.OffchainOracle__factory = OffchainOracle__factory;
exports.OvmGasPriceOracle__factory = OvmGasPriceOracle__factory;

8
dist/index.mjs vendored

@ -4617,7 +4617,7 @@ class BaseEventsService {
});
const lastBlock = newEvents ? newEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : null;
this.validateEvents({ events: allEvents, lastBlock });
yield this.saveEvents({ events: allEvents, lastBlock });
this.saveEventsPromise = this.saveEvents({ events: allEvents, lastBlock });
return {
events: allEvents,
lastBlock
@ -4625,7 +4625,7 @@ class BaseEventsService {
});
}
}
class BaseDepositsService extends BaseEventsService {
class BaseTornadoService extends BaseEventsService {
constructor({
netId,
provider,
@ -5123,7 +5123,7 @@ var __async$9 = (__this, __arguments, generator) => {
step((generator = generator.apply(__this, __arguments)).next());
});
};
class NodeDepositsService extends BaseDepositsService {
class NodeTornadoService extends BaseTornadoService {
constructor({
netId,
provider,
@ -7868,4 +7868,4 @@ function calculateSnarkProof(input, circuit, provingKey) {
});
}
export { BaseDepositsService, BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, GasPriceOracle__factory, Invoice, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NodeDepositsService, NodeEchoService, NodeEncryptedNotesService, NodeGovernanceService, NodeRegistryService, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, TreeCache, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, download, enabledChains, existsAsync, index as factories, fetch, fetchData, fetchGetUrlFunc, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGasOraclePlugin, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getStatistic, getStatusSchema, getSubdomains, getSupportedInstances, getTokenBalances, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, isRelayerUpdated, jobsSchema, leBuff2Int, leInt2Buff, loadCachedEvents, loadSavedEvents, mimc, multicall, packEncryptedMessage, parseAddress, parseKey, parseMnemonic, parseNumber, parseRecoveryKey, parseRelayer, parseSemanticVersion, parseUrl, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, saveUserFile, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, unzipAsync, validateUrl, zipAsync };
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, GasPriceOracle__factory, Invoice, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NodeEchoService, NodeEncryptedNotesService, NodeGovernanceService, NodeRegistryService, NodeTornadoService, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, TreeCache, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, download, enabledChains, existsAsync, index as factories, fetch, fetchData, fetchGetUrlFunc, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGasOraclePlugin, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getStatistic, getStatusSchema, getSubdomains, getSupportedInstances, getTokenBalances, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, isRelayerUpdated, jobsSchema, leBuff2Int, leInt2Buff, loadCachedEvents, loadSavedEvents, mimc, multicall, packEncryptedMessage, parseAddress, parseKey, parseMnemonic, parseNumber, parseRecoveryKey, parseRelayer, parseSemanticVersion, parseUrl, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, saveUserFile, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, unzipAsync, validateUrl, zipAsync };

14
dist/index.umd.js vendored

@ -63898,8 +63898,8 @@ class NoteAccount {
/* harmony export */ Lx: () => (/* binding */ DEPOSIT),
/* harmony export */ O_: () => (/* binding */ BaseEncryptedNotesService),
/* harmony export */ cE: () => (/* binding */ BaseRegistryService),
/* harmony export */ e0: () => (/* binding */ BaseTornadoService),
/* harmony export */ oW: () => (/* binding */ WITHDRAWAL),
/* harmony export */ qD: () => (/* binding */ BaseDepositsService),
/* harmony export */ uw: () => (/* binding */ BaseEventsService)
/* harmony export */ });
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(30031);
@ -64154,7 +64154,7 @@ class BaseEventsService {
});
const lastBlock = newEvents ? newEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : null;
this.validateEvents({ events: allEvents, lastBlock });
yield this.saveEvents({ events: allEvents, lastBlock });
this.saveEventsPromise = this.saveEvents({ events: allEvents, lastBlock });
return {
events: allEvents,
lastBlock
@ -64162,7 +64162,7 @@ class BaseEventsService {
});
}
}
class BaseDepositsService extends BaseEventsService {
class BaseTornadoService extends BaseEventsService {
constructor({
netId,
provider,
@ -64509,18 +64509,18 @@ class BaseRegistryService extends BaseEventsService {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ BaseDepositsService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.qD),
/* harmony export */ BaseEchoService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.GS),
/* harmony export */ BaseEncryptedNotesService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.O_),
/* harmony export */ BaseEventsService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.uw),
/* harmony export */ BaseGovernanceService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.JJ),
/* harmony export */ BaseRegistryService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.cE),
/* harmony export */ BaseTornadoService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.e0),
/* harmony export */ DEPOSIT: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.Lx),
/* harmony export */ NodeDepositsService: () => (/* reexport safe */ _node__WEBPACK_IMPORTED_MODULE_2__.fD),
/* harmony export */ NodeEchoService: () => (/* reexport safe */ _node__WEBPACK_IMPORTED_MODULE_2__.Rl),
/* harmony export */ NodeEncryptedNotesService: () => (/* reexport safe */ _node__WEBPACK_IMPORTED_MODULE_2__.l5),
/* harmony export */ NodeGovernanceService: () => (/* reexport safe */ _node__WEBPACK_IMPORTED_MODULE_2__.Om),
/* harmony export */ NodeRegistryService: () => (/* reexport safe */ _node__WEBPACK_IMPORTED_MODULE_2__.b5),
/* harmony export */ NodeTornadoService: () => (/* reexport safe */ _node__WEBPACK_IMPORTED_MODULE_2__.$X),
/* harmony export */ WITHDRAWAL: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.oW)
/* harmony export */ });
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(61060);
@ -64543,10 +64543,10 @@ __webpack_require__.r(__webpack_exports__);
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ $X: () => (/* binding */ NodeTornadoService),
/* harmony export */ Om: () => (/* binding */ NodeGovernanceService),
/* harmony export */ Rl: () => (/* binding */ NodeEchoService),
/* harmony export */ b5: () => (/* binding */ NodeRegistryService),
/* harmony export */ fD: () => (/* binding */ NodeDepositsService),
/* harmony export */ l5: () => (/* binding */ NodeEncryptedNotesService)
/* harmony export */ });
/* harmony import */ var cli_table3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29530);
@ -64581,7 +64581,7 @@ var __async = (__this, __arguments, generator) => {
class NodeDepositsService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseDepositsService */ .qD {
class NodeTornadoService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseTornadoService */ .e0 {
constructor({
netId,
provider,

@ -77,6 +77,8 @@ export class BaseEventsService<EventType extends MinimalEvents> {
batchEventsService: BatchEventsService;
fetchDataOptions?: fetchDataOptions;
saveEventsPromise?: Promise<void>;
constructor({
netId,
provider,
@ -315,7 +317,7 @@ export class BaseEventsService<EventType extends MinimalEvents> {
this.validateEvents({ events: allEvents, lastBlock });
await this.saveEvents({ events: allEvents, lastBlock });
this.saveEventsPromise = this.saveEvents({ events: allEvents, lastBlock });
return {
events: allEvents,
@ -324,7 +326,7 @@ export class BaseEventsService<EventType extends MinimalEvents> {
}
}
export type BaseDepositsServiceConstructor = {
export type BaseTornadoServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
@ -342,7 +344,7 @@ export type DepositsGraphParams = BaseGraphParams & {
currency: string;
};
export class BaseDepositsService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> {
export class BaseTornadoService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> {
amount: string;
currency: string;
batchTransactionService: BatchTransactionService;
@ -359,7 +361,7 @@ export class BaseDepositsService extends BaseEventsService<DepositsEvents | With
currency,
deployedBlock,
fetchDataOptions,
}: BaseDepositsServiceConstructor) {
}: BaseTornadoServiceConstructor) {
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions });
this.amount = amount;

@ -3,11 +3,11 @@ import moment from 'moment';
import { BatchBlockOnProgress, BatchEventOnProgress } from '../batch';
import { saveUserFile, loadSavedEvents, loadCachedEvents } from '../data';
import {
BaseDepositsService,
BaseTornadoService,
BaseEncryptedNotesService,
BaseGovernanceService,
BaseRegistryService,
BaseDepositsServiceConstructor,
BaseTornadoServiceConstructor,
BaseEncryptedNotesServiceConstructor,
BaseGovernanceServiceConstructor,
BaseRegistryServiceConstructor,
@ -24,12 +24,12 @@ import type {
EchoEvents,
} from './types';
export type NodeDepositsServiceConstructor = BaseDepositsServiceConstructor & {
export type NodeTornadoServiceConstructor = BaseTornadoServiceConstructor & {
cacheDirectory?: string;
userDirectory?: string;
};
export class NodeDepositsService extends BaseDepositsService {
export class NodeTornadoService extends BaseTornadoService {
cacheDirectory?: string;
userDirectory?: string;
@ -46,7 +46,7 @@ export class NodeDepositsService extends BaseDepositsService {
fetchDataOptions,
cacheDirectory,
userDirectory,
}: NodeDepositsServiceConstructor) {
}: NodeTornadoServiceConstructor) {
super({
netId,
provider,