starknet-contract-verifier 0.4.4

Contract class verification tool that allows you to verify your starknet classes on a block explorer.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
mod args;
use crate::args::{Args, Commands, VerifyArgs};

use camino::{Utf8Path, Utf8PathBuf};
use chrono::{DateTime, Utc};
use clap::Parser;
use colored::*;
use itertools::Itertools;
use log::{debug, info, warn};
use scarb_metadata::PackageMetadata;
use std::collections::HashMap;
use std::time::{Duration, UNIX_EPOCH};
use thiserror::Error;
use verifier::{
    api::{
        poll_verification_status, ApiClient, ApiClientError, FileInfo, ProjectMetadataInfo,
        VerificationJob, VerifyJobStatus,
    },
    class_hash::ClassHash,
    errors, license, resolver, voyager,
};

#[derive(Debug, Error)]
pub enum CliError {
    #[error(transparent)]
    Args(#[from] crate::args::ProjectError),

    #[error(transparent)]
    Api(#[from] ApiClientError),

    #[error(transparent)]
    MissingPackage(#[from] errors::MissingPackage),

    #[error("[E015] Class hash '{0}' is not declared\n\nSuggestions:\n  • Verify the class hash is correct\n  • Check that the contract has been declared on the network\n  • Ensure you're using the correct network (mainnet/testnet)\n  • Use a block explorer to verify the class hash exists")]
    NotDeclared(ClassHash),

    #[error("[E016] No contracts selected for verification\n\nSuggestions:\n  • Use --contract-name <name> to specify a contract\n  • Check that contracts are defined in [tool.voyager] section\n  • Verify your Scarb.toml contains contract definitions\n  • Use 'scarb metadata' to list available contracts")]
    NoTarget,

    #[error("[E017] Multiple contracts found - only single contract verification is supported\n\nSuggestions:\n  • Use --contract-name <name> to specify which contract to verify\n  • Choose one from the available contracts\n  • Verify each contract separately")]
    MultipleContracts,

    #[error(transparent)]
    MissingContract(#[from] errors::MissingContract),

    #[error(transparent)]
    Resolver(#[from] resolver::Error),

    #[error("[E018] Path processing error: cannot strip '{prefix}' from '{path}'\n\nThis is an internal error. Please report this issue with:\n  • The full command you ran\n  • Your project structure\n  • The contents of your Scarb.toml")]
    StripPrefix {
        path: Utf8PathBuf,
        prefix: Utf8PathBuf,
    },

    #[error(transparent)]
    Utf8(#[from] camino::FromPathBufError),

    #[error(transparent)]
    Voyager(#[from] voyager::Error),

    #[error("[E019] File '{path}' exceeds maximum size limit of {max_size} bytes (actual: {actual_size} bytes)\n\nSuggestions:\n  • Reduce the file size by removing unnecessary content\n  • Split large files into smaller modules\n  • Check if the file contains generated or temporary content\n  • Use .gitignore to exclude large files that shouldn't be verified")]
    FileSizeLimit {
        path: Utf8PathBuf,
        max_size: usize,
        actual_size: usize,
    },

    #[error("[E024] File '{path}' has invalid file type (extension: {extension})\n\nSuggestions:\n  • Only include Cairo source files (.cairo)\n  • Include project configuration files (.toml, .lock)\n  • Include documentation files (.md, .txt)\n  • Remove binary or executable files from the project\n  • Allowed extensions: .cairo, .toml, .lock, .md, .txt, .json")]
    InvalidFileType {
        path: Utf8PathBuf,
        extension: String,
    },
}

impl CliError {
    pub const fn error_code(&self) -> &'static str {
        match self {
            Self::Args(_) => "E020",
            Self::Api(e) => e.error_code(),
            Self::MissingPackage(e) => e.error_code().as_str(),
            Self::NotDeclared(_) => "E015",
            Self::NoTarget => "E016",
            Self::MultipleContracts => "E017",
            Self::MissingContract(e) => e.error_code().as_str(),
            Self::Resolver(e) => e.error_code(),
            Self::StripPrefix { .. } => "E018",
            Self::Utf8(_) => "E023",
            Self::Voyager(_) => "E999",
            Self::FileSizeLimit { .. } => "E019",
            Self::InvalidFileType { .. } => "E024",
        }
    }
}

fn display_verification_job_id(job_id: &str) {
    println!();
    println!("verification job id: {}", job_id.green().bold());
    println!();
}

fn main() -> anyhow::Result<()> {
    env_logger::init();
    let Args { command: cmd } = Args::parse();

    match &cmd {
        Commands::Verify(args) => {
            let public = ApiClient::new(args.network_url.public.clone())?;
            let private = ApiClient::new(args.network_url.private.clone())?;

            let license_info = license::resolve_license_info(
                args.license,
                args.path.get_license(),
                args.path.manifest_path(),
            );

            license::warn_if_no_license(&license_info);

            let job_id = submit(&public, &private, args, &license_info).map_err(|e| {
                if let CliError::Api(ApiClientError::Verify(ref verification_error)) = e {
                    eprintln!("\nSuggestions:");
                    for suggestion in verification_error.suggestions() {
                        eprintln!("{suggestion}");
                    }
                } else if let CliError::Api(ApiClientError::Failure(ref _request_failure)) = e {
                    // RequestFailure errors already include suggestions in their display
                }
                e
            })?;
            if job_id != "dry-run" {
                display_verification_job_id(&job_id);

                // If --watch flag is enabled, poll for verification result
                if args.watch {
                    let status = check(&public, &job_id).map_err(|e| {
                        if let CliError::Api(ApiClientError::Verify(ref verification_error)) = e {
                            eprintln!("\nSuggestions:");
                            for suggestion in verification_error.suggestions() {
                                eprintln!("{suggestion}");
                            }
                        } else if let CliError::Api(ApiClientError::Failure(ref _request_failure)) =
                            e
                        {
                            // RequestFailure errors already include suggestions in their display
                        }
                        e
                    })?;
                    info!("{status:?}");
                }
            }
        }
        Commands::Status(args) => {
            let public = ApiClient::new(args.network_url.public.clone())?;
            let status = check(&public, &args.job).map_err(|e| {
                if let CliError::Api(ApiClientError::Verify(ref verification_error)) = e {
                    eprintln!("\nSuggestions:");
                    for suggestion in verification_error.suggestions() {
                        eprintln!("{suggestion}");
                    }
                } else if let CliError::Api(ApiClientError::Failure(ref _request_failure)) = e {
                    // RequestFailure errors already include suggestions in their display
                }
                e
            })?;
            info!("{status:?}");
        }
    }
    Ok(())
}

fn submit(
    public: &ApiClient,
    _private: &ApiClient,
    args: &VerifyArgs,
    license_info: &license::LicenseInfo,
) -> Result<String, CliError> {
    let metadata = args.path.metadata();

    // Gather packages and sources
    let packages = gather_packages_and_validate(metadata, args)?;
    let sources = collect_source_files(metadata, &packages, args.test_files)?;

    // Prepare project structure
    let (file_infos, package_meta, contract_file, project_dir_path) =
        prepare_project_for_verification(args, metadata, &packages, sources)?;

    // Log verification info
    log_verification_info(args, metadata, &file_infos, &contract_file, license_info);

    // Execute verification unless dry run is requested
    if !args.dry_run {
        return execute_verification(
            public,
            args,
            file_infos,
            package_meta,
            contract_file,
            project_dir_path,
            license_info,
        );
    }

    info!("Dry run mode: collected files for verification but skipping submission due to --dry-run flag");
    Ok("dry-run".to_string())
}

fn gather_packages_and_validate(
    metadata: &scarb_metadata::Metadata,
    args: &VerifyArgs,
) -> Result<Vec<PackageMetadata>, CliError> {
    let mut packages: Vec<PackageMetadata> = vec![];
    resolver::gather_packages(metadata, &mut packages)?;

    // Filter packages based on --package argument
    let filtered_packages: Vec<&PackageMetadata> = if let Some(package_id) = &args.package {
        packages.iter().filter(|p| p.name == *package_id).collect()
    } else {
        packages.iter().collect()
    };

    // Validate package selection
    if filtered_packages.is_empty() {
        if let Some(package_name) = &args.package {
            let available_packages: Vec<String> = packages.iter().map(|p| p.name.clone()).collect();
            return Err(CliError::from(errors::MissingContract::new(
                package_name.clone(),
                available_packages,
            )));
        }
    }

    // Check workspace requirements
    let workspace_manifest = &metadata.workspace.manifest_path;
    let manifest_path = voyager::manifest_path(metadata);
    let is_workspace = workspace_manifest != manifest_path && metadata.workspace.members.len() > 1;

    if args.package.is_none() && is_workspace {
        let available_packages: Vec<String> = packages.iter().map(|p| p.name.clone()).collect();
        return Err(CliError::from(errors::MissingContract::new(
            "Workspace project detected - use --package argument".to_string(),
            available_packages,
        )));
    }

    Ok(packages)
}

fn collect_source_files(
    _metadata: &scarb_metadata::Metadata,
    packages: &[PackageMetadata],
    include_test_files: bool,
) -> Result<Vec<Utf8PathBuf>, CliError> {
    let mut sources: Vec<Utf8PathBuf> = vec![];
    for package in packages {
        let mut package_sources =
            resolver::package_sources_with_test_files(package, include_test_files)?;
        sources.append(&mut package_sources);
    }
    Ok(sources)
}

fn prepare_project_for_verification(
    args: &VerifyArgs,
    metadata: &scarb_metadata::Metadata,
    packages: &[PackageMetadata],
    sources: Vec<Utf8PathBuf>,
) -> Result<(Vec<FileInfo>, PackageMetadata, String, String), CliError> {
    let prefix = resolver::biggest_common_prefix(&sources, args.path.root_dir());

    // Build file map
    let files = build_file_map(&sources, &prefix, metadata, args)?;

    // Filter packages and get the target package
    let filtered_packages: Vec<&PackageMetadata> = if let Some(package_id) = &args.package {
        packages.iter().filter(|p| p.name == *package_id).collect()
    } else {
        packages.iter().collect()
    };

    let package_meta = filtered_packages
        .first()
        .ok_or_else(|| CliError::NoTarget)?;

    // Find contract file
    let contract_file_path = find_contract_file(package_meta, &sources)?;
    let contract_file =
        contract_file_path
            .strip_prefix(&prefix)
            .map_err(|_| CliError::StripPrefix {
                path: contract_file_path.clone(),
                prefix: prefix.clone(),
            })?;

    // Prepare project directory path
    let project_dir_path = prepare_project_dir_path(args, &prefix)?;

    // Convert to FileInfo
    let file_infos = convert_to_file_info(files);

    Ok((
        file_infos,
        (*package_meta).clone(),
        contract_file.to_string(),
        project_dir_path,
    ))
}

fn build_file_map(
    sources: &[Utf8PathBuf],
    prefix: &Utf8Path,
    metadata: &scarb_metadata::Metadata,
    args: &VerifyArgs,
) -> Result<HashMap<String, Utf8PathBuf>, CliError> {
    let mut files: HashMap<String, Utf8PathBuf> = sources
        .iter()
        .map(|p| -> Result<(String, Utf8PathBuf), CliError> {
            let name = p.strip_prefix(prefix).map_err(|_| CliError::StripPrefix {
                path: p.clone(),
                prefix: prefix.to_path_buf(),
            })?;
            Ok((name.to_string(), p.clone()))
        })
        .try_collect()?;

    // Add manifest files
    add_manifest_files(&mut files, metadata, prefix)?;

    // Add lock file if requested
    add_lock_file_if_requested(&mut files, args, prefix)?;

    // Validate file sizes
    validate_file_sizes(&files)?;

    Ok(files)
}

fn validate_file_sizes(files: &HashMap<String, Utf8PathBuf>) -> Result<(), CliError> {
    const MAX_FILE_SIZE: usize = 1024 * 1024 * 20; // 20MB limit

    for path in files.values() {
        // Validate file type
        validate_file_type(path)?;

        // Validate file size
        if let Ok(metadata) = std::fs::metadata(path) {
            let size = metadata.len() as usize;
            if size > MAX_FILE_SIZE {
                return Err(CliError::FileSizeLimit {
                    path: path.clone(),
                    max_size: MAX_FILE_SIZE,
                    actual_size: size,
                });
            }
        }
    }
    Ok(())
}

fn validate_file_type(path: &Utf8PathBuf) -> Result<(), CliError> {
    // Get file extension
    let extension = path.extension().unwrap_or("");

    // Define allowed file types
    let allowed_extensions = ["cairo", "toml", "lock", "md", "txt", "json", "rs"];

    // Define common project files without extensions
    let allowed_no_extension_files = [
        "LICENSE",
        "README",
        "CHANGELOG",
        "NOTICE",
        "AUTHORS",
        "CONTRIBUTORS",
    ];

    // Check if extension is allowed
    if !allowed_extensions.contains(&extension) {
        // If no extension, check if it's a common project file
        if extension.is_empty() {
            let file_name = path.file_name().unwrap_or("");
            if !allowed_no_extension_files.contains(&file_name) {
                return Err(CliError::InvalidFileType {
                    path: path.clone(),
                    extension: extension.to_string(),
                });
            }
        } else {
            return Err(CliError::InvalidFileType {
                path: path.clone(),
                extension: extension.to_string(),
            });
        }
    }

    Ok(())
}

fn add_manifest_files(
    files: &mut HashMap<String, Utf8PathBuf>,
    metadata: &scarb_metadata::Metadata,
    prefix: &Utf8Path,
) -> Result<(), CliError> {
    let manifest_path = voyager::manifest_path(metadata);
    let manifest = manifest_path
        .strip_prefix(prefix)
        .map_err(|_| CliError::StripPrefix {
            path: manifest_path.clone(),
            prefix: prefix.to_path_buf(),
        })?;

    files.insert(manifest.to_string(), manifest_path.clone());

    // Handle workspace manifests
    add_workspace_manifest_if_needed(files, metadata, prefix)?;

    Ok(())
}

fn add_workspace_manifest_if_needed(
    files: &mut HashMap<String, Utf8PathBuf>,
    metadata: &scarb_metadata::Metadata,
    prefix: &Utf8Path,
) -> Result<(), CliError> {
    let workspace_manifest = &metadata.workspace.manifest_path;
    let manifest_path = voyager::manifest_path(metadata);

    let is_workspace = workspace_manifest != manifest_path && metadata.workspace.members.len() > 1;

    if is_workspace {
        let workspace_manifest_rel =
            workspace_manifest
                .strip_prefix(prefix)
                .map_err(|_| CliError::StripPrefix {
                    path: workspace_manifest.clone(),
                    prefix: prefix.to_path_buf(),
                })?;
        debug!("Including workspace root manifest: {workspace_manifest}");
        files.insert(
            workspace_manifest_rel.to_string(),
            workspace_manifest.clone(),
        );
    }

    Ok(())
}

fn add_lock_file_if_requested(
    files: &mut HashMap<String, Utf8PathBuf>,
    args: &VerifyArgs,
    prefix: &Utf8Path,
) -> Result<(), CliError> {
    if args.lock_file {
        let lock_file_path = args.path.root_dir().join("Scarb.lock");
        if lock_file_path.exists() {
            let lock_file_rel =
                lock_file_path
                    .strip_prefix(prefix)
                    .map_err(|_| CliError::StripPrefix {
                        path: lock_file_path.clone(),
                        prefix: prefix.to_path_buf(),
                    })?;
            debug!("Including Scarb.lock file: {lock_file_path}");
            files.insert(lock_file_rel.to_string(), lock_file_path.clone());
        } else {
            warn!("--lock-file flag enabled but Scarb.lock not found at {lock_file_path}");
        }
    }
    Ok(())
}

fn find_contract_file(
    package_meta: &PackageMetadata,
    sources: &[Utf8PathBuf],
) -> Result<Utf8PathBuf, CliError> {
    // Find the main source file for the package (conventionally src/lib.cairo or src/main.cairo)
    let possible_main_paths = vec!["src/lib.cairo", "src/main.cairo"];

    for path in possible_main_paths {
        let full_path = package_meta.root.join(path);
        if full_path.exists() {
            return Ok(full_path);
        }
    }

    // If we can't find a main file, use the first source file in the package
    let contract_file_path = sources
        .iter()
        .filter(|path| path.starts_with(&package_meta.root))
        .find(|path| path.extension() == Some("cairo"))
        .cloned()
        .ok_or(CliError::NoTarget)?;

    Ok(contract_file_path)
}

fn prepare_project_dir_path(args: &VerifyArgs, prefix: &Utf8Path) -> Result<String, CliError> {
    let project_dir_path = args
        .path
        .root_dir()
        .strip_prefix(prefix)
        .map_err(|_| CliError::StripPrefix {
            path: args.path.root_dir().clone(),
            prefix: prefix.to_path_buf(),
        })
        // backend expects this for cwd
        .map(|p| {
            if p == Utf8Path::new("") {
                Utf8Path::new(".")
            } else {
                p
            }
        })?;

    Ok(project_dir_path.to_string())
}

fn convert_to_file_info(files: HashMap<String, Utf8PathBuf>) -> Vec<FileInfo> {
    files
        .into_iter()
        .map(|(name, path)| FileInfo {
            name,
            path: path.into_std_path_buf(),
        })
        .collect_vec()
}

fn log_verification_info(
    args: &VerifyArgs,
    metadata: &scarb_metadata::Metadata,
    file_infos: &[FileInfo],
    contract_file: &str,
    license_info: &license::LicenseInfo,
) {
    let cairo_version = &metadata.app_version_info.cairo.version;
    let scarb_version = &metadata.app_version_info.version;

    info!(
        "Verifying contract: {} from {}",
        args.contract_name, contract_file
    );
    info!("licensed with: {}", license_info.display_string());
    info!("using cairo: {cairo_version} and scarb {scarb_version}");
    info!("These are the files that will be used for verification:");
    for file_info in file_infos {
        info!("{}", file_info.path.display());
    }
}

fn execute_verification(
    public: &ApiClient,
    args: &VerifyArgs,
    file_infos: Vec<FileInfo>,
    package_meta: PackageMetadata,
    contract_file: String,
    project_dir_path: String,
    license_info: &license::LicenseInfo,
) -> Result<String, CliError> {
    let metadata = args.path.metadata();
    let cairo_version = metadata.app_version_info.cairo.version.clone();
    let scarb_version = metadata.app_version_info.version.clone();

    let project_meta = ProjectMetadataInfo {
        cairo_version,
        scarb_version,
        contract_file,
        project_dir_path,
        package_name: package_meta.name,
    };

    public
        .verify_class(
            &args.class_hash,
            Some(license_info.display_string().to_string()),
            &args.contract_name,
            project_meta,
            &file_infos,
        )
        .map_err(CliError::from)
}

fn format_timestamp(timestamp: f64) -> String {
    let duration = Duration::from_secs_f64(timestamp);
    if let Some(datetime) = UNIX_EPOCH.checked_add(duration) {
        let datetime: DateTime<Utc> = datetime.into();
        datetime.to_rfc3339()
    } else {
        timestamp.to_string()
    }
}

fn check(public: &ApiClient, job_id: &str) -> Result<VerificationJob, CliError> {
    let status = poll_verification_status(public, job_id).map_err(CliError::from)?;

    match status.status() {
        VerifyJobStatus::Success => {
            println!("\n✅ Verification successful!");
            if let Some(name) = status.name() {
                println!("Contract name: {name}");
            }
            if let Some(file) = status.contract_file() {
                println!("Contract file: {file}");
            }
            if let Some(version) = status.version() {
                println!("Version: {version}");
            }
            if let Some(license) = status.license() {
                println!("License: {license}");
            }
            if let Some(address) = status.address() {
                println!("Contract address: {address}");
            }
            println!("Class hash: {}", status.class_hash());
            if let Some(created) = status.created_timestamp() {
                println!("Created: {}", format_timestamp(created));
            }
            if let Some(updated) = status.updated_timestamp() {
                println!("Last updated: {}", format_timestamp(updated));
            }
            println!("\nThe contract is now verified and visible on Voyager at https://voyager.online/class/{} .", status.class_hash());
        }
        VerifyJobStatus::Fail => {
            println!("\n❌ Verification failed!");
            if let Some(desc) = status.status_description() {
                println!("Reason: {desc}");
            }
            if let Some(created) = status.created_timestamp() {
                println!("Started: {}", format_timestamp(created));
            }
            if let Some(updated) = status.updated_timestamp() {
                println!("Failed: {}", format_timestamp(updated));
            }
        }
        VerifyJobStatus::CompileFailed => {
            println!("\n❌ Compilation failed!");
            if let Some(desc) = status.status_description() {
                println!("Reason: {desc}");
            }
            if let Some(created) = status.created_timestamp() {
                println!("Started: {}", format_timestamp(created));
            }
            if let Some(updated) = status.updated_timestamp() {
                println!("Failed: {}", format_timestamp(updated));
            }
        }
        VerifyJobStatus::Processing => {
            println!("\n⏳ Contract verification is being processed...");
            println!("Job ID: {}", status.job_id());
            println!("Status: Processing");
            if let Some(created) = status.created_timestamp() {
                println!("Started: {}", format_timestamp(created));
            }
            if let Some(updated) = status.updated_timestamp() {
                println!("Last updated: {}", format_timestamp(updated));
            }
            println!("\nUse the same command to check progress later.");
        }
        VerifyJobStatus::Submitted => {
            println!("\n⏳ Verification job submitted and waiting for processing...");
            println!("Job ID: {}", status.job_id());
            println!("Status: Submitted");
            if let Some(created) = status.created_timestamp() {
                println!("Submitted: {}", format_timestamp(created));
            }
            println!("\nUse the same command to check progress later.");
        }
        VerifyJobStatus::Compiled => {
            println!("\n⏳ Contract compiled successfully, verification in progress...");
            println!("Job ID: {}", status.job_id());
            println!("Status: Compiled");
            if let Some(created) = status.created_timestamp() {
                println!("Started: {}", format_timestamp(created));
            }
            if let Some(updated) = status.updated_timestamp() {
                println!("Last updated: {}", format_timestamp(updated));
            }
            println!("\nUse the same command to check progress later.");
        }
        _ => {
            println!("\n⏳ Verification in progress...");
            println!("Job ID: {}", status.job_id());
            println!("Status: {}", status.status());
            if let Some(created) = status.created_timestamp() {
                println!("Started: {}", format_timestamp(created));
            }
            if let Some(updated) = status.updated_timestamp() {
                println!("Last updated: {}", format_timestamp(updated));
            }
            println!("\nUse the same command to check progress later.");
        }
    }

    Ok(status)
}