sushiswap-watcher-ts/packages/v3-watcher/src/cli/import-state.ts
Nabarun f23e440197 Generate watcher for sushiswap v3 subgraph (#1)
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>
2024-06-06 11:42:55 +00:00

40 lines
1017 B
TypeScript

//
// Copyright 2021 Vulcanize, Inc.
//
import 'reflect-metadata';
import debug from 'debug';
import { ImportStateCmd } from '@cerc-io/cli';
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
import { Indexer } from '../indexer';
import { State } from '../entity/State';
const log = debug('vulcanize:import-state');
export const main = async (): Promise<any> => {
const importStateCmd = new ImportStateCmd();
await importStateCmd.init(Database);
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
importStateCmd.config.server,
importStateCmd.clients.ethClient,
importStateCmd.ethProvider,
importStateCmd.database.baseDatabase,
ENTITY_QUERY_TYPE_MAP,
ENTITY_TO_LATEST_ENTITY_MAP
);
await importStateCmd.initIndexer(Indexer, graphWatcher);
await importStateCmd.exec(State, graphDb);
};
main().catch(err => {
log(err);
}).finally(() => {
process.exit(0);
});