cgewecke / hardhat-gas-reporter

Gas Usage Analytics for Hardhat
MIT License
413 stars 59 forks source link

getGasPriceUrlForChain never sets apiKey for L1 #239

Closed sherpya closed 3 months ago

sherpya commented 3 months ago
export function getGasPriceUrlForChain(options: GasReporterOptions): string {
  let apiKey = "";

  if (options.gasPriceApi) return options.gasPriceApi;

  if (options.L2) {
    if (!L2[options.L2]) throw new Error;

    apiKey = (options.L2Etherscan)
      ? `${DEFAULT_API_KEY_ARGS}${options.L2Etherscan}`
      : "";

    return `${L2[options.L2!].baseUrl}${DEFAULT_GAS_PRICE_API_ARGS}${apiKey}`;
  }

  if (!L1[options.L1!]) throw new Error();

  return `${L1[options.L1!].baseUrl}${DEFAULT_GAS_PRICE_API_ARGS}${apiKey}`;
}

apiKey is always empty string on ethereum mainnet

cgewecke commented 3 months ago

@sherpya Thanks for catching... out of curiosity are you currently seeing etherscan rate limit this call on Ethereum mainnet?

sherpya commented 3 months ago

@sherpya Thanks for catching... out of curiosity are you currently seeing etherscan rate limit this call on Ethereum mainnet?

yes, I'm getting:

{
    status: "0",
    message: "NOTOK",
    result: "Missing/Invalid API Key"
}

the url is: https://api.etherscan.io/api?module=proxy&action=eth_gasPrice"

cgewecke commented 3 months ago

@sherpya Patched via #240 and published in v2.2.1. Please just lmk if that doesn't fix it and I'll re-open.

Thanks again!

https://github.com/cgewecke/hardhat-gas-reporter/releases/tag/v2.2.1

sherpya commented 3 months ago

yes, it works