/* eslint-disable @typescript-eslint/no-unused-vars */ import assert from 'assert'; import { DeepPartial, FindConditions, FindManyOptions } from 'typeorm'; import { IndexerInterface, BlockProgressInterface, EventInterface, SyncStatusInterface, ServerConfig, ValueResult, ContractInterface, StateStatus, StateSyncStatusInterface, StateInterface, getResultEvent, ResultEvent, StateKind } from '@cerc-io/util'; import { EthClient } from '@cerc-io/ipld-eth-client'; import { GetStorageAt, getStorageValue, MappingKey, StorageLayout } from '@cerc-io/solidity-mapper'; export class Indexer implements IndexerInterface { _getStorageAt: GetStorageAt; _storageLayoutMap: Map = new Map(); constructor (ethClient: EthClient, storageLayoutMap?: Map) { this._getStorageAt = ethClient.getStorageAt.bind(ethClient); if (storageLayoutMap) { this._storageLayoutMap = storageLayoutMap; } } get serverConfig () { return {} as ServerConfig; } get storageLayoutMap (): Map { return this._storageLayoutMap; } async init (): Promise { return undefined; } getResultEvent (event: EventInterface): ResultEvent { return getResultEvent(event); } async getStorageValue (storageLayout: StorageLayout, blockHash: string, contractAddress: string, variable: string, ...mappingKeys: MappingKey[]): Promise { return getStorageValue( storageLayout, this._getStorageAt, blockHash, contractAddress, variable, ...mappingKeys ); } async getEntitiesForBlock (blockHash: string, tableName: string): Promise { return []; } 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 saveBlockAndFetchEvents (block: BlockProgressInterface): Promise<[BlockProgressInterface, DeepPartial[]]> { 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 {} as SyncStatusInterface; } async updateSyncStatusIndexedBlock (blockHash: string, blockNumber: number, force?: boolean): Promise { assert(blockNumber); assert(blockHash); assert(force); return {} as SyncStatusInterface; } async updateSyncStatusCanonicalBlock (blockHash: string, blockNumber: number, force?: boolean): Promise { assert(blockNumber); assert(blockHash); assert(force); return {} as SyncStatusInterface; } 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); } async getStateSyncStatus (): Promise { return undefined; } async updateStateSyncStatusIndexedBlock (blockNumber: number, force?: boolean): Promise { return {} as StateSyncStatusInterface; } async updateStateSyncStatusCheckpointBlock (blockNumber: number, force?: boolean): Promise { return {} as StateSyncStatusInterface; } async getLatestCanonicalBlock (): Promise { return {} as BlockProgressInterface; } isWatchedContract (address : string): ContractInterface | undefined { return undefined; } async watchContract (address: string, kind: string, checkpoint: boolean, startingBlock: number): Promise { return undefined; } async processBlock (blockProgress: BlockProgressInterface): Promise { return undefined; } async processCanonicalBlock (blockHash: string, blockNumber: number): Promise { return undefined; } async processCheckpoint (blockHash: string): Promise { return undefined; } async processCLICheckpoint (contractAddress: string, blockHash?: string): Promise { return undefined; } async getLatestState (contractAddress: string, kind: StateKind | null, blockNumber?: number): Promise { return undefined; } async getStateByCID (cid: string): Promise { return undefined; } async getStates (where: FindConditions): Promise { return []; } async createDiff (contractAddress: string, blockHash: string, data: any): Promise { return undefined; } async createCheckpoint (contractAddress: string, blockHash: string): Promise { return undefined; } async getLatestStateIndexedBlock (): Promise { return {} as BlockProgressInterface; } async saveOrUpdateState (state: StateInterface): Promise { return {} as StateInterface; } async removeStates (blockNumber: number, kind: StateKind): Promise { return undefined; } getStateData (state: StateInterface): any { return undefined; } updateStateStatusMap (address: string, stateStatus: StateStatus): void { return undefined; } async resetWatcherToBlock (blockNumber: number): Promise { return undefined; } cacheContract (contract: ContractInterface): void { return undefined; } async processInitialState (contractAddress: string, blockHash: string): Promise { return undefined; } async processStateCheckpoint (contractAddress: string, blockHash: string): Promise { return false; } }