Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/verify/src/etherscan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
};
Expand Down
12 changes: 10 additions & 2 deletions crates/verify/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ pub struct JsonResult {
pub message: Option<String>,
}

pub(crate) fn version_without_build(version: &str) -> Option<&str> {
version.split('+').next().filter(|s| !s.is_empty())
}

pub(crate) fn normalize_compiler_version_str(version: &str) -> String {
version_without_build(version).unwrap_or("").trim_start_matches('v').to_string()
}

pub fn match_bytecodes(
local_bytecode: &[u8],
bytecode: &[u8],
Expand Down Expand Up @@ -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()) {
Expand Down
Loading