Skip to content

Commit

Permalink
Fix codegen util imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nikugogoi committed Oct 11, 2022
1 parent 40ab8a2 commit 2c3c074
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 14 additions & 2 deletions packages/codegen/src/templates/database-template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -190,6 +190,18 @@ export class Database implements IPLDDatabaseInterface {
return this._baseDatabase.saveBlockWithEvents(blockRepo, eventRepo, block, events);
}

async saveEvents (queryRunner: QueryRunner, events: Event[]): Promise<void> {
const eventRepo = queryRunner.manager.getRepository(Event);

return this._baseDatabase.saveEvents(eventRepo, events);
}

async saveBlockProgress (queryRunner: QueryRunner, block: DeepPartial<BlockProgress>): Promise<BlockProgress> {
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<Contract> {
const repo = queryRunner.manager.getRepository(Contract);

Expand Down
8 changes: 4 additions & 4 deletions packages/codegen/src/templates/indexer-template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -590,7 +590,7 @@ export class Indexer implements IPLDIndexerInterface {
return this._baseIndexer.getEventsByFilter(blockHash, contract, name);
}

async isWatchedContract (address : string): Promise<Contract | undefined> {
isWatchedContract (address : string): Contract | undefined {
return this._baseIndexer.isWatchedContract(address);
}

Expand Down

0 comments on commit 2c3c074

Please sign in to comment.