import assert from 'assert'; import { FindConditions, FindManyOptions } from 'typeorm'; import { IndexerInterface, BlockProgressInterface, EventInterface, SyncStatusInterface } from '@vulcanize/util'; export class Indexer implements IndexerInterface { async getBlockProgress (blockHash: string): Promise { assert(blockHash); return undefined; } async getEvent (id: string): Promise { assert(id); return undefined; } async getSyncStatus (): Promise { return undefined; } async getBlocks (blockFilter: { blockHash?: string, blockNumber?: number }): Promise { assert(blockFilter); return undefined; } async getBlocksAtHeight (height: number, isPruned: boolean): Promise { assert(height); assert(isPruned); return []; } async getBlockEvents (blockHash: string): Promise> { assert(blockHash); return []; } async getAncestorAtDepth (blockHash: string, depth: number): Promise { assert(blockHash); assert(depth); return ''; } async fetchBlockEvents (block: BlockProgressInterface): Promise { return block; } async removeUnknownEvents (block: BlockProgressInterface): Promise { assert(block); } async updateBlockProgress (block: BlockProgressInterface, lastProcessedEventIndex: number): Promise { assert(block); assert(lastProcessedEventIndex); return block; } async updateSyncStatusChainHead (blockHash: string, blockNumber: number): Promise { assert(blockHash); assert(blockNumber); return new SyncStatus(); } async updateSyncStatusIndexedBlock (blockHash: string, blockNumber: number, force?: boolean): Promise { assert(blockNumber); assert(blockHash); assert(force); return new SyncStatus(); } async updateSyncStatusCanonicalBlock (blockHash: string, blockNumber: number, force?: boolean): Promise { assert(blockNumber); assert(blockHash); assert(force); return new SyncStatus(); } async markBlocksAsPruned (blocks: BlockProgressInterface[]): Promise { assert(blocks); return undefined; } async createDiffStaged (contractAddress: string, blockHash: string, data: any): Promise { assert(contractAddress); assert(blockHash); assert(data); } getEntityTypesMap (): Map { return new Map(); } async getBlockProgressEntities (where: FindConditions, options: FindManyOptions): Promise { assert(where); assert(options); return []; } async saveEventEntity (dbEvent: EventInterface): Promise { return dbEvent; } async processEvent (event: EventInterface): Promise { assert(event); } } class SyncStatus implements SyncStatusInterface { id: number; chainHeadBlockHash: string; chainHeadBlockNumber: number; latestIndexedBlockHash: string; latestIndexedBlockNumber: number; latestCanonicalBlockHash: string; latestCanonicalBlockNumber: number; constructor () { this.id = 0; this.chainHeadBlockHash = '0'; this.chainHeadBlockNumber = 0; this.latestIndexedBlockHash = '0'; this.latestIndexedBlockNumber = 0; this.latestCanonicalBlockHash = '0'; this.latestCanonicalBlockNumber = 0; } }