Skip to content

Commit a8ce825

Browse files
manuelwedlergrandizzy
authored andcommitted
feat(forge verify-contract): update Sourcify integration to support API v2 (foundry-rs#11438)
* use sourcify api v2 in forge verify-contract * add is_contract_verified check to sourcify verification * add support for providing the creation transaction hash for sourcify verification * use `#[serde(rename_all = "camelCase")]` on all sourcify response structs * Remove `validate_tx_hash` function * address feedback * Fix --------- Co-authored-by: grandizzy <[email protected]>
1 parent 32fec6c commit a8ce825

File tree

6 files changed

+341
-125
lines changed

6 files changed

+341
-125
lines changed

crates/forge/src/cmd/create.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ impl CreateArgs {
248248
guess_constructor_args: false,
249249
compilation_profile: Some(id.profile.to_string()),
250250
language: None,
251+
creation_transaction_hash: None,
251252
};
252253

253254
// Check config for Etherscan API Keys to avoid preflight check failing if no
@@ -434,6 +435,7 @@ impl CreateArgs {
434435
guess_constructor_args: false,
435436
compilation_profile: Some(id.profile.to_string()),
436437
language: None,
438+
creation_transaction_hash: Some(receipt.transaction_hash),
437439
};
438440
sh_println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier)?;
439441
verify.run().await

crates/script/src/verify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl VerifyBundle {
163163
guess_constructor_args: false,
164164
compilation_profile: Some(artifact.profile.to_string()),
165165
language: None,
166+
creation_transaction_hash: None,
166167
};
167168

168169
return Some(verify);

crates/verify/src/etherscan/mod.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::{
22
VerifierArgs,
33
provider::{VerificationContext, VerificationProvider},
44
retry::RETRY_CHECK_ON_VERIFY,
5+
utils::ensure_solc_build_metadata,
56
verify::{ContractLanguage, VerifyArgs, VerifyCheckArgs},
67
};
78
use alloy_json_abi::Function;
@@ -12,7 +13,6 @@ use eyre::{Context, OptionExt, Result, eyre};
1213
use foundry_block_explorers::{
1314
Client,
1415
errors::EtherscanError,
15-
utils::lookup_compiler_version,
1616
verify::{CodeFormat, VerifyContract},
1717
};
1818
use foundry_cli::{
@@ -24,7 +24,7 @@ use foundry_compilers::{Artifact, artifacts::BytecodeObject};
2424
use foundry_config::Config;
2525
use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER;
2626
use regex::Regex;
27-
use semver::{BuildMetadata, Version};
27+
use semver::BuildMetadata;
2828
use std::{fmt::Debug, sync::LazyLock};
2929

3030
mod flatten;
@@ -451,24 +451,6 @@ impl EtherscanVerificationProvider {
451451
}
452452
}
453453

454-
/// Given any solc [Version] return a [Version] with build metadata
455-
///
456-
/// # Example
457-
///
458-
/// ```ignore
459-
/// use semver::{BuildMetadata, Version};
460-
/// let version = Version::new(1, 2, 3);
461-
/// let version = ensure_solc_build_metadata(version).await?;
462-
/// assert_ne!(version.build, BuildMetadata::EMPTY);
463-
/// ```
464-
async fn ensure_solc_build_metadata(version: Version) -> Result<Version> {
465-
if version.build != BuildMetadata::EMPTY {
466-
Ok(version)
467-
} else {
468-
Ok(lookup_compiler_version(&version).await?)
469-
}
470-
}
471-
472454
#[cfg(test)]
473455
mod tests {
474456
use super::*;

0 commit comments

Comments
 (0)