Skip to content

Commit

Permalink
Satisfy updated indexer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed Nov 24, 2022
1 parent 4b46f69 commit 99ad6ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
9 changes: 8 additions & 1 deletion packages/erc20-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,14 @@ export class Indexer implements IndexerInterface {
return [];
}

// Method to be used by export-state CLI.
async createDiffStaged (contractAddress: string, blockHash: string, data: any): Promise<void> {
// TODO Implement
}

async createDiff (contractAddress: string, blockHash: string, data: any): Promise<void> {
// TODO Implement
}

async createCheckpoint (contractAddress: string, blockHash: string): Promise<string | undefined> {
// TODO Implement
return undefined;
Expand Down
22 changes: 3 additions & 19 deletions packages/uni-info-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DeepPartial, FindConditions, FindManyOptions, FindOneOptions, LessThan,
import JSONbig from 'json-bigint';
import { providers, utils, BigNumber } from 'ethers';
import { SelectionNode } from 'graphql';
import _ from 'lodash';

import { Client as UniClient } from '@vulcanize/uni-watcher';
import { Client as ERC20Client } from '@vulcanize/erc20-watcher';
Expand All @@ -31,6 +30,7 @@ import {
DatabaseInterface,
Clients
} from '@cerc-io/util';
import { updateSubgraphState, dumpSubgraphState } from '@cerc-io/graph-node';
import { EthClient } from '@cerc-io/ipld-eth-client';
import { StorageLayout, MappingKey } from '@cerc-io/solidity-mapper';

Expand Down Expand Up @@ -617,27 +617,11 @@ export class Indexer implements IndexerInterface {
}

updateSubgraphState (contractAddress: string, data: any): void {
// Update the subgraph state for a given contract.
const oldData = this._subgraphStateMap.get(contractAddress);
const updatedData = _.merge(oldData, data);
this._subgraphStateMap.set(contractAddress, updatedData);
return updateSubgraphState(this._subgraphStateMap, contractAddress, data);
}

async dumpSubgraphState (blockHash: string, isStateFinalized = false): Promise<void> {
// Create a diff for each contract in the subgraph state map.
const createDiffPromises = Array.from(this._subgraphStateMap.entries())
.map(([contractAddress, data]): Promise<void> => {
if (isStateFinalized) {
return this.createDiff(contractAddress, blockHash, data);
}

return this.createDiffStaged(contractAddress, blockHash, data);
});

await Promise.all(createDiffPromises);

// Reset the subgraph state map.
this._subgraphStateMap.clear();
return dumpSubgraphState(this, this._subgraphStateMap, blockHash, isStateFinalized);
}

async resetWatcherToBlock (blockNumber: number): Promise<void> {
Expand Down
9 changes: 8 additions & 1 deletion packages/uni-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ export class Indexer implements IndexerInterface {
return [];
}

// Method to be used by export-state CLI.
async createDiffStaged (contractAddress: string, blockHash: string, data: any): Promise<void> {
// TODO Implement
}

async createDiff (contractAddress: string, blockHash: string, data: any): Promise<void> {
// TODO Implement
}

async createCheckpoint (contractAddress: string, blockHash: string): Promise<string | undefined> {
// TODO Implement
return undefined;
Expand Down

0 comments on commit 99ad6ef

Please sign in to comment.