2021-11-29 12:21:16 +00:00
|
|
|
import assert from 'assert';
|
2021-12-21 10:28:17 +00:00
|
|
|
import { FindConditions, FindManyOptions } from 'typeorm';
|
2021-11-29 12:21:16 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
IndexerInterface,
|
|
|
|
BlockProgressInterface,
|
|
|
|
EventInterface,
|
|
|
|
SyncStatusInterface
|
|
|
|
} from '@vulcanize/util';
|
|
|
|
|
|
|
|
export class Indexer implements IndexerInterface {
|
|
|
|
async getBlockProgress (blockHash: string): Promise<BlockProgressInterface | undefined> {
|
|
|
|
assert(blockHash);
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
async getEvent (id: string): Promise<EventInterface | undefined> {
|
|
|
|
assert(id);
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
async getSyncStatus (): Promise<SyncStatusInterface | undefined> {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-12-07 11:36:06 +00:00
|
|
|
async getBlocks (blockFilter: { blockHash?: string, blockNumber?: number }): Promise<any> {
|
|
|
|
assert(blockFilter);
|
2021-11-29 12:21:16 +00:00
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
async getBlocksAtHeight (height: number, isPruned: boolean): Promise<BlockProgressInterface[]> {
|
|
|
|
assert(height);
|
|
|
|
assert(isPruned);
|
|
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
async getBlockEvents (blockHash: string): Promise<Array<EventInterface>> {
|
|
|
|
assert(blockHash);
|
|
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
async getAncestorAtDepth (blockHash: string, depth: number): Promise<string> {
|
|
|
|
assert(blockHash);
|
|
|
|
assert(depth);
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2021-12-21 10:28:17 +00:00
|
|
|
async fetchBlockEvents (block: BlockProgressInterface): Promise<BlockProgressInterface> {
|
|
|
|
return block;
|
2021-11-29 12:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async removeUnknownEvents (block: BlockProgressInterface): Promise<void> {
|
|
|
|
assert(block);
|
|
|
|
}
|
|
|
|
|
2021-12-21 10:28:17 +00:00
|
|
|
async updateBlockProgress (block: BlockProgressInterface, lastProcessedEventIndex: number): Promise<BlockProgressInterface> {
|
|
|
|
assert(block);
|
2021-11-29 12:21:16 +00:00
|
|
|
assert(lastProcessedEventIndex);
|
2021-12-21 10:28:17 +00:00
|
|
|
|
|
|
|
return block;
|
2021-11-29 12:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async updateSyncStatusChainHead (blockHash: string, blockNumber: number): Promise<SyncStatusInterface> {
|
|
|
|
assert(blockHash);
|
|
|
|
assert(blockNumber);
|
|
|
|
|
|
|
|
return new SyncStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
async updateSyncStatusIndexedBlock (blockHash: string, blockNumber: number, force?: boolean): Promise<SyncStatusInterface> {
|
|
|
|
assert(blockNumber);
|
|
|
|
assert(blockHash);
|
|
|
|
assert(force);
|
|
|
|
|
|
|
|
return new SyncStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
async updateSyncStatusCanonicalBlock (blockHash: string, blockNumber: number, force?: boolean): Promise<SyncStatusInterface> {
|
|
|
|
assert(blockNumber);
|
|
|
|
assert(blockHash);
|
|
|
|
assert(force);
|
|
|
|
|
|
|
|
return new SyncStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
async markBlocksAsPruned (blocks: BlockProgressInterface[]): Promise<void> {
|
|
|
|
assert(blocks);
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
async createDiffStaged (contractAddress: string, blockHash: string, data: any): Promise<void> {
|
|
|
|
assert(contractAddress);
|
|
|
|
assert(blockHash);
|
|
|
|
assert(data);
|
|
|
|
}
|
2021-12-07 11:29:36 +00:00
|
|
|
|
|
|
|
getEntityTypesMap (): Map<string, { [key: string]: string; }> {
|
|
|
|
return new Map();
|
|
|
|
}
|
2021-12-21 10:28:17 +00:00
|
|
|
|
|
|
|
async getBlockProgressEntities (where: FindConditions<BlockProgressInterface>, options: FindManyOptions<BlockProgressInterface>): Promise<BlockProgressInterface[]> {
|
|
|
|
assert(where);
|
|
|
|
assert(options);
|
|
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
async saveEventEntity (dbEvent: EventInterface): Promise<EventInterface> {
|
|
|
|
return dbEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
async processEvent (event: EventInterface): Promise<void> {
|
|
|
|
assert(event);
|
|
|
|
}
|
2021-11-29 12:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|