import { BaseContract, Provider, EventLog } from 'ethers'; import { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry, Echoer, Aggregator } from '@tornado/contracts'; import type { MerkleTree } from '@tornado/fixed-merkle-tree'; import { BatchEventsService, BatchBlockService, BatchTransactionService, BatchEventOnProgress, BatchBlockOnProgress } from '../batch'; import { fetchDataOptions } from '../providers'; import { type NetIdType, type SubdomainMap } from '../networkConfig'; import { RelayerParams } from '../relayerClient'; import type { TovarishClient } from '../tovarishClient'; import type { ReverseRecords } from '../typechain'; import type { MerkleTreeService } from '../merkleTree'; import type { DepositType } from '../deposits'; import type { BaseEvents, CachedEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, AllGovernanceEvents, GovernanceProposalCreatedEvents, GovernanceVotedEvents, EchoEvents, AllRelayerRegistryEvents, StakeBurnedEvents, MultiDepositsEvents, MultiWithdrawalsEvents } from './types'; export interface BaseEventsServiceConstructor { netId: NetIdType; provider: Provider; contract: BaseContract; type: string; deployedBlock?: number; fetchDataOptions?: fetchDataOptions; tovarishClient?: TovarishClient; } export declare class BaseEventsService { netId: NetIdType; provider: Provider; contract: BaseContract; type: string; deployedBlock: number; batchEventsService: BatchEventsService; fetchDataOptions?: fetchDataOptions; tovarishClient?: TovarishClient; constructor({ netId, provider, contract, type, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEventsServiceConstructor); getInstanceName(): string; getType(): string; getTovarishType(): string; updateEventProgress({ percentage, type, fromBlock, toBlock, count }: Parameters[0]): void; updateBlockProgress({ percentage, currentIndex, totalIndex }: Parameters[0]): void; updateTransactionProgress({ percentage, currentIndex, totalIndex }: Parameters[0]): void; formatEvents(events: EventLog[]): Promise; /** * Get saved or cached events */ getEventsFromDB(): Promise>; /** * Events from remote cache (Either from local cache, CDN, or from IPFS) */ getEventsFromCache(): Promise>; getSavedEvents(): Promise | CachedEvents>; getEventsFromRpc({ fromBlock, toBlock, }: { fromBlock: number; toBlock?: number; }): Promise>; getLatestEvents({ fromBlock }: { fromBlock: number; }): Promise>; validateEvents({ events, newEvents, lastBlock, }: BaseEvents & { newEvents: EventType[]; }): Promise; /** * Handle saving events */ saveEvents({ events, newEvents, lastBlock }: BaseEvents & { newEvents: EventType[]; }): Promise; /** * Trigger saving and receiving latest events */ updateEvents(): Promise<{ events: EventType[]; lastBlock: number; validateResult: Awaited; }>; } export interface BaseTornadoServiceConstructor extends Omit { Tornado: Tornado; amount: string; currency: string; optionalTree?: boolean; merkleTreeService?: MerkleTreeService; } export declare class BaseTornadoService extends BaseEventsService { amount: string; currency: string; optionalTree?: boolean; merkleTreeService?: MerkleTreeService; batchTransactionService: BatchTransactionService; batchBlockService: BatchBlockService; constructor(serviceConstructor: BaseTornadoServiceConstructor); getInstanceName(): string; formatEvents(events: EventLog[]): Promise<(DepositsEvents | WithdrawalsEvents)[]>; validateEvents({ events, newEvents, }: BaseEvents & { newEvents: (DepositsEvents | WithdrawalsEvents)[]; }): Promise; getLatestEvents({ fromBlock, }: { fromBlock: number; }): Promise>; } export interface BaseMultiTornadoServiceConstructor extends Omit { instances: { [key in string]: DepositType; }; optionalTree?: boolean; merkleTreeService?: MerkleTreeService; } export declare class BaseMultiTornadoService extends BaseEventsService { instances: { [key in string]: DepositType; }; optionalTree?: boolean; merkleTreeService?: MerkleTreeService; batchTransactionService: BatchTransactionService; batchBlockService: BatchBlockService; constructor(serviceConstructor: BaseMultiTornadoServiceConstructor); getInstanceName(): string; getTovarishType(): string; formatEvents(events: EventLog[]): Promise<(MultiDepositsEvents | MultiWithdrawalsEvents)[]>; validateEvents({ events, newEvents, }: BaseEvents & { newEvents: (MultiDepositsEvents | MultiWithdrawalsEvents)[]; }): Promise; getEvents(instanceAddress: string): Promise<{ depositEvents: MultiDepositsEvents[]; withdrawalEvents: MultiWithdrawalsEvents[]; tree: MerkleTree | undefined; lastBlock: number; }>; } export interface BaseEchoServiceConstructor extends Omit { Echoer: Echoer; } export declare class BaseEchoService extends BaseEventsService { constructor(serviceConstructor: BaseEchoServiceConstructor); getInstanceName(): string; formatEvents(events: EventLog[]): Promise; } export interface BaseEncryptedNotesServiceConstructor extends Omit { Router: TornadoRouter | TornadoProxyLight; } export declare class BaseEncryptedNotesService extends BaseEventsService { constructor(serviceConstructor: BaseEncryptedNotesServiceConstructor); getInstanceName(): string; getTovarishType(): string; formatEvents(events: EventLog[]): Promise; } export declare const proposalState: { [key: string]: string; }; export interface GovernanceProposals extends GovernanceProposalCreatedEvents { title: string; proposerName?: string; forVotes: bigint; againstVotes: bigint; executed: boolean; extended: boolean; quorum: string; state: string; } export interface GovernanceVotes extends GovernanceVotedEvents { contact: string; message: string; fromName?: string; voterName?: string; } export interface BaseGovernanceServiceConstructor extends Omit { Governance: Governance; Aggregator: Aggregator; ReverseRecords: ReverseRecords; } export declare class BaseGovernanceService extends BaseEventsService { Governance: Governance; Aggregator: Aggregator; ReverseRecords: ReverseRecords; batchTransactionService: BatchTransactionService; constructor(serviceConstructor: BaseGovernanceServiceConstructor); getInstanceName(): string; getTovarishType(): string; formatEvents(events: EventLog[]): Promise; getAllProposals(): Promise; getVotes(proposalId: number): Promise; getDelegatedBalance(ethAccount: string): Promise<{ delegatedAccs: string[]; undelegatedAccs: string[]; uniq: string[]; uniqNames: { [key: string]: string; }; balances: bigint[]; balance: bigint; }>; } export declare function getTovarishNetworks(registryService: BaseRegistryService, relayers: CachedRelayerInfo[]): Promise; /** * Essential params: * ensName, relayerAddress, hostnames * Other data is for historic purpose from relayer registry */ export interface CachedRelayerInfo extends RelayerParams { isRegistered?: boolean; registeredAddress?: string; stakeBalance?: string; hostnames: SubdomainMap; tovarishHost?: string; tovarishNetworks?: number[]; } export interface CachedRelayers { lastBlock: number; timestamp: number; relayers: CachedRelayerInfo[]; fromCache?: boolean; } export interface BaseRegistryServiceConstructor extends Omit { RelayerRegistry: RelayerRegistry; Aggregator: Aggregator; relayerEnsSubdomains: SubdomainMap; } export declare class BaseRegistryService extends BaseEventsService { Aggregator: Aggregator; relayerEnsSubdomains: SubdomainMap; updateInterval: number; constructor(serviceConstructor: BaseRegistryServiceConstructor); getInstanceName(): string; getTovarishType(): string; formatEvents(events: EventLog[]): Promise; /** * Get saved or cached relayers */ getRelayersFromDB(): Promise; /** * Relayers from remote cache (Either from local cache, CDN, or from IPFS) */ getRelayersFromCache(): Promise; getSavedRelayers(): Promise; getLatestRelayers(): Promise; /** * Handle saving relayers */ saveRelayers({ lastBlock, timestamp, relayers }: CachedRelayers): Promise; /** * Get cached or latest relayer and save to local */ updateRelayers(): Promise; } export interface BaseRevenueServiceConstructor extends Omit { RelayerRegistry: RelayerRegistry; } /** * Tracks TORN burned events from RelayerRegistry contract */ export declare class BaseRevenueService extends BaseEventsService { batchTransactionService: BatchTransactionService; batchBlockService: BatchBlockService; constructor(serviceConstructor: BaseRevenueServiceConstructor); getInstanceName(): string; getTovarishType(): string; formatEvents(events: EventLog[]): Promise; }