@@ -8,6 +8,8 @@ use std::path::{Path, PathBuf};
88
99use crate :: {
1010 backends,
11+ commands:: common,
12+ config:: Config ,
1113 util:: { self , Flavour , move_generated_project} ,
1214} ;
1315
@@ -17,6 +19,7 @@ use crate::{
1719/// that can be used for on-chain proof verification on Starknet.
1820///
1921/// # Arguments
22+ /// * `cfg` - Configuration containing runner and flags
2023/// * `proof_path` - Path to the proof file
2124/// * `vk_path` - Path to the verification key file
2225/// * `public_inputs_path` - Path to the public inputs file
@@ -25,6 +28,7 @@ use crate::{
2528/// # Returns
2629/// * `Result<PathBuf>` - Path to generated calldata file or error
2730pub fn generate_calldata (
31+ _cfg : & Config ,
2832 proof_path : & Path ,
2933 vk_path : & Path ,
3034 public_inputs_path : & Path ,
@@ -46,6 +50,8 @@ pub fn generate_calldata(
4650 & public_inputs_str,
4751 ] ;
4852
53+ // TODO: Extend runner interface to capture stdout for calldata generation
54+ // For now, fall back to direct backend call
4955 let ( stdout, _stderr) = backends:: garaga:: run_with_output ( & garaga_args) ?;
5056
5157 // Determine output path
@@ -64,14 +70,17 @@ pub fn generate_calldata(
6470/// Convenience function that uses the standard Starknet artifact locations
6571/// to generate calldata JSON.
6672///
73+ /// # Arguments
74+ /// * `cfg` - Configuration containing runner and flags
75+ ///
6776/// # Returns
6877/// * `Result<PathBuf>` - Path to generated calldata file or error
69- pub fn generate_calldata_from_starknet_artifacts ( ) -> Result < PathBuf > {
78+ pub fn generate_calldata_from_starknet_artifacts ( cfg : & Config ) -> Result < PathBuf > {
7079 let proof_path = util:: get_proof_path ( Flavour :: Starknet ) ;
7180 let vk_path = util:: get_vk_path ( Flavour :: Starknet ) ;
7281 let public_inputs_path = util:: get_public_inputs_path ( Flavour :: Starknet ) ;
7382
74- generate_calldata ( & proof_path, & vk_path, & public_inputs_path, None )
83+ generate_calldata ( cfg , & proof_path, & vk_path, & public_inputs_path, None )
7584}
7685
7786/// Generate Cairo verifier contract using Garaga
@@ -80,12 +89,17 @@ pub fn generate_calldata_from_starknet_artifacts() -> Result<PathBuf> {
8089/// on Starknet using the provided verification key.
8190///
8291/// # Arguments
92+ /// * `cfg` - Configuration containing runner and flags
8393/// * `vk_path` - Path to the verification key file
8494/// * `output_dir` - Optional output directory (defaults to ./contracts/cairo/)
8595///
8696/// # Returns
8797/// * `Result<()>` - Success or error from Garaga execution
88- pub fn generate_cairo_contract ( vk_path : & Path , output_dir : Option < & str > ) -> Result < ( ) > {
98+ pub fn generate_cairo_contract (
99+ cfg : & Config ,
100+ vk_path : & Path ,
101+ output_dir : Option < & str > ,
102+ ) -> Result < ( ) > {
89103 let output = output_dir. unwrap_or ( "./contracts/cairo/" ) ;
90104
91105 let vk_str = vk_path. to_string_lossy ( ) ;
@@ -100,22 +114,29 @@ pub fn generate_cairo_contract(vk_path: &Path, output_dir: Option<&str>) -> Resu
100114 "cairo_verifier" ,
101115 ] ;
102116
103- backends :: garaga :: run ( & garaga_args) ?;
117+ common :: run_garaga_command ( cfg , & garaga_args) ?;
104118
105- // Move the generated project to the correct location
106- move_generated_project ( "cairo_verifier" , output)
119+ // Move the generated project to the correct location (skip in dry-run mode)
120+ if cfg. dry_run {
121+ Ok ( ( ) )
122+ } else {
123+ move_generated_project ( "cairo_verifier" , output)
124+ }
107125}
108126
109127/// Generate Cairo verifier contract using default Starknet VK path
110128///
111129/// Convenience function that uses the standard Starknet VK location
112130/// to generate a Cairo verifier contract.
113131///
132+ /// # Arguments
133+ /// * `cfg` - Configuration containing runner and flags
134+ ///
114135/// # Returns
115136/// * `Result<()>` - Success or error from Garaga execution
116- pub fn generate_cairo_contract_from_starknet_vk ( ) -> Result < ( ) > {
137+ pub fn generate_cairo_contract_from_starknet_vk ( cfg : & Config ) -> Result < ( ) > {
117138 let vk_path = util:: get_vk_path ( Flavour :: Starknet ) ;
118- generate_cairo_contract ( & vk_path, None )
139+ generate_cairo_contract ( cfg , & vk_path, None )
119140}
120141
121142/// Validate that required Starknet artifacts exist for Garaga operations
0 commit comments