@nomiclabs/hardhat-etherscan
Advanced tools
Comparing version 3.1.7 to 3.1.8
@@ -27,5 +27,5 @@ "use strict"; | ||
exports.encodeArguments = void 0; | ||
const plugins_1 = require("hardhat/plugins"); | ||
const ABITypes_1 = require("./ABITypes"); | ||
const constants_1 = require("./constants"); | ||
const errors_1 = require("./errors"); | ||
async function encodeArguments(abi, sourceName, contractName, constructorArguments) { | ||
@@ -45,3 +45,3 @@ const { Interface } = await Promise.resolve().then(() => __importStar(require("@ethersproject/abi"))); | ||
but ${error.count.values} arguments were provided instead.`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message, error); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message, error); | ||
} | ||
@@ -51,3 +51,3 @@ if ((0, ABITypes_1.isABIArgumentTypeError)(error)) { | ||
Encoder error reason: ${error.reason}`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message, error); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message, error); | ||
} | ||
@@ -58,3 +58,3 @@ if ((0, ABITypes_1.isABIArgumentOverflowError)(error)) { | ||
Encoder error reason: ${error.fault} fault in ${error.operation}`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message, error); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message, error); | ||
} | ||
@@ -61,0 +61,0 @@ // Should be unreachable. |
@@ -8,5 +8,5 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const plugins_1 = require("hardhat/plugins"); | ||
const ChainConfig_1 = require("./ChainConfig"); | ||
const constants_1 = require("./constants"); | ||
const errors_1 = require("./errors"); | ||
const verifyAllowedChains = (etherscanConfig) => { | ||
@@ -25,3 +25,3 @@ if (etherscanConfig.apiKey === null || | ||
if (invalidNetwork !== undefined) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `You set an Etherscan API token for the network "${invalidNetwork}" but the plugin doesn't support it, or it's spelled incorrectly. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `You set an Etherscan API token for the network "${invalidNetwork}" but the plugin doesn't support it, or it's spelled incorrectly. | ||
@@ -28,0 +28,0 @@ To see the list of supported networks, run this command: |
@@ -0,2 +1,6 @@ | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
export declare class HardhatEtherscanPluginError extends NomicLabsHardhatPluginError { | ||
constructor(name: string, message: string, parent?: Error, shouldBeReported?: boolean); | ||
} | ||
export declare function throwUnsupportedNetwork(networkName: string, chainID: number): never; | ||
//# sourceMappingURL=errors.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.throwUnsupportedNetwork = void 0; | ||
exports.throwUnsupportedNetwork = exports.HardhatEtherscanPluginError = void 0; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const plugins_1 = require("hardhat/plugins"); | ||
const constants_1 = require("./constants"); | ||
class HardhatEtherscanPluginError extends plugins_1.NomicLabsHardhatPluginError { | ||
constructor(name, message, parent, shouldBeReported = false) { | ||
super(name, message, parent, shouldBeReported); | ||
console.warn(chalk_1.default.yellow("DEPRECATION WARNING: 'hardhat-etherscan' has been deprecated in favor of 'hardhat-verify'. You can find more information about the migration in the readme.")); | ||
} | ||
} | ||
exports.HardhatEtherscanPluginError = HardhatEtherscanPluginError; | ||
function throwUnsupportedNetwork(networkName, chainID) { | ||
@@ -15,5 +26,5 @@ const message = ` | ||
npx hardhat verify --list-networks`.trimStart(); | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message); | ||
throw new HardhatEtherscanPluginError(constants_1.pluginName, message); | ||
} | ||
exports.throwUnsupportedNetwork = throwUnsupportedNetwork; | ||
//# sourceMappingURL=errors.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isAlreadyVerified = exports.EtherscanResponse = exports.getVerificationStatus = exports.verifyContract = exports.delay = void 0; | ||
const plugins_1 = require("hardhat/plugins"); | ||
const constants_1 = require("../constants"); | ||
const undici_1 = require("../undici"); | ||
const errors_1 = require("../errors"); | ||
async function delay(ms) { | ||
@@ -20,3 +20,3 @@ return new Promise((resolve) => setTimeout(resolve, ms)); | ||
catch (error) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Failed to send contract verification request. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Failed to send contract verification request. | ||
Endpoint URL: ${url} | ||
@@ -28,3 +28,3 @@ Reason: ${error.message}`, error); | ||
const responseText = await response.body.text(); | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Failed to send contract verification request. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Failed to send contract verification request. | ||
Endpoint URL: ${url} | ||
@@ -35,3 +35,3 @@ The HTTP server response is not ok. Status code: ${response.statusCode} Response text: ${responseText}`); | ||
if (etherscanResponse.isBytecodeMissingInNetworkError()) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Failed to send contract verification request. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Failed to send contract verification request. | ||
Endpoint URL: ${url} | ||
@@ -44,3 +44,3 @@ Reason: The Etherscan API responded that the address ${req.contractaddress} does not have bytecode. | ||
if (!etherscanResponse.isOk()) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, etherscanResponse.message); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, etherscanResponse.message); | ||
} | ||
@@ -61,7 +61,7 @@ return etherscanResponse; | ||
const message = `The HTTP server response is not ok. Status code: ${response.statusCode} Response text: ${responseText}`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message); | ||
} | ||
} | ||
catch (error) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Failure during etherscan status polling. The verification may still succeed but | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Failure during etherscan status polling. The verification may still succeed but | ||
should be checked manually. | ||
@@ -80,3 +80,3 @@ Endpoint URL: ${urlWithQuery.toString()} | ||
if (!etherscanResponse.isOk()) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The Etherscan API responded with a failure status. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The Etherscan API responded with a failure status. | ||
The verification may still succeed but should be checked manually. | ||
@@ -83,0 +83,0 @@ Reason: ${etherscanResponse.message}`); |
@@ -31,3 +31,2 @@ "use strict"; | ||
const config_1 = require("hardhat/config"); | ||
const plugins_1 = require("hardhat/plugins"); | ||
const contract_names_1 = require("hardhat/utils/contract-names"); | ||
@@ -50,2 +49,3 @@ const path_1 = __importDefault(require("path")); | ||
const util_1 = require("./util"); | ||
const errors_1 = require("./errors"); | ||
(0, config_1.extendConfig)(config_2.etherscanConfigExtender); | ||
@@ -58,3 +58,3 @@ const verify = async ({ address, constructorArgsParams, constructorArgs: constructorArgsModule, contract, libraries: librariesModule, listNetworks, noCompile, }, { config, run }) => { | ||
if (address === undefined) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, "You didn’t provide any address. Please re-run the 'verify' task with the address of the contract you want to verify."); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, "You didn’t provide any address. Please re-run the 'verify' task with the address of the contract you want to verify."); | ||
} | ||
@@ -81,7 +81,7 @@ (0, config_2.verifyAllowedChains)(config.etherscan); | ||
if (!isAddress(address)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `${address} is an invalid address.`); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `${address} is an invalid address.`); | ||
} | ||
// This can only happen if the subtask is invoked from within Hardhat by a user script or another task. | ||
if (!Array.isArray(constructorArguments)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The constructorArguments parameter should be an array. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The constructorArguments parameter should be an array. | ||
If your constructor has no arguments pass an empty array. E.g: | ||
@@ -125,3 +125,3 @@ | ||
- The selected network (${network.name}) is wrong.`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message); | ||
} | ||
@@ -150,3 +150,3 @@ // Make sure that contract artifacts are up-to-date. | ||
const message = `It looks like you are verifying an OVM contract, but do not have an OVM solcVersion specified in the hardhat config.`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message); | ||
} | ||
@@ -196,3 +196,3 @@ contractInformation.solcVersion = `v${ovmSolcVersion}`; // Etherscan requires the leading `v` before the version string | ||
} | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, errorMessage); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, errorMessage); | ||
}; | ||
@@ -211,3 +211,3 @@ (0, config_1.subtask)(constants_1.TASK_VERIFY_GET_CONSTRUCTOR_ARGUMENTS) | ||
if (!Array.isArray(constructorArguments)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The module ${constructorArgsModulePath} doesn't export a list. The module should look like this: | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The module ${constructorArgsModulePath} doesn't export a list. The module should look like this: | ||
@@ -219,3 +219,3 @@ module.exports = [ arg1, arg2, ... ];`); | ||
catch (error) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Importing the module for the constructor arguments list failed. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Importing the module for the constructor arguments list failed. | ||
Reason: ${error.message}`, error); | ||
@@ -234,3 +234,3 @@ } | ||
if (typeof libraries !== "object" || Array.isArray(libraries)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The module ${librariesModulePath} doesn't export a dictionary. The module should look like this: | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The module ${librariesModulePath} doesn't export a dictionary. The module should look like this: | ||
@@ -242,3 +242,3 @@ module.exports = { lib1: "0x...", lib2: "0x...", ... };`); | ||
catch (error) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Importing the module for the libraries dictionary failed. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Importing the module for the libraries dictionary failed. | ||
Reason: ${error.message}`, error); | ||
@@ -276,3 +276,3 @@ } | ||
// Reaching this point shouldn't be possible unless the API is behaving in a new way. | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The API responded with an unexpected message. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The API responded with an unexpected message. | ||
Contract verification may have succeeded and should be checked manually. | ||
@@ -313,3 +313,3 @@ Message: ${verificationStatus.message}`, undefined, true); | ||
- The selected network (${network.name}) is wrong.`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message); | ||
} | ||
@@ -337,3 +337,3 @@ if (contractMatches.length > 1) { | ||
};`; | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message, undefined, true); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message, undefined, true); | ||
} | ||
@@ -355,3 +355,3 @@ return contractMatches[0]; | ||
})) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Etherscan only supports compiler versions 0.4.11 and higher. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Etherscan only supports compiler versions 0.4.11 and higher. | ||
See https://etherscan.io/solcversions for more information.`); | ||
@@ -372,7 +372,7 @@ } | ||
if (!(0, contract_names_1.isFullyQualifiedName)(contractFQN)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `A valid fully qualified name was expected. Fully qualified names look like this: "contracts/AContract.sol:TheContract" | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `A valid fully qualified name was expected. Fully qualified names look like this: "contracts/AContract.sol:TheContract" | ||
Instead, this name was received: ${contractFQN}`); | ||
} | ||
if (!(await artifacts.artifactExists(contractFQN))) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The contract ${contractFQN} is not present in your project.`); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The contract ${contractFQN} is not present in your project.`); | ||
} | ||
@@ -382,3 +382,3 @@ // Process BuildInfo here to check version and throw an error if unexpected version is found. | ||
if (buildInfo === undefined) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The contract ${contractFQN} is present in your project, but we couldn't find its sources. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The contract ${contractFQN} is present in your project, but we couldn't find its sources. | ||
Please make sure that it has been compiled by Hardhat and that it is written in Solidity.`); | ||
@@ -396,3 +396,3 @@ } | ||
} | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The contract ${contractFQN} is being compiled with ${buildInfo.solcVersion}. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The contract ${contractFQN} is being compiled with ${buildInfo.solcVersion}. | ||
However, the contract found in the address provided as argument has its bytecode marked with ${versionDetails}. | ||
@@ -408,3 +408,3 @@ | ||
if (contractInformation === null) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The address provided as argument contains a contract, but its bytecode doesn't match the contract ${contractFQN}. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The address provided as argument contains a contract, but its bytecode doesn't match the contract ${contractFQN}. | ||
@@ -487,3 +487,3 @@ Possible causes are: | ||
if (!invariant) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message, undefined, true); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message, undefined, true); | ||
} | ||
@@ -490,0 +490,0 @@ } |
@@ -8,3 +8,3 @@ "use strict"; | ||
async function getEtherscanEndpoints(provider, networkName, chainConfig, customChains) { | ||
const chainIdsToNames = new Map(entries(chainConfig).map(([chainName, config]) => [ | ||
const chainIdsToNames = new Map(Object.entries(chainConfig).map(([chainName, config]) => [ | ||
config.chainId, | ||
@@ -45,5 +45,2 @@ chainName, | ||
exports.retrieveContractBytecode = retrieveContractBytecode; | ||
function entries(o) { | ||
return Object.entries(o); | ||
} | ||
//# sourceMappingURL=prober.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveEtherscanApiKey = void 0; | ||
const plugins_1 = require("hardhat/plugins"); | ||
const constants_1 = require("./constants"); | ||
const errors_1 = require("./errors"); | ||
const resolveEtherscanApiKey = (apiKey, network) => { | ||
@@ -21,3 +21,3 @@ if (apiKey === undefined || apiKey === "") { | ||
function throwMissingApiKeyError(network) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `You are trying to verify a contract in '${network}', but no API token was found for this network. Please provide one in your hardhat config. For example: | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `You are trying to verify a contract in '${network}', but no API token was found for this network. Please provide one in your hardhat config. For example: | ||
@@ -24,0 +24,0 @@ { |
@@ -27,4 +27,4 @@ "use strict"; | ||
exports.getLibraryLinks = void 0; | ||
const plugins_1 = require("hardhat/plugins"); | ||
const constants_1 = require("../constants"); | ||
const errors_1 = require("../errors"); | ||
async function getLibraryLinks(contractInformation, libraries) { | ||
@@ -66,3 +66,3 @@ const allLibraries = getLibraryNames(contractInformation.contract.evm.bytecode.linkReferences); | ||
} | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, message); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, message); | ||
} | ||
@@ -96,3 +96,3 @@ return { libraryLinks: mergedLibraryLinks, undetectableLibraries }; | ||
.join("\n"); | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The following detected library addresses are different from the ones provided: | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The following detected library addresses are different from the ones provided: | ||
${conflictDescriptions} | ||
@@ -123,3 +123,3 @@ | ||
if (!isAddress(linkedLibraryAddress)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `You gave a link for the contract ${contractName} with the library ${linkedLibraryName}, but provided this invalid address: ${linkedLibraryAddress}`); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `You gave a link for the contract ${contractName} with the library ${linkedLibraryName}, but provided this invalid address: ${linkedLibraryAddress}`); | ||
} | ||
@@ -132,3 +132,3 @@ const neededLibrary = lookupLibrary(allLibraries, detectableLibraries, undetectableLibraries, linkedLibraryName, contractName); | ||
if (libraryFQNs.has(neededLibraryFQN)) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The library names ${neededLibrary.libName} and ${neededLibraryFQN} refer to the same library and were given as two entries in the libraries dictionary. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The library names ${neededLibrary.libName} and ${neededLibraryFQN} refer to the same library and were given as two entries in the libraries dictionary. | ||
Remove one of them and review your libraries dictionary before proceeding.`); | ||
@@ -172,3 +172,3 @@ } | ||
} | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `You gave an address for the library ${linkedLibraryName} in the libraries dictionary, which is not one of the libraries of contract ${contractName}. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `You gave an address for the library ${linkedLibraryName} in the libraries dictionary, which is not one of the libraries of contract ${contractName}. | ||
${detailedMessage}`); | ||
@@ -181,3 +181,3 @@ } | ||
.join("\n"); | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `The library name ${linkedLibraryName} is ambiguous for the contract ${contractName}. | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `The library name ${linkedLibraryName} is ambiguous for the contract ${contractName}. | ||
It may resolve to one of the following libraries: | ||
@@ -184,0 +184,0 @@ ${matchingLibrariesFQNs} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getVersions = exports.getLongVersion = void 0; | ||
const plugins_1 = require("hardhat/plugins"); | ||
const constants_1 = require("../constants"); | ||
const errors_1 = require("../errors"); | ||
const undici_1 = require("../undici"); | ||
@@ -13,3 +13,3 @@ const COMPILERS_LIST_URL = "https://solc-bin.ethereum.org/bin/list.json"; | ||
if (fullVersion === undefined || fullVersion === "") { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, "Given solc version doesn't exist"); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, "Given solc version doesn't exist"); | ||
} | ||
@@ -25,3 +25,3 @@ return fullVersion.replace(/(soljson-)(.*)(.js)/, "$2"); | ||
const responseText = await response.body.text(); | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `HTTP response is not ok. Status code: ${response.statusCode} Response text: ${responseText}`); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `HTTP response is not ok. Status code: ${response.statusCode} Response text: ${responseText}`); | ||
} | ||
@@ -31,3 +31,3 @@ return (await response.body.json()); | ||
catch (error) { | ||
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `Failed to obtain list of solc versions. Reason: ${error.message}`, error); | ||
throw new errors_1.HardhatEtherscanPluginError(constants_1.pluginName, `Failed to obtain list of solc versions. Reason: ${error.message}`, error); | ||
} | ||
@@ -34,0 +34,0 @@ } |
{ | ||
"name": "@nomiclabs/hardhat-etherscan", | ||
"version": "3.1.7", | ||
"version": "3.1.8", | ||
"description": "Hardhat plugin for verifying contracts on etherscan", | ||
@@ -5,0 +5,0 @@ "repository": "github:nomiclabs/hardhat", |
@@ -5,4 +5,12 @@ [![npm](https://img.shields.io/npm/v/@nomiclabs/hardhat-etherscan.svg)](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan) [![hardhat](https://hardhat.org/buidler-plugin-badge.svg?1)](https://hardhat.org) | ||
[Hardhat](https://hardhat.org) plugin for integration with [Etherscan](https://etherscan.io)'s contract verification service. | ||
The `@nomiclabs/hardhat-etherscan` plugin is deprecated in favor of our new [`@nomicfoundation/hardhat-verify`](/packages/hardhat-verify) plugin. | ||
## Migrating to `hardhat-verify` | ||
`hardhat-verify` is a drop-in replacement of `hardhat-etherscan`. To migrate to it: | ||
1. Uninstall the `@nomiclabs/hardhat-etherscan` package | ||
2. Install the `@nomicfoundation/hardhat-verify` package | ||
3. Update your Hardhat config to import `@nomicfoundation/hardhat-verify` instead of `@nomiclabs/hardhat-etherscan` | ||
## What | ||
@@ -9,0 +17,0 @@ |
@@ -1,3 +0,1 @@ | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { | ||
@@ -9,2 +7,3 @@ isABIArgumentLengthError, | ||
import { pluginName } from "./constants"; | ||
import { HardhatEtherscanPluginError } from "./errors"; | ||
@@ -30,3 +29,3 @@ export async function encodeArguments( | ||
but ${error.count.values} arguments were provided instead.`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message, error); | ||
throw new HardhatEtherscanPluginError(pluginName, message, error); | ||
} | ||
@@ -36,3 +35,3 @@ if (isABIArgumentTypeError(error)) { | ||
Encoder error reason: ${error.reason}`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message, error); | ||
throw new HardhatEtherscanPluginError(pluginName, message, error); | ||
} | ||
@@ -43,3 +42,3 @@ if (isABIArgumentOverflowError(error)) { | ||
Encoder error reason: ${error.fault} fault in ${error.operation}`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message, error); | ||
throw new HardhatEtherscanPluginError(pluginName, message, error); | ||
} | ||
@@ -46,0 +45,0 @@ // Should be unreachable. |
import type LodashT from "lodash"; | ||
import chalk from "chalk"; | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { ConfigExtender } from "hardhat/types"; | ||
@@ -9,2 +8,3 @@ import { chainConfig } from "./ChainConfig"; | ||
import { pluginName } from "./constants"; | ||
import { HardhatEtherscanPluginError } from "./errors"; | ||
@@ -30,3 +30,3 @@ export const verifyAllowedChains = (etherscanConfig: EtherscanConfig) => { | ||
if (invalidNetwork !== undefined) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -33,0 +33,0 @@ `You set an Etherscan API token for the network "${invalidNetwork}" but the plugin doesn't support it, or it's spelled incorrectly. |
@@ -0,1 +1,2 @@ | ||
import chalk from "chalk"; | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
@@ -5,2 +6,19 @@ | ||
export class HardhatEtherscanPluginError extends NomicLabsHardhatPluginError { | ||
constructor( | ||
name: string, | ||
message: string, | ||
parent?: Error, | ||
shouldBeReported = false | ||
) { | ||
super(name, message, parent, shouldBeReported); | ||
console.warn( | ||
chalk.yellow( | ||
"DEPRECATION WARNING: 'hardhat-etherscan' has been deprecated in favor of 'hardhat-verify'. You can find more information about the migration in the readme." | ||
) | ||
); | ||
} | ||
} | ||
export function throwUnsupportedNetwork( | ||
@@ -19,3 +37,3 @@ networkName: string, | ||
throw new NomicLabsHardhatPluginError(pluginName, message); | ||
throw new HardhatEtherscanPluginError(pluginName, message); | ||
} |
@@ -1,2 +0,1 @@ | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { Dispatcher } from "undici"; | ||
@@ -7,2 +6,3 @@ | ||
import { HardhatEtherscanPluginError } from "../errors"; | ||
import { | ||
@@ -30,3 +30,3 @@ EtherscanCheckStatusRequest, | ||
} catch (error: any) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -43,3 +43,3 @@ `Failed to send contract verification request. | ||
const responseText = await response.body.text(); | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -55,3 +55,3 @@ `Failed to send contract verification request. | ||
if (etherscanResponse.isBytecodeMissingInNetworkError()) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -68,3 +68,3 @@ `Failed to send contract verification request. | ||
if (!etherscanResponse.isOk()) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -95,6 +95,6 @@ etherscanResponse.message | ||
throw new NomicLabsHardhatPluginError(pluginName, message); | ||
throw new HardhatEtherscanPluginError(pluginName, message); | ||
} | ||
} catch (error: any) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -122,3 +122,3 @@ `Failure during etherscan status polling. The verification may still succeed but | ||
if (!etherscanResponse.isOk()) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -125,0 +125,0 @@ `The Etherscan API responded with a failure status. |
@@ -8,3 +8,2 @@ import { | ||
import { extendConfig, subtask, task, types } from "hardhat/config"; | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { | ||
@@ -71,2 +70,3 @@ ActionType, | ||
import { buildContractUrl, printSupportedNetworks } from "./util"; | ||
import { HardhatEtherscanPluginError } from "./errors"; | ||
@@ -153,3 +153,3 @@ interface VerificationArgs { | ||
if (address === undefined) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -197,3 +197,3 @@ "You didn’t provide any address. Please re-run the 'verify' task with the address of the contract you want to verify." | ||
if (!isAddress(address)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -206,3 +206,3 @@ `${address} is an invalid address.` | ||
if (!Array.isArray(constructorArguments)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -276,3 +276,3 @@ `The constructorArguments parameter should be an array. | ||
- The selected network (${network.name}) is wrong.`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message); | ||
throw new HardhatEtherscanPluginError(pluginName, message); | ||
} | ||
@@ -309,3 +309,3 @@ | ||
const message = `It looks like you are verifying an OVM contract, but do not have an OVM solcVersion specified in the hardhat config.`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message); | ||
throw new HardhatEtherscanPluginError(pluginName, message); | ||
} | ||
@@ -382,3 +382,3 @@ contractInformation.solcVersion = `v${ovmSolcVersion}`; // Etherscan requires the leading `v` before the version string | ||
} | ||
throw new NomicLabsHardhatPluginError(pluginName, errorMessage); | ||
throw new HardhatEtherscanPluginError(pluginName, errorMessage); | ||
}; | ||
@@ -416,3 +416,3 @@ | ||
if (!Array.isArray(constructorArguments)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -427,3 +427,3 @@ `The module ${constructorArgsModulePath} doesn't export a list. The module should look like this: | ||
} catch (error: any) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -456,3 +456,3 @@ `Importing the module for the constructor arguments list failed. | ||
if (typeof libraries !== "object" || Array.isArray(libraries)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -467,3 +467,3 @@ `The module ${librariesModulePath} doesn't export a dictionary. The module should look like this: | ||
} catch (error: any) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -528,3 +528,3 @@ `Importing the module for the libraries dictionary failed. | ||
// Reaching this point shouldn't be possible unless the API is behaving in a new way. | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -597,3 +597,3 @@ `The API responded with an unexpected message. | ||
- The selected network (${network.name}) is wrong.`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message); | ||
throw new HardhatEtherscanPluginError(pluginName, message); | ||
} | ||
@@ -621,3 +621,3 @@ if (contractMatches.length > 1) { | ||
};`; | ||
throw new NomicLabsHardhatPluginError(pluginName, message, undefined, true); | ||
throw new HardhatEtherscanPluginError(pluginName, message, undefined, true); | ||
} | ||
@@ -644,3 +644,3 @@ return contractMatches[0]; | ||
) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -685,3 +685,3 @@ `Etherscan only supports compiler versions 0.4.11 and higher. | ||
if (!isFullyQualifiedName(contractFQN)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -694,3 +694,3 @@ `A valid fully qualified name was expected. Fully qualified names look like this: "contracts/AContract.sol:TheContract" | ||
if (!(await artifacts.artifactExists(contractFQN))) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -705,3 +705,3 @@ `The contract ${contractFQN} is not present in your project.` | ||
if (buildInfo === undefined) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -725,3 +725,3 @@ `The contract ${contractFQN} is present in your project, but we couldn't find its sources. | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -748,3 +748,3 @@ `The contract ${contractFQN} is being compiled with ${buildInfo.solcVersion}. | ||
if (contractInformation === null) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -904,3 +904,3 @@ `The address provided as argument contains a contract, but its bytecode doesn't match the contract ${contractFQN}. | ||
if (!invariant) { | ||
throw new NomicLabsHardhatPluginError(pluginName, message, undefined, true); | ||
throw new HardhatEtherscanPluginError(pluginName, message, undefined, true); | ||
} | ||
@@ -907,0 +907,0 @@ } |
@@ -15,3 +15,3 @@ import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
const chainIdsToNames = new Map( | ||
entries(chainConfig).map(([chainName, config]) => [ | ||
Object.entries(chainConfig).map(([chainName, config]) => [ | ||
config.chainId, | ||
@@ -66,5 +66,1 @@ chainName, | ||
} | ||
function entries<O>(o: O) { | ||
return Object.entries(o) as Array<[keyof O, O[keyof O]]>; | ||
} |
@@ -1,4 +0,4 @@ | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { pluginName } from "./constants"; | ||
import { EtherscanConfig } from "./types"; | ||
import { HardhatEtherscanPluginError } from "./errors"; | ||
@@ -27,3 +27,3 @@ export const resolveEtherscanApiKey = ( | ||
function throwMissingApiKeyError(network: string): never { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -30,0 +30,0 @@ `You are trying to verify a contract in '${network}', but no API token was found for this network. Please provide one in your hardhat config. For example: |
@@ -1,5 +0,4 @@ | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { pluginName } from "../constants"; | ||
import { HardhatEtherscanPluginError } from "../errors"; | ||
import { ContractInformation, ResolvedLinks } from "./bytecode"; | ||
@@ -87,3 +86,3 @@ | ||
} | ||
throw new NomicLabsHardhatPluginError(pluginName, message); | ||
throw new HardhatEtherscanPluginError(pluginName, message); | ||
} | ||
@@ -126,3 +125,3 @@ return { libraryLinks: mergedLibraryLinks, undetectableLibraries }; | ||
.join("\n"); | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -171,3 +170,3 @@ `The following detected library addresses are different from the ones provided: | ||
if (!isAddress(linkedLibraryAddress)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -191,3 +190,3 @@ `You gave a link for the contract ${contractName} with the library ${linkedLibraryName}, but provided this invalid address: ${linkedLibraryAddress}` | ||
if (libraryFQNs.has(neededLibraryFQN)) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -244,3 +243,3 @@ `The library names ${neededLibrary.libName} and ${neededLibraryFQN} refer to the same library and were given as two entries in the libraries dictionary. | ||
} | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -257,3 +256,3 @@ `You gave an address for the library ${linkedLibraryName} in the libraries dictionary, which is not one of the libraries of contract ${contractName}. | ||
.join("\n"); | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -260,0 +259,0 @@ `The library name ${linkedLibraryName} is ambiguous for the contract ${contractName}. |
@@ -1,4 +0,3 @@ | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { pluginName } from "../constants"; | ||
import { HardhatEtherscanPluginError } from "../errors"; | ||
import { sendGetRequest } from "../undici"; | ||
@@ -22,3 +21,3 @@ | ||
if (fullVersion === undefined || fullVersion === "") { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -39,3 +38,3 @@ "Given solc version doesn't exist" | ||
const responseText = await response.body.text(); | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -48,3 +47,3 @@ `HTTP response is not ok. Status code: ${response.statusCode} Response text: ${responseText}` | ||
} catch (error: any) { | ||
throw new NomicLabsHardhatPluginError( | ||
throw new HardhatEtherscanPluginError( | ||
pluginName, | ||
@@ -51,0 +50,0 @@ `Failed to obtain list of solc versions. Reason: ${error.message}`, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
243067
4267
226