diff --git a/.changeset/fuzzy-eyes-collect.md b/.changeset/fuzzy-eyes-collect.md new file mode 100644 index 0000000000..dc057aca7f --- /dev/null +++ b/.changeset/fuzzy-eyes-collect.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/hardhat-verify": patch +--- + +Make the `--force` flag override the check of any existing verification, even in the presence of errors. diff --git a/packages/hardhat-verify/src/internal/tasks/etherscan.ts b/packages/hardhat-verify/src/internal/tasks/etherscan.ts index e238896ebf..1154f8abf7 100644 --- a/packages/hardhat-verify/src/internal/tasks/etherscan.ts +++ b/packages/hardhat-verify/src/internal/tasks/etherscan.ts @@ -27,6 +27,7 @@ import { UnexpectedNumberOfFilesError, VerificationAPIUnexpectedMessageError, ContractAlreadyVerifiedError, + NetworkRequestError, } from "../errors"; import { Etherscan } from "../etherscan"; import { Bytecode } from "../solc/bytecode"; @@ -102,7 +103,15 @@ subtask(TASK_VERIFY_ETHERSCAN) chainConfig ); - const isVerified = await etherscan.isVerified(address); + let isVerified = false; + try { + isVerified = await etherscan.isVerified(address); + } catch (err) { + if (!force || err instanceof NetworkRequestError) { + throw err; + } + // https://github.com/blockscout/blockscout/issues/9001 + } if (!force && isVerified) { const contractURL = etherscan.getContractUrl(address); console.log(`The contract ${address} has already been verified on the block explorer. If you're trying to verify a partially verified contract, please use the --force flag.