Skip to content
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

fix: forge script --verifier sourcify is ignored when ETHERSCAN_API_KEY env var is defined #10002

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Mar 3, 2025

Motivation

Closes: #10000

Solution

Reorders the way we check for the --verifiers:

If --verifier is passed explicitly we always use that specified verifier.
If --verifier is passed (excluding etherscan) and we have an ETHERSCAN_API_KEY defined in the environment we always use the specified identifier, ignoring the ETHERSCAN_API_KEY.
If --verifier etherscan is set, perform a hard check against whether the ETHERSCAN_API_KEY is set.
If no --verifier is specified but ETHERSCAN_API_KEY is set, default to Etherscan.
If no --verifier is specified and no ETHERSCAN_API_KEY is set we bail, throwing a useful error.

This should satisfy all conditions.

PR Checklist

Manually tested against sandbox in #10000 confirming I was able to verify with Sourcify even if ETHERSCAN_API_KEY was set. Previously it would attempt to verify with Etherscan.

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks zerosnacks marked this pull request as ready for review March 3, 2025 14:30
@zerosnacks zerosnacks added T-bug Type: bug C-forge Command: forge Cmd-forge-script Command: forge script labels Mar 3, 2025
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@zerosnacks zerosnacks merged commit abbcc45 into master Mar 4, 2025
22 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/override-etherscan-api-key-if-alternative-verifier-is-set branch March 4, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

forge script --verifier sourcify is ignored when ETHERSCAN_API_KEY env var is defined
2 participants