Skip to content

Commit

Permalink
Fix L1Etherscan option logic (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke authored Aug 12, 2024
1 parent a09cf98 commit 7828cd9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 5 additions & 1 deletion src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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}`;
}

Expand Down
6 changes: 3 additions & 3 deletions test/projects/options/hardhat.options.a.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/projects/options/hardhat.options.e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7828cd9

Please sign in to comment.