From 8e2c4b358cb784ed4aa60a2b022914c09e1927b1 Mon Sep 17 00:00:00 2001 From: Nicolas Alencar <55406040+nicoalencar@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:41:59 -0300 Subject: [PATCH] npm prettier --- src/config.ts | 22 +++++++++++----------- src/data_sources/events/web3.ts | 22 ++++++++++++++++++---- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/config.ts b/src/config.ts index 7a50bd0..2c521ba 100644 --- a/src/config.ts +++ b/src/config.ts @@ -142,10 +142,10 @@ export const SCRAPER_MODE: ScraperMode = process.env.SCRAPER_MODE === undefined ? DEFAULT_SCRAPER_MODE : process.env.SCRAPER_MODE === 'BLOCKS' - ? 'BLOCKS' - : process.env.SCRAPER_MODE === 'EVENTS' - ? 'EVENTS' - : throwError('Wrong SCRAPER_MODE'); + ? 'BLOCKS' + : process.env.SCRAPER_MODE === 'EVENTS' + ? 'EVENTS' + : throwError('Wrong SCRAPER_MODE'); export const METRICS_PATH = process.env.METRICS_PATH || DEFAULT_METRICS_PATH; export const PROMETHEUS_PORT = getIntConfig('PROMETHEUS_PORT', DEFAULT_PROMETHEUS_PORT); @@ -386,13 +386,13 @@ export const FEAT_UNISWAP_V2_PAIR_CREATED_EVENT = getBoolConfig( export const UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS = process.env .UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS ? process.env.UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS.split(',').map((contract) => { - const [name, factoryAddress, startBlock] = contract.split(':'); - return { - name, - factoryAddress, - startBlock: parseInt(startBlock), - }; - }) + const [name, factoryAddress, startBlock] = contract.split(':'); + return { + name, + factoryAddress, + startBlock: parseInt(startBlock), + }; + }) : []; if ( diff --git a/src/data_sources/events/web3.ts b/src/data_sources/events/web3.ts index f4aac3b..ee04deb 100644 --- a/src/data_sources/events/web3.ts +++ b/src/data_sources/events/web3.ts @@ -259,10 +259,16 @@ export class Web3Source { try { logger.debug(`Fetching block ${blockNumber}`); - const block = (await this._web3Wrapper.getBlockIfExistsAsync(blockNumber)) as BlockWithoutTransactionData; + const block = (await this._web3Wrapper.getBlockIfExistsAsync( + blockNumber, + )) as BlockWithoutTransactionData; if (block == null) { - logger.warn(`Block ${blockNumber} returned null, likely because the RPC node is not fully synced. Retrying... (${retryCount + 1}/${MAX_RPC_RETRY_CALLS})`); + logger.warn( + `Block ${blockNumber} returned null, likely because the RPC node is not fully synced. Retrying... (${ + retryCount + 1 + }/${MAX_RPC_RETRY_CALLS})`, + ); retryCount++; await new Promise((resolve) => setTimeout(resolve, 1000)); continue; @@ -270,9 +276,17 @@ export class Web3Source { return block; } catch (err) { if (err instanceof Error) { - logger.error(`Error while fetching block ${blockNumber}: ${err.message}. Retrying... (${retryCount + 1}/${MAX_RPC_RETRY_CALLS})`); + logger.error( + `Error while fetching block ${blockNumber}: ${err.message}. Retrying... (${ + retryCount + 1 + }/${MAX_RPC_RETRY_CALLS})`, + ); } else { - logger.error(`Unknown error while fetching block ${blockNumber}. Retrying... (${retryCount + 1}/${MAX_RPC_RETRY_CALLS})`); + logger.error( + `Unknown error while fetching block ${blockNumber}. Retrying... (${ + retryCount + 1 + }/${MAX_RPC_RETRY_CALLS})`, + ); } retryCount++; await new Promise((resolve) => setTimeout(resolve, 1000));