Skip to content

Commit cd8e505

Browse files
authored
fix(verify): correct constructor argument format for ZKsync verification (#1166)
* fix(verify): correct constructor argument format for ZKsync verification ZKsync verification broke in v0.0.27 when switching from JSON to form-encoded requests. The form-encoded API expects constructor arguments in a different format: - Empty constructor args: empty string (not "0x") - Non-empty constructor args: raw hex without "0x" prefix This fixes "Invalid constructor arguments" errors for both cases. * clippy fixes
1 parent aa5c7c6 commit cd8e505

File tree

2 files changed

+53
-37
lines changed

2 files changed

+53
-37
lines changed

Cargo.lock

Lines changed: 41 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/verify/src/zksync/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,25 @@ impl ZkVerificationProvider {
289289
)?,
290290
)?;
291291
let encoded_args = hex::encode(encoded_args);
292-
return Ok(Some(format!("0x{}", &encoded_args[8..])));
292+
// Note(zk): Form-encoded API expects constructor args without "0x" prefix
293+
// Strip first 8 chars (function selector) and don't add "0x" prefix
294+
return Ok(Some(encoded_args[8..].to_string()));
293295
}
294296

295297
if let Some(ref args) = args.constructor_args {
296-
if args.starts_with("0x") {
297-
return Ok(Some(args.clone()));
298+
// Note(zk): Form-encoded API expects constructor args without "0x" prefix
299+
// Strip "0x" prefix if present for form encoding compatibility
300+
301+
if let Some(args) = args.strip_prefix("0x") {
302+
return Ok(Some(args.to_string()));
298303
} else {
299-
return Ok(Some(format!("0x{args}")));
304+
return Ok(Some(args.clone()));
300305
}
301306
}
302307

303-
Ok(None)
308+
// Note(zk): Form-encoded API expects empty string for contracts with no constructor args,
309+
// not "0x". The JSON API used to expect "0x", but form encoding expects empty string.
310+
Ok(Some(String::new()))
304311
}
305312
/// Retry logic for checking the verification status
306313
async fn retry_verification_status(

0 commit comments

Comments
 (0)