55
66use color_eyre:: Result ;
77
8- use crate :: backends;
8+ use crate :: { backends, commands :: common , config :: Config } ;
99
1010/// Initialize a new Foundry project
1111///
1212/// This function creates a new Foundry project structure with the necessary
1313/// configuration files and directories.
1414///
1515/// # Arguments
16+ /// * `cfg` - Configuration containing runner and flags
1617/// * `project_path` - Path where the Foundry project should be created
1718///
1819/// # Returns
1920/// * `Result<()>` - Success or error from Foundry initialization
20- pub fn init_foundry_project ( project_path : & str ) -> Result < ( ) > {
21- backends :: foundry :: run_forge ( & [ "init" , "--force" , project_path] )
21+ pub fn init_foundry_project ( cfg : & Config , project_path : & str ) -> Result < ( ) > {
22+ common :: run_foundry_command ( cfg , "forge" , & [ "init" , "--force" , project_path] )
2223}
2324
2425/// Initialize Foundry project at the default EVM contracts location
2526///
2627/// Convenience function that initializes a Foundry project at the standard
2728/// location used by the Bargo workflow.
2829///
30+ /// # Arguments
31+ /// * `cfg` - Configuration containing runner and flags
32+ ///
2933/// # Returns
3034/// * `Result<()>` - Success or error from initialization
31- pub fn init_default_foundry_project ( ) -> Result < ( ) > {
32- init_foundry_project ( "contracts/evm" )
35+ pub fn init_default_foundry_project ( cfg : & Config ) -> Result < ( ) > {
36+ init_foundry_project ( cfg , "contracts/evm" )
3337}
3438
3539/// Deploy a contract using Foundry
3640///
3741/// This function deploys a contract to an EVM network using forge create.
3842///
3943/// # Arguments
44+ /// * `cfg` - Configuration containing runner and flags
4045/// * `contract_path` - Path to the contract source file
4146/// * `contract_name` - Name of the contract to deploy
4247/// * `rpc_url` - RPC URL for the target network
@@ -46,6 +51,7 @@ pub fn init_default_foundry_project() -> Result<()> {
4651/// # Returns
4752/// * `Result<String>` - Contract address or error
4853pub fn deploy_contract (
54+ _cfg : & Config ,
4955 contract_path : & str ,
5056 _contract_name : & str ,
5157 rpc_url : & str ,
@@ -66,6 +72,8 @@ pub fn deploy_contract(
6672 args. extend ( constructor_args) ;
6773 }
6874
75+ // TODO: Extend runner interface to capture stdout for contract address parsing
76+ // For now, fall back to direct backend call
6977 let ( stdout, _stderr) = backends:: foundry:: run_forge_with_output ( & args) ?;
7078
7179 // Parse contract address from forge output
@@ -89,13 +97,15 @@ pub fn deploy_contract(
8997/// standard EVM contracts directory.
9098///
9199/// # Arguments
100+ /// * `cfg` - Configuration containing runner and flags
92101/// * `rpc_url` - RPC URL for the target network
93102/// * `private_key` - Private key for deployment
94103///
95104/// # Returns
96105/// * `Result<String>` - Contract address or error
97- pub fn deploy_verifier_contract ( rpc_url : & str , private_key : & str ) -> Result < String > {
106+ pub fn deploy_verifier_contract ( cfg : & Config , rpc_url : & str , private_key : & str ) -> Result < String > {
98107 deploy_contract (
108+ cfg,
99109 "contracts/evm/src/Verifier.sol:Verifier" ,
100110 "Verifier" ,
101111 rpc_url,
0 commit comments