tovarish-relayer/lib/services/sync.d.ts

83 lines
2.8 KiB
TypeScript
Raw Permalink Normal View History

2024-11-13 04:42:13 +03:00
import type { Provider } from 'ethers';
import type { Logger } from 'winston';
import { NetIdType, TokenPriceOracle, TornadoFeeOracle, TovarishEventsStatus, TovarishSyncStatus } from '@tornado/core';
import { RelayerConfig } from '../config';
2024-11-19 13:22:27 +03:00
import { NodeEchoService, NodeEncryptedNotesService, NodeGovernanceService, NodeRegistryService, NodeRevenueService, NodeMultiTornadoService } from './events';
2024-11-13 04:42:13 +03:00
import { ErrorTypes, ErrorMessages } from './error';
export interface Services {
provider: Provider;
tokenPriceOracle: TokenPriceOracle;
tornadoFeeOracle: TornadoFeeOracle;
governanceService?: NodeGovernanceService;
registryService?: NodeRegistryService;
revenueService?: NodeRevenueService;
echoService: NodeEchoService;
encryptedNotesService: NodeEncryptedNotesService;
2024-11-19 13:22:27 +03:00
tornadoServices: NodeMultiTornadoService;
2024-11-13 04:42:13 +03:00
}
export interface CachedServices {
[index: NetIdType]: Services;
}
export interface CachedEventsStatus {
[index: NetIdType]: TovarishEventsStatus;
}
export interface TokenPrices {
[index: string]: bigint;
}
export interface TokenPricesString {
[index: string]: string;
}
export interface CachedPrices {
[index: NetIdType]: TokenPrices;
}
export interface CachedPricesString {
[index: NetIdType]: TokenPricesString;
}
export interface GasPrices {
gasPrice: string;
l1Fee?: string;
}
export interface CachedGasPrices {
[index: NetIdType]: GasPrices;
}
export interface LatestBlocks {
[index: NetIdType]: number;
}
export interface LatestBalances {
[index: NetIdType]: string;
}
export interface CachedSyncStatus {
[index: NetIdType]: TovarishSyncStatus;
}
export declare function syncGasPrice(syncManager: SyncManager, netId: NetIdType): Promise<void>;
export declare function syncPrices(syncManager: SyncManager, netId: NetIdType): Promise<void>;
export declare function syncNetworkEvents(syncManager: SyncManager, netId: NetIdType): Promise<void>;
export interface SyncManagerStatus {
cachedEvents: CachedEventsStatus;
cachedPrices: CachedPricesString;
cachedGasPrices: CachedGasPrices;
syncStatus: CachedSyncStatus;
latestBlocks: LatestBlocks;
latestBalances: LatestBalances;
errors: ErrorTypes[];
onSyncEvents: boolean;
}
export declare class SyncManager {
relayerConfig: RelayerConfig;
logger: Logger;
cachedServices: CachedServices;
cachedEvents: CachedEventsStatus;
cachedPrices: CachedPrices;
cachedGasPrices: CachedGasPrices;
syncStatus: CachedSyncStatus;
latestBlocks: LatestBlocks;
latestBalances: LatestBalances;
errors: ErrorMessages[];
onSyncEvents: boolean;
constructor(relayerConfig: RelayerConfig);
getStatus(): SyncManagerStatus;
getPrice(netId: NetIdType, token: string): bigint;
getGasPrice(netId: NetIdType): GasPrices;
syncEvents(): Promise<void>;
}