Nabarun
f23e440197
Part of [Generate watchers for sushiswap subgraphs deployed in graph-node](https://www.notion.so/Generate-watchers-for-sushiswap-subgraphs-deployed-in-graph-node-b3f2e475373d4ab1887d9f8720bd5ae6) Co-authored-by: neeraj <neeraj.rtly@gmail.com> Reviewed-on: cerc-io/sushiswap-watcher-ts#1 Co-authored-by: Nabarun <nabarun@deepstacksoft.com> Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
//
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
//
|
|
|
|
import 'reflect-metadata';
|
|
import debug from 'debug';
|
|
|
|
import { FillCmd } from '@cerc-io/cli';
|
|
import { getContractEntitiesMap } from '@cerc-io/util';
|
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
|
|
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
|
import { Indexer } from './indexer';
|
|
|
|
const log = debug('vulcanize:fill');
|
|
|
|
export const main = async (): Promise<any> => {
|
|
const fillCmd = new FillCmd();
|
|
await fillCmd.init(Database);
|
|
|
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
|
fillCmd.config.server,
|
|
fillCmd.clients.ethClient,
|
|
fillCmd.ethProvider,
|
|
fillCmd.database.baseDatabase,
|
|
ENTITY_QUERY_TYPE_MAP,
|
|
ENTITY_TO_LATEST_ENTITY_MAP
|
|
);
|
|
|
|
await fillCmd.initIndexer(Indexer, graphWatcher);
|
|
|
|
// Get contractEntitiesMap required for fill-state
|
|
// NOTE: Assuming each entity type is only mapped to a single contract
|
|
const contractEntitiesMap = getContractEntitiesMap(graphWatcher.dataSources);
|
|
|
|
await fillCmd.exec(contractEntitiesMap);
|
|
};
|
|
|
|
main().catch(err => {
|
|
log(err);
|
|
}).finally(() => {
|
|
process.exit();
|
|
});
|
|
|
|
process.on('SIGINT', () => {
|
|
log(`Exiting process ${process.pid} with code 0`);
|
|
process.exit(0);
|
|
});
|