Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inspect-cid CLI from cli package #405

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/erc20-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,12 @@ export class Indexer implements IndexerInterface {

async processCLICheckpoint (contractAddress: string, blockHash?: string): Promise<string | undefined> {
// TODO Implement
return '';
return undefined;
}

async getStateByCID (cid: string): Promise<State | undefined> {
// TODO Implement
return undefined;
}

parseEventNameAndArgs (kind: string, logObj: any): any {
Expand Down
51 changes: 5 additions & 46 deletions packages/uni-info-watcher/src/cli/inspect-cid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
// Copyright 2022 Vulcanize, Inc.
//

import assert from 'assert';
import yargs from 'yargs';
import 'reflect-metadata';
import debug from 'debug';
import util from 'util';

import { InspectCIDCmd } from '@cerc-io/cli';
import { Client as ERC20Client } from '@vulcanize/erc20-watcher';
import { Client as UniClient } from '@vulcanize/uni-watcher';
import { DEFAULT_CONFIG_PATH, JobQueue, getConfig, initClients } from '@cerc-io/util';
import { Config } from '@vulcanize/util';

import { Database } from '../database';
Expand All @@ -19,40 +16,9 @@ import { Indexer } from '../indexer';
const log = debug('vulcanize:inspect-cid');

const main = async (): Promise<void> => {
const argv = await yargs.parserConfiguration({
'parse-numbers': false
}).options({
configFile: {
alias: 'f',
type: 'string',
require: true,
demandOption: true,
describe: 'Configuration file path (toml)',
default: DEFAULT_CONFIG_PATH
},
cid: {
alias: 'c',
type: 'string',
demandOption: true,
describe: 'CID to be inspected'
}
}).argv;

const config: Config = await getConfig(argv.configFile);
const { ethClient, ethProvider } = await initClients(config);

const db = new Database(config.database, config.server);
await db.init();

const jobQueueConfig = config.jobQueue;
assert(jobQueueConfig, 'Missing job queue config');

const { dbConnectionString, maxCompletionLagInSecs } = jobQueueConfig;
assert(dbConnectionString, 'Missing job queue db connection string');

const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
await jobQueue.start();
const inspectCIDCmd = new InspectCIDCmd();

const config: Config = await inspectCIDCmd.initConfig();
const {
uniWatcher,
tokenWatcher
Expand All @@ -61,15 +27,8 @@ const main = async (): Promise<void> => {
const uniClient = new UniClient(uniWatcher);
const erc20Client = new ERC20Client(tokenWatcher);

const indexer = new Indexer(config.server, db, { uniClient, erc20Client, ethClient }, ethProvider, jobQueue);
await indexer.init();

const state = await indexer.getStateByCID(argv.cid);
assert(state, 'State for the provided CID doesn\'t exist.');

const stateData = await indexer.getStateData(state);

log(util.inspect(stateData, false, null));
await inspectCIDCmd.init(Database, Indexer, { uniClient, erc20Client });
await inspectCIDCmd.exec();
};

main().catch(err => {
Expand Down
7 changes: 6 additions & 1 deletion packages/uni-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ export class Indexer implements IndexerInterface {

async processCLICheckpoint (contractAddress: string, blockHash?: string): Promise<string | undefined> {
// TODO Implement
return '';
return undefined;
}

async getStateByCID (cid: string): Promise<State | undefined> {
// TODO Implement
return undefined;
}

parseEventNameAndArgs (kind: string, logObj: any): any {
Expand Down