-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ignition: verify on all enabled verification services #7967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kanej
merged 16 commits into
NomicFoundation:main
from
manuelwedler:ignition-verify-on-all
Mar 17, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4504411
Verify on all enabled verification providers with `ignition verify`
manuelwedler 64600ab
ignition: Store creationTxHash in successful deployment information a…
manuelwedler 481b221
Add changeset entry
manuelwedler 4725683
Fix property order in journal files
manuelwedler ca6df13
Update changeset
manuelwedler 832ae4d
chore: update the changeset text
kanej 3bfe0fe
refactor: pull deployment transaction hash from state
kanej ada1304
refactor: revert the createTxState addition
kanej 270e2a9
tweak the text of the verify parameter
kanej c1914fd
docs: update type doc to no longer reference etherscan exclusively
kanej 98be7a2
test: add additional tests
kanej c28de8e
Merge remote-tracking branch 'origin/main' into feat/ignition-verify-…
kanej ad64b52
chore: fix copy and paste mistake
kanej daa98a2
feat: set exit code on verify failure
kanej 686e6a5
docs: update strategy doc with rule on last transaction
kanej 316c7e9
Merge branch 'main' into feat/ignition-verify-on-all
kanej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@nomicfoundation/hardhat-ignition": minor | ||
| "@nomicfoundation/ignition-core": minor | ||
| "@nomicfoundation/hardhat-ignition-ethers": minor | ||
| "@nomicfoundation/hardhat-ignition-viem": minor | ||
| "@nomicfoundation/ignition-ui": minor | ||
| --- | ||
|
|
||
| Added support for verifying on all enabled verification services (e.g. Sourcify) ([#7538](https://github.com/NomicFoundation/hardhat/issues/7538)). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| import type { VerifyContractArgs } from "@nomicfoundation/hardhat-verify/verify"; | ||
| import type { VerifyResult } from "@nomicfoundation/ignition-core"; | ||
| import type { VerificationProvidersConfig } from "hardhat/types/config"; | ||
| import type { HardhatRuntimeEnvironment } from "hardhat/types/hre"; | ||
|
|
||
| import { assert } from "chai"; | ||
| import sinon from "sinon"; | ||
|
|
||
| import { verify } from "../../src/internal/tasks/verify.js"; | ||
| import { useEphemeralIgnitionProject } from "../test-helpers/use-ignition-project.js"; | ||
|
|
||
| describe("ignition verify task", () => { | ||
| useEphemeralIgnitionProject("minimal"); | ||
|
|
||
| // TODO: replace with disableConsole() once converted to `node:test` | ||
| let consoleLogStub: sinon.SinonStub; | ||
| let consoleWarnStub: sinon.SinonStub; | ||
| let consoleErrorStub: sinon.SinonStub; | ||
|
|
||
| beforeEach(() => { | ||
| consoleLogStub = sinon.stub(console, "log"); | ||
| consoleWarnStub = sinon.stub(console, "warn"); | ||
| consoleErrorStub = sinon.stub(console, "error"); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| consoleLogStub.restore(); | ||
| consoleWarnStub.restore(); | ||
| consoleErrorStub.restore(); | ||
|
|
||
| process.exitCode = undefined; | ||
| }); | ||
|
|
||
| const exampleVerifyInfo: VerifyResult = { | ||
| address: "0x1234567890123456789012345678901234567890", | ||
| constructorArgs: [], | ||
| libraries: {}, | ||
| contract: "contracts/Foo.sol:Foo", | ||
| creationTxHash: | ||
| "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", | ||
| }; | ||
|
|
||
| it("should verify on all enabled providers", async function () { | ||
| const verifyCallsByProvider: Array<keyof VerificationProvidersConfig> = []; | ||
|
|
||
| const mockVerifyContract = async ( | ||
| args: VerifyContractArgs, | ||
| _hre: HardhatRuntimeEnvironment, | ||
| ) => { | ||
| if (args.provider !== undefined) { | ||
| verifyCallsByProvider.push(args.provider); | ||
| } | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| const mockGetVerificationInformation = async function* () { | ||
| yield exampleVerifyInfo; | ||
| }; | ||
|
|
||
| await verify( | ||
| { deploymentId: "test-deployment", force: false }, | ||
| this.hre, | ||
| mockVerifyContract, | ||
| mockGetVerificationInformation, | ||
| ); | ||
|
|
||
| assert.equal(verifyCallsByProvider.length, 3); | ||
| assert.include(verifyCallsByProvider, "etherscan"); | ||
| assert.include(verifyCallsByProvider, "blockscout"); | ||
| assert.include(verifyCallsByProvider, "sourcify"); | ||
|
|
||
| assert.equal(process.exitCode, undefined); | ||
| }); | ||
|
|
||
| it("should continue verification on other providers when one fails", async function () { | ||
| const verifyCallsByProvider: Array<keyof VerificationProvidersConfig> = []; | ||
|
|
||
| const mockVerifyContract = async ( | ||
| args: VerifyContractArgs, | ||
| _hre: HardhatRuntimeEnvironment, | ||
| ) => { | ||
| if (args.provider !== undefined) { | ||
| verifyCallsByProvider.push(args.provider); | ||
|
|
||
| if (args.provider === "blockscout") { | ||
| throw new Error("Blockscout verification failed"); | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| const mockGetVerificationInformation = async function* () { | ||
| yield exampleVerifyInfo; | ||
| }; | ||
|
|
||
| await verify( | ||
| { deploymentId: "test-deployment", force: false }, | ||
| this.hre, | ||
| mockVerifyContract, | ||
| mockGetVerificationInformation, | ||
| ); | ||
|
|
||
| assert.equal(verifyCallsByProvider.length, 3); | ||
| assert.include(verifyCallsByProvider, "etherscan"); | ||
| assert.include(verifyCallsByProvider, "blockscout"); | ||
| assert.include(verifyCallsByProvider, "sourcify"); | ||
|
|
||
| assert.equal(process.exitCode, 1); | ||
| }); | ||
|
|
||
| it("should not verify when no providers are enabled", async function () { | ||
| let verifyContractCalled = false; | ||
|
|
||
| await verify( | ||
| { deploymentId: "test-deployment", force: false }, | ||
| { | ||
| ...this.hre, | ||
| config: { | ||
| ...this.hre.config, | ||
| verify: { | ||
| etherscan: { enabled: false, apiKey: "" as any }, | ||
| blockscout: { enabled: false }, | ||
| sourcify: { enabled: false }, | ||
| }, | ||
| }, | ||
| }, | ||
| async () => { | ||
| verifyContractCalled = true; | ||
|
|
||
| return true; | ||
| }, | ||
| async function* () {}, | ||
| ); | ||
|
|
||
| assert.isFalse(verifyContractCalled); | ||
| }); | ||
|
|
||
| it("should verify multiple contracts on all enabled providers", async function () { | ||
| const verifyCalls: Array<{ provider: string; contract: string }> = []; | ||
|
|
||
| const mockVerifyContract = async ( | ||
| args: VerifyContractArgs, | ||
| _hre: HardhatRuntimeEnvironment, | ||
| ) => { | ||
| if (args.contract === undefined) { | ||
| assert.fail("Expected contract to be passed"); | ||
| } | ||
|
|
||
| if (args.provider !== undefined) { | ||
| verifyCalls.push({ provider: args.provider, contract: args.contract }); | ||
| } | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| const mockGetVerificationInformation = async function* () { | ||
| yield { | ||
| address: "0x1111111111111111111111111111111111111111", | ||
| constructorArgs: [], | ||
| libraries: {}, | ||
| contract: "contracts/Foo.sol:Foo", | ||
| creationTxHash: | ||
| "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
| }; | ||
| yield { | ||
| address: "0x2222222222222222222222222222222222222222", | ||
| constructorArgs: [123], | ||
| libraries: {}, | ||
| contract: "contracts/Bar.sol:Bar", | ||
| creationTxHash: | ||
| "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | ||
| }; | ||
| }; | ||
|
|
||
| await verify( | ||
| { deploymentId: "test-deployment", force: false }, | ||
| this.hre, | ||
| mockVerifyContract, | ||
| mockGetVerificationInformation, | ||
| ); | ||
|
|
||
| // 2 contracts × 3 providers = 6 calls | ||
| assert.equal(verifyCalls.length, 6); | ||
|
|
||
| // Each contract should be verified on each provider | ||
| assert.deepEqual(verifyCalls, [ | ||
| { provider: "etherscan", contract: "contracts/Foo.sol:Foo" }, | ||
| { provider: "blockscout", contract: "contracts/Foo.sol:Foo" }, | ||
| { provider: "sourcify", contract: "contracts/Foo.sol:Foo" }, | ||
| { provider: "etherscan", contract: "contracts/Bar.sol:Bar" }, | ||
| { provider: "blockscout", contract: "contracts/Bar.sol:Bar" }, | ||
| { provider: "sourcify", contract: "contracts/Bar.sol:Bar" }, | ||
| ]); | ||
| }); | ||
|
|
||
| it("should pass force flag through to each provider call", async function () { | ||
| const forceValues: boolean[] = []; | ||
|
|
||
| const mockVerifyContract = async ( | ||
| args: VerifyContractArgs, | ||
| _hre: HardhatRuntimeEnvironment, | ||
| ) => { | ||
| if (args.force === undefined) { | ||
| assert.fail("Expected force to be passed"); | ||
| } | ||
|
|
||
| forceValues.push(args.force); | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| const mockGetVerificationInformation = async function* () { | ||
| yield exampleVerifyInfo; | ||
| }; | ||
|
|
||
| await verify( | ||
| { deploymentId: "test-deployment", force: true }, | ||
| this.hre, | ||
| mockVerifyContract, | ||
| mockGetVerificationInformation, | ||
| ); | ||
|
|
||
| assert.equal(forceValues.length, 3); | ||
| assert.isTrue( | ||
| forceValues.every((f) => f === true), | ||
| "Expected all verify calls to have force: true", | ||
| ); | ||
| }); | ||
|
|
||
| it("should not verify if contracts artifacts cannot be resolved", async function () { | ||
| let verifyContractCalled = false; | ||
|
|
||
| const mockGetVerificationInformation = async function* () { | ||
| yield "contracts/Foo.sol:Foo"; | ||
| }; | ||
|
|
||
| await verify( | ||
| { deploymentId: "test-deployment", force: false }, | ||
| this.hre, | ||
| async () => { | ||
| verifyContractCalled = true; | ||
|
|
||
| return true; | ||
| }, | ||
| mockGetVerificationInformation, | ||
| ); | ||
|
|
||
| assert.isFalse(verifyContractCalled); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.