From 765ef8522855801f35c0edf28d112a874e7333f8 Mon Sep 17 00:00:00 2001 From: nicholaspai <9457025+nicholaspai@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:58:08 -0500 Subject: [PATCH] refactor(QueryBase): Remove constructors in derived classes (#808) --- .../chain-queries/alephZero.ts | 28 +------------------ .../chain-queries/factory.ts | 8 ++++-- .../chain-queries/polygon.ts | 28 +------------------ 3 files changed, 8 insertions(+), 56 deletions(-) diff --git a/src/relayFeeCalculator/chain-queries/alephZero.ts b/src/relayFeeCalculator/chain-queries/alephZero.ts index bbe1b851..0c7ff48a 100644 --- a/src/relayFeeCalculator/chain-queries/alephZero.ts +++ b/src/relayFeeCalculator/chain-queries/alephZero.ts @@ -1,34 +1,8 @@ -import assert from "assert"; -import { getDeployedAddress } from "../../utils/DeploymentUtils"; -import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator"; -import { providers } from "ethers"; -import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../../constants"; +import { CHAIN_IDs } from "../../constants"; import { Coingecko } from "../../coingecko/Coingecko"; -import { isDefined } from "../../utils"; import { QueryBase } from "./baseQuery"; export class AlephZeroQueries extends QueryBase { - constructor( - provider: providers.Provider, - symbolMapping = TOKEN_SYMBOLS_MAP, - spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.ALEPH_ZERO), - simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS, - coingeckoProApiKey?: string, - logger: Logger = DEFAULT_LOGGER - ) { - assert(isDefined(spokePoolAddress)); - super( - provider, - symbolMapping, - spokePoolAddress, - simulatedRelayerAddress, - logger, - coingeckoProApiKey, - undefined, - "usd" - ); - } - override async getTokenPrice(tokenSymbol: string): Promise { if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`); const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey); diff --git a/src/relayFeeCalculator/chain-queries/factory.ts b/src/relayFeeCalculator/chain-queries/factory.ts index 54f3bc8f..9bfee85f 100644 --- a/src/relayFeeCalculator/chain-queries/factory.ts +++ b/src/relayFeeCalculator/chain-queries/factory.ts @@ -37,8 +37,10 @@ export class QueryBase__factory { symbolMapping, spokePoolAddress, simulatedRelayerAddress, + logger, coingeckoProApiKey, - logger + fixedGasPrice[chainId], + "usd" ); } @@ -48,8 +50,10 @@ export class QueryBase__factory { symbolMapping, spokePoolAddress, simulatedRelayerAddress, + logger, coingeckoProApiKey, - logger + fixedGasPrice[chainId], + "usd" ); } diff --git a/src/relayFeeCalculator/chain-queries/polygon.ts b/src/relayFeeCalculator/chain-queries/polygon.ts index dfaa75da..29e1fa07 100644 --- a/src/relayFeeCalculator/chain-queries/polygon.ts +++ b/src/relayFeeCalculator/chain-queries/polygon.ts @@ -1,34 +1,8 @@ -import assert from "assert"; -import { getDeployedAddress } from "../../utils/DeploymentUtils"; -import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator"; -import { providers } from "ethers"; -import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../../constants"; +import { CHAIN_IDs } from "../../constants"; import { Coingecko } from "../../coingecko/Coingecko"; -import { isDefined } from "../../utils"; import { QueryBase } from "./baseQuery"; export class PolygonQueries extends QueryBase { - constructor( - provider: providers.Provider, - symbolMapping = TOKEN_SYMBOLS_MAP, - spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.POLYGON), - simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS, - coingeckoProApiKey?: string, - logger: Logger = DEFAULT_LOGGER - ) { - assert(isDefined(spokePoolAddress)); - super( - provider, - symbolMapping, - spokePoolAddress, - simulatedRelayerAddress, - logger, - coingeckoProApiKey, - undefined, - "usd" - ); - } - override async getTokenPrice(tokenSymbol: string): Promise { if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`); const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey);