From e445d12e205e1e31bf942244c5dc907935bf56d8 Mon Sep 17 00:00:00 2001 From: Alvarez <140459501+prestoalvarez@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:39:56 +0100 Subject: [PATCH 1/6] Update utils.rs --- crates/verify/src/utils.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 8f24e67ebf3f1..6d0bb39114a62 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -59,6 +59,14 @@ pub struct JsonResult { pub message: Option, } +pub fn version_without_build(version: &str) -> String { + version.split('+').next().unwrap_or("").to_string() +} + +pub fn normalize_compiler_version_str(version: &str) -> String { + version_without_build(version).trim_start_matches('v').to_string() +} + pub fn match_bytecodes( local_bytecode: &[u8], bytecode: &[u8], @@ -113,8 +121,8 @@ pub fn build_using_cache( if version.starts_with("vyper:") { eyre::bail!("Vyper contracts are not supported") } - // Parse etherscan version string - let version = version.split('+').next().unwrap_or("").trim_start_matches('v').to_string(); + // Parse etherscan version string using a shared normalizer + let version = normalize_compiler_version_str(&version); // Check if `out/directory` name matches the contract name if key.ends_with(name.as_str()) { From f19ad5d659733f4884b9c104b3fe70987e26820e Mon Sep 17 00:00:00 2001 From: Alvarez <140459501+prestoalvarez@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:41:51 +0100 Subject: [PATCH 2/6] Update mod.rs --- crates/verify/src/etherscan/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 60f8daf962adf..071d229a85468 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -317,7 +317,9 @@ impl EtherscanVerificationProvider { }; let compiler_version = if matches!(lang, ContractLanguage::Vyper) { - format!("vyper:{}", compiler_version.to_string().split('+').next().unwrap_or("0.0.0")) + let base = crate::utils::version_without_build(&compiler_version.to_string()); + let base = if base.is_empty() { "0.0.0".to_string() } else { base }; + format!("vyper:{}", base) } else { format!("v{}", ensure_solc_build_metadata(context.compiler_version.clone()).await?) }; From 54148c0ef3e21c8b9cc3c208c1a293f550df14bb Mon Sep 17 00:00:00 2001 From: Alvarez <140459501+prestoalvarez@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:40:58 +0100 Subject: [PATCH 3/6] Update utils.rs --- crates/verify/src/utils.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 6d0bb39114a62..b251d5566789f 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -59,12 +59,21 @@ pub struct JsonResult { pub message: Option, } -pub fn version_without_build(version: &str) -> String { - version.split('+').next().unwrap_or("").to_string() +/// Returns the version string without build metadata part after '+'. +/// Returns `None` if the version string is empty or contains only '+'. +/// Example: "0.8.26+commit.abcdef" -> Some("0.8.26") +fn version_without_build(version: &str) -> Option<&str> { + version.split('+').next().filter(|s| !s.is_empty()) } -pub fn normalize_compiler_version_str(version: &str) -> String { - version_without_build(version).trim_start_matches('v').to_string() +/// Normalizes a compiler version string by dropping build metadata and a leading 'v'. +/// Returns an empty string if the version cannot be normalized. +/// Example: "v0.8.26+commit.abcdef" -> "0.8.26" +fn normalize_compiler_version_str(version: &str) -> String { + version_without_build(version) + .unwrap_or("") + .trim_start_matches('v') + .to_string() } pub fn match_bytecodes( From 41d6d5d8c9ceadb551816630897b1808fefc349c Mon Sep 17 00:00:00 2001 From: Alvarez <140459501+prestoalvarez@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:42:57 +0100 Subject: [PATCH 4/6] Update utils.rs --- crates/verify/src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index b251d5566789f..227de4e75bed9 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -62,14 +62,14 @@ pub struct JsonResult { /// Returns the version string without build metadata part after '+'. /// Returns `None` if the version string is empty or contains only '+'. /// Example: "0.8.26+commit.abcdef" -> Some("0.8.26") -fn version_without_build(version: &str) -> Option<&str> { +pub(crate) fn version_without_build(version: &str) -> Option<&str> { version.split('+').next().filter(|s| !s.is_empty()) } /// Normalizes a compiler version string by dropping build metadata and a leading 'v'. /// Returns an empty string if the version cannot be normalized. /// Example: "v0.8.26+commit.abcdef" -> "0.8.26" -fn normalize_compiler_version_str(version: &str) -> String { +pub(crate) fn normalize_compiler_version_str(version: &str) -> String { version_without_build(version) .unwrap_or("") .trim_start_matches('v') From 937c39bf2b0f8cd8c83449ef61b8e4c242b84540 Mon Sep 17 00:00:00 2001 From: Alvarez <140459501+prestoalvarez@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:45:25 +0100 Subject: [PATCH 5/6] Update utils.rs --- crates/verify/src/utils.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 227de4e75bed9..424779abeb09d 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -70,10 +70,7 @@ pub(crate) fn version_without_build(version: &str) -> Option<&str> { /// Returns an empty string if the version cannot be normalized. /// Example: "v0.8.26+commit.abcdef" -> "0.8.26" pub(crate) fn normalize_compiler_version_str(version: &str) -> String { - version_without_build(version) - .unwrap_or("") - .trim_start_matches('v') - .to_string() + version_without_build(version).unwrap_or("").trim_start_matches('v').to_string() } pub fn match_bytecodes( From 9587fd70116f62bee41b7bcfb00d85a2c08af6f7 Mon Sep 17 00:00:00 2001 From: Alvarez <140459501+prestoalvarez@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:55:43 +0100 Subject: [PATCH 6/6] Update utils.rs --- crates/verify/src/utils.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 424779abeb09d..be0078b4f0b35 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -59,16 +59,10 @@ pub struct JsonResult { pub message: Option, } -/// Returns the version string without build metadata part after '+'. -/// Returns `None` if the version string is empty or contains only '+'. -/// Example: "0.8.26+commit.abcdef" -> Some("0.8.26") pub(crate) fn version_without_build(version: &str) -> Option<&str> { version.split('+').next().filter(|s| !s.is_empty()) } -/// Normalizes a compiler version string by dropping build metadata and a leading 'v'. -/// Returns an empty string if the version cannot be normalized. -/// Example: "v0.8.26+commit.abcdef" -> "0.8.26" pub(crate) fn normalize_compiler_version_str(version: &str) -> String { version_without_build(version).unwrap_or("").trim_start_matches('v').to_string() }