diff --git a/src/cli/add-contract.ts b/src/cli/add-contract.ts index b7f6486..b0afe4e 100644 --- a/src/cli/add-contract.ts +++ b/src/cli/add-contract.ts @@ -43,13 +43,18 @@ const argv = yargs.parserConfiguration({ type: 'string', default: '', describe: 'Solidity compiler version' + }, + runBackfiller: { + type: 'boolean', + default: false, + describe: 'Run backfiller' } }).argv; (async (): Promise => { const connectionOptions = await getConnectionOptions(); createConnection(connectionOptions).then(async () => { - const { name, address, sourcePath, artifactPath, startingBlock, compilerVersion } = argv; + const { name, address, sourcePath, artifactPath, startingBlock, compilerVersion, runBackfiller } = argv; const contracts = []; @@ -67,7 +72,7 @@ const argv = yargs.parserConfiguration({ contracts.push(contract); const contractService = new ContractService(); - const data = await contractService.addContracts(null, contracts); + const data = await contractService.addContracts(null, contracts, runBackfiller); console.log(data); }); })(); diff --git a/src/controllers/defaultController.ts b/src/controllers/defaultController.ts index ad11b25..855b523 100644 --- a/src/controllers/defaultController.ts +++ b/src/controllers/defaultController.ts @@ -23,7 +23,7 @@ export default class DefaultController { const contracts = req.body.contracts; const apikey = req.body.apikey; - const data = await contractService.addContracts(apikey, contracts); + const data = await contractService.addContracts(apikey, contracts, true); res.status(HttpStatusCodes.OK).json({ message: 'OK', diff --git a/src/services/contractService.ts b/src/services/contractService.ts index fa6233f..a31efcc 100644 --- a/src/services/contractService.ts +++ b/src/services/contractService.ts @@ -62,7 +62,7 @@ export default class ContractService { } - public async addContracts (apiKey: string, contracts: ContractParam[]): Promise<{ success; fail }> { + public async addContracts (apiKey: string, contracts: ContractParam[], runBackfiller: boolean): Promise<{ success; fail }> { const eventRepository: EventRepository = getConnection().getCustomRepository(EventRepository); const stateRepository: StateRepository = getConnection().getCustomRepository(StateRepository); const contractRepository: ContractRepository = getConnection().getCustomRepository(ContractRepository); @@ -121,7 +121,7 @@ export default class ContractService { } } - if (contractIds && contractIds.length) { + if (contractIds && contractIds.length && runBackfiller) { this.runBackfillService(contractIds); // async }