Skip to content

feat: Etherscan V2 support #10440

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
merged 20 commits into from
May 8, 2025
Merged

Conversation

grandizzy
Copy link
Collaborator

@grandizzy grandizzy commented May 5, 2025

Motivation

[etherscan]
sepolia = { key = "$KEY"}
optimisim = { key = "$KEY" }
base-sepolia = { key = "$KEY_V1", api-version="v1" }

or etherscan_api_version = "v2" in top level foundry.toml

  • new --etherscan-api-version to forge and cast commands (added for v1 compatibility), defaults to v2
  • chisel supports v2 only (for fetch commands)

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@grandizzy grandizzy force-pushed the etherscan-v2-redo branch from c5592d5 to 735424c Compare May 5, 2025 09:25
@grandizzy grandizzy added T-feature Type: feature C-forge Command: forge labels May 5, 2025
@grandizzy grandizzy self-assigned this May 5, 2025
@grandizzy grandizzy added this to the v1.2.0 milestone May 5, 2025
@jenpaff jenpaff moved this to In Progress in Foundry May 5, 2025
@grandizzy grandizzy force-pushed the etherscan-v2-redo branch from 6337fa1 to a182e56 Compare May 6, 2025 16:29
@grandizzy grandizzy mentioned this pull request May 6, 2025
3 tasks
@grandizzy grandizzy marked this pull request as ready for review May 6, 2025 19:10
@grandizzy grandizzy requested a review from DaniPopes as a code owner May 6, 2025 19:10
env = "ETHERSCAN_API_VERSION"
)]
#[serde(rename = "etherscan_api_version", skip_serializing_if = "Option::is_none")]
pub api_version: Option<String>,
Copy link
Contributor

@iainnash iainnash May 6, 2025

Choose a reason for hiding this comment

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

Since the package is included here if it makes sense to use the struct you would get seralization/deseralization errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point, yeah, could also get rid of the newly introduced InvalidApiVersion, requires foundry-rs/block-explorers#85

Copy link
Collaborator Author

@grandizzy grandizzy May 7, 2025

Choose a reason for hiding this comment

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

Simplified in 24782b1

@@ -1324,6 +1324,7 @@ async fn test_fork_execution_reverted() {

// <https://github.com/foundry-rs/foundry/issues/8227>
#[tokio::test(flavor = "multi_thread")]
#[ignore]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

unrelated, flaky immutable test

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm!

Comment on lines +138 to +140
let chain = config.chain.unwrap_or_default();
let api_version = config.get_etherscan_api_version(Some(chain));
let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default();
Copy link
Member

Choose a reason for hiding this comment

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

it's funny how when you try to unify things you now suddenly need to handle another case -.-

if is_etherscan {
etherscan_config.as_ref().map(|c| c.api_version).unwrap_or_default()
} else {
EtherscanApiVersion::V1
Copy link
Member

Choose a reason for hiding this comment

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

I see, this is for non v2 compat verifiers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, they'll default to v1, we can gradually move that to default v2 as they upgrade

Copy link
Member

@yash-atreya yash-atreya left a comment

Choose a reason for hiding this comment

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

lgtm!

@grandizzy grandizzy merged commit 0f87460 into foundry-rs:master May 8, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Foundry May 8, 2025
@grandizzy grandizzy deleted the etherscan-v2-redo branch May 8, 2025 06:28
@iainnash
Copy link
Contributor

iainnash commented May 8, 2025

Exciting!

@grandizzy
Copy link
Collaborator Author

Exciting!

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge T-feature Type: feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

debt: use the single Etherscan V2 API endpoint for unified verification / query flow w/ single API key
4 participants