diff --git a/README.md b/README.md index 9e90b8a..821a2f7 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ API keys for the networks this plugin auto-configures via the `L1` and `L2` opti **L1** -+ [ethereum][101] ++ [ethereum][101] (`gasPrice` and `baseFee` prices require an API key) + [polygon][102] + [binance][103] + [fantom][104] diff --git a/src/utils/chains.ts b/src/utils/chains.ts index 0bdd0f4..6e8df9d 100644 --- a/src/utils/chains.ts +++ b/src/utils/chains.ts @@ -28,7 +28,7 @@ export function getTokenForChain(options: GasReporterOptions): string { * @returns */ export function getGasPriceUrlForChain(options: GasReporterOptions): string { - let apiKey = ""; + let apiKey: string; if (options.gasPriceApi) return options.gasPriceApi; @@ -44,6 +44,10 @@ export function getGasPriceUrlForChain(options: GasReporterOptions): string { if (!L1[options.L1!]) throw new Error(); + apiKey = (options.L1Etherscan) + ? `${DEFAULT_API_KEY_ARGS}${options.L1Etherscan}` + : ""; + return `${L1[options.L1!].baseUrl}${DEFAULT_GAS_PRICE_API_ARGS}${apiKey}`; } diff --git a/test/projects/options/hardhat.options.a.config.ts b/test/projects/options/hardhat.options.a.config.ts index 1a45df3..5597d93 100644 --- a/test/projects/options/hardhat.options.a.config.ts +++ b/test/projects/options/hardhat.options.a.config.ts @@ -34,11 +34,11 @@ const config: HardhatUserConfig = { }, gasReporter: { currency: "CHF", - L1: "polygon", - L1Etherscan: process.env.POLYGONSCAN_API_KEY, + L1: "ethereum", + L1Etherscan: process.env.ETHERSCAN_API_KEY, coinmarketcap: process.env.CMC_API_KEY, rst: true, - rstTitle: "Polygon Report", + rstTitle: "Ethereum Report", excludeContracts: ["EtherRouter/EtherRouter.sol"], showMethodSig: true, enabled: true, diff --git a/test/projects/options/hardhat.options.e.config.ts b/test/projects/options/hardhat.options.e.config.ts index a7f9f28..5c36fec 100644 --- a/test/projects/options/hardhat.options.e.config.ts +++ b/test/projects/options/hardhat.options.e.config.ts @@ -20,6 +20,7 @@ const config: HardhatUserConfig = { gasReporter: { coinmarketcap: process.env.CMC_API_KEY, L2: "optimism", + L1Etherscan: process.env.ETHERSCAN_API_KEY, L2Etherscan: process.env.OPTIMISTIC_API_KEY, enabled: true, reportPureAndViewMethods: true,