/* eslint-disable @typescript-eslint/no-unused-vars */ import assert from 'assert'; import { DeepPartial, FindConditions, FindManyOptions } from 'typeorm'; import { ethers } from 'ethers'; import { IndexerInterface, BlockProgressInterface, EventInterface, SyncStatusInterface, ServerConfig, ValueResult, ContractInterface, StateStatus, StateSyncStatusInterface, StateInterface, getResultEvent, ResultEvent, StateKind, EthClient, UpstreamConfig, EthFullTransaction, EthFullBlock } from '@cerc-io/util'; import { GetStorageAt, getStorageValue, MappingKey, StorageLayout } from '@cerc-io/solidity-mapper'; export class Indexer implements IndexerInterface { _getStorageAt: GetStorageAt; _storageLayoutMap: Map = new Map(); _contractMap: Map = new Map(); eventSignaturesMap: 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 upstreamConfig () { return {} as UpstreamConfig; } get storageLayoutMap (): Map { return this._storageLayoutMap; } get contractMap (): Map { return this._contractMap; } 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 getEvents (options: FindManyOptions): Promise> { assert(options); return []; } async getSyncStatus (): Promise { return undefined; } async getBlocks (blockFilter: { blockHash?: string, blockNumber?: number }): Promise { assert(blockFilter); return undefined; } async getBlockByHash (blockHash?: string): Promise<{ block: any }> { return { block: undefined }; } async getBlocksAtHeight (height: number, isPruned: boolean): Promise { assert(height); assert(isPruned); return []; } async getBlockEvents (blockHash: string): Promise> { assert(blockHash); return []; } async getAncestorAtHeight (blockHash: string, height: number): Promise { assert(blockHash); assert(height); return ''; } async fetchAndSaveFilteredEventsAndBlocks (startBlock: number, endBlock: number): Promise<{ blockProgress: BlockProgressInterface; events: DeepPartial[]; ethFullBlock: EthFullBlock; ethFullTransactions: EthFullTransaction[]; }[]> { assert(startBlock); assert(endBlock); return []; } async fetchEventsForContracts (blockHash: string, blockNumber: number, addresses: string[]): Promise[]> { assert(blockHash); assert(blockNumber); assert(addresses); return []; } async saveBlockAndFetchEvents (block: BlockProgressInterface): Promise<[ BlockProgressInterface, DeepPartial[], EthFullTransaction[] ]> { 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 updateSyncStatusProcessedBlock (blockHash: string, blockNumber: number, force?: boolean): Promise { assert(blockNumber); assert(blockHash); assert(force); return {} as SyncStatusInterface; } async updateSyncStatusIndexingError (hasIndexingError: boolean): Promise { assert(hasIndexingError); return undefined; } async updateSyncStatus (syncStatus: SyncStatusInterface): Promise { assert(syncStatus); 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 saveEvents (dbEvents: EventInterface[]): Promise { assert(dbEvents); } async processEvent (event: EventInterface): Promise { assert(event); } async getStateSyncStatus (): Promise { return undefined; } async updateStateSyncStatusIndexedBlock (blockNumber: number, force?: boolean): Promise { return undefined; } async updateStateSyncStatusCheckpointBlock (blockNumber: number, force?: boolean): Promise { return {} as StateSyncStatusInterface; } async getLatestCanonicalBlock (): Promise { return undefined; } isContractAddressWatched (address : string): ContractInterface[] | undefined { return undefined; } getWatchedContracts (): ContractInterface[] { return []; } async watchContract (address: string, kind: string, checkpoint: boolean, startingBlock: number): Promise { return undefined; } async removeContract (address: string, kind: string): 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; } async clearProcessedBlockData (block: BlockProgressInterface): 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; } async getFullTransactions (txHashList: string[]): Promise { return []; } async switchClients (): Promise { return undefined; } async isGetLogsRequestsSlow (): Promise { return false; } }