diff --git a/packages/codegen/src/templates/database-template.handlebars b/packages/codegen/src/templates/database-template.handlebars index f84330014..82169fe1c 100644 --- a/packages/codegen/src/templates/database-template.handlebars +++ b/packages/codegen/src/templates/database-template.handlebars @@ -6,7 +6,7 @@ import assert from 'assert'; import { Connection, ConnectionOptions, DeepPartial, FindConditions, QueryRunner, FindManyOptions } from 'typeorm'; import path from 'path'; -import { IPLDDatabase as BaseDatabase, IPLDDatabaseInterface, QueryOptions, StateKind, Where } from '@cerc-io/util'; +import { Database as BaseDatabase, DatabaseInterface, QueryOptions, StateKind, Where } from '@cerc-io/util'; import { Contract } from './entity/Contract'; import { Event } from './entity/Event'; @@ -18,7 +18,7 @@ import { IPLDBlock } from './entity/IPLDBlock'; import { {{query.entityName}} } from './entity/{{query.entityName}}'; {{/each}} -export class Database implements IPLDDatabaseInterface { +export class Database implements DatabaseInterface { _config: ConnectionOptions; _conn!: Connection; _baseDatabase: BaseDatabase; @@ -190,6 +190,18 @@ export class Database implements IPLDDatabaseInterface { return this._baseDatabase.saveBlockWithEvents(blockRepo, eventRepo, block, events); } + async saveEvents (queryRunner: QueryRunner, events: Event[]): Promise { + const eventRepo = queryRunner.manager.getRepository(Event); + + return this._baseDatabase.saveEvents(eventRepo, events); + } + + async saveBlockProgress (queryRunner: QueryRunner, block: DeepPartial): Promise { + const repo = queryRunner.manager.getRepository(BlockProgress); + + return this._baseDatabase.saveBlockProgress(repo, block); + } + async saveContract (queryRunner: QueryRunner, address: string, kind: string, checkpoint: boolean, startingBlock: number): Promise { const repo = queryRunner.manager.getRepository(Contract); diff --git a/packages/codegen/src/templates/indexer-template.handlebars b/packages/codegen/src/templates/indexer-template.handlebars index 8200d997d..d67b65962 100644 --- a/packages/codegen/src/templates/indexer-template.handlebars +++ b/packages/codegen/src/templates/indexer-template.handlebars @@ -16,8 +16,8 @@ import * as codec from '@ipld/dag-cbor'; import { EthClient } from '@cerc-io/ipld-eth-client'; import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper'; import { - IPLDIndexer as BaseIndexer, - IPLDIndexerInterface, + Indexer as BaseIndexer, + IndexerInterface, ValueResult, UNKNOWN_EVENT_NAME, ServerConfig, @@ -89,7 +89,7 @@ export type ResultEvent = { proof: string; }; -export class Indexer implements IPLDIndexerInterface { +export class Indexer implements IndexerInterface { _db: Database _ethClient: EthClient _ethProvider: BaseProvider @@ -590,7 +590,7 @@ export class Indexer implements IPLDIndexerInterface { return this._baseIndexer.getEventsByFilter(blockHash, contract, name); } - async isWatchedContract (address : string): Promise { + isWatchedContract (address : string): Contract | undefined { return this._baseIndexer.isWatchedContract(address); }