2023-11-28 11:00:45 -08:00
|
|
|
import { RunPollingJob } from "./actions/RunPollingJob";
|
2023-11-30 07:43:37 -08:00
|
|
|
import { EvmBlock, EvmLog, EvmLogFilter, Handler, JobDefinition, solana } from "./entities";
|
2023-11-30 07:05:43 -08:00
|
|
|
import { ConfirmedSignatureInfo } from "./entities/solana";
|
|
|
|
import { Fallible, SolanaFailure } from "./errors";
|
2023-11-28 11:00:45 -08:00
|
|
|
|
|
|
|
export interface EvmBlockRepository {
|
2023-12-04 04:47:02 -08:00
|
|
|
getBlockHeight(chain: string, finality: string): Promise<bigint>;
|
|
|
|
getBlocks(chain: string, blockNumbers: Set<bigint>): Promise<Record<string, EvmBlock>>;
|
|
|
|
getFilteredLogs(chain: string, filter: EvmLogFilter): Promise<EvmLog[]>;
|
2023-11-28 11:00:45 -08:00
|
|
|
}
|
|
|
|
|
2023-11-30 07:05:43 -08:00
|
|
|
export interface SolanaSlotRepository {
|
|
|
|
getLatestSlot(commitment: string): Promise<number>;
|
|
|
|
getBlock(slot: number, finality?: string): Promise<Fallible<solana.Block, SolanaFailure>>;
|
|
|
|
getSignaturesForAddress(
|
|
|
|
address: string,
|
|
|
|
beforeSig: string,
|
|
|
|
afterSig: string,
|
|
|
|
limit: number,
|
|
|
|
finality?: string
|
|
|
|
): Promise<ConfirmedSignatureInfo[]>;
|
|
|
|
getTransactions(sigs: ConfirmedSignatureInfo[], finality?: string): Promise<solana.Transaction[]>;
|
|
|
|
}
|
|
|
|
|
2023-11-28 11:00:45 -08:00
|
|
|
export interface MetadataRepository<Metadata> {
|
|
|
|
get(id: string): Promise<Metadata | undefined>;
|
|
|
|
save(id: string, metadata: Metadata): Promise<void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface StatRepository {
|
2023-11-30 07:05:43 -08:00
|
|
|
count(id: string, labels: Record<string, any>, increase?: number): void;
|
2023-11-28 11:00:45 -08:00
|
|
|
measure(id: string, value: bigint, labels: Record<string, any>): void;
|
|
|
|
report: () => Promise<string>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface JobRepository {
|
|
|
|
getJobDefinitions(): Promise<JobDefinition[]>;
|
|
|
|
getSource(jobDef: JobDefinition): RunPollingJob;
|
|
|
|
getHandlers(jobDef: JobDefinition): Promise<Handler[]>;
|
|
|
|
}
|