@@ -133,36 +133,6 @@ pub fn cairo1_compile(
133133 cargo_nightly_arg : Option < String > ,
134134) -> CompilationArtifacts {
135135 let mut base_compile_args = vec ! [ ] ;
136-
137- let sierra_output =
138- starknet_compile ( path, git_tag_override, cargo_nightly_arg, & mut base_compile_args) ;
139-
140- let mut temp_file = NamedTempFile :: new ( ) . unwrap ( ) ;
141- temp_file. write_all ( & sierra_output) . unwrap ( ) ;
142- let temp_path_str = temp_file. into_temp_path ( ) ;
143-
144- // Sierra -> CASM.
145- let mut sierra_compile_command = Command :: new ( "cargo" ) ;
146- sierra_compile_command. args ( base_compile_args) ;
147- sierra_compile_command. args ( [
148- "starknet-sierra-compile" ,
149- temp_path_str. to_str ( ) . unwrap ( ) ,
150- "--allowed-libfuncs-list-name" ,
151- "all" ,
152- ] ) ;
153- let casm_output = run_and_verify_output ( & mut sierra_compile_command) ;
154-
155- CompilationArtifacts :: Cairo1 { casm : casm_output. stdout , sierra : sierra_output }
156- }
157-
158- /// Compile Cairo1 Contract into their Sierra version using the compiler version set in the
159- /// Cargo.toml
160- pub fn starknet_compile (
161- path : String ,
162- git_tag_override : Option < String > ,
163- cargo_nightly_arg : Option < String > ,
164- base_compile_args : & mut Vec < String > ,
165- ) -> Vec < u8 > {
166136 verify_cairo1_compiler_deps ( git_tag_override) ;
167137
168138 let cairo1_compiler_path = local_cairo1_compiler_repo_path ( ) ;
@@ -178,9 +148,27 @@ pub fn starknet_compile(
178148 base_compile_args. insert ( 0 , format ! ( "+nightly-{nightly_version}" ) ) ;
179149 }
180150
151+ let sierra_output = starknet_compile ( path, & mut base_compile_args) ;
152+
153+ let mut temp_file = NamedTempFile :: new ( ) . unwrap ( ) ;
154+ temp_file. write_all ( & sierra_output) . unwrap ( ) ;
155+ let temp_path_str = temp_file. into_temp_path ( ) ;
156+
157+ // Sierra -> CASM.
158+ let casm_output = starknet_sierra_compile (
159+ temp_path_str. to_str ( ) . unwrap ( ) . to_string ( ) ,
160+ & mut base_compile_args,
161+ ) ;
162+
163+ CompilationArtifacts :: Cairo1 { casm : casm_output, sierra : sierra_output }
164+ }
165+
166+ /// Compile Cairo1 Contract into their Sierra version using the compiler version set in the
167+ /// Cargo.toml
168+ pub fn starknet_compile ( path : String , base_compile_args : & mut [ String ] ) -> Vec < u8 > {
181169 // Cairo -> Sierra.
182170 let mut starknet_compile_commmand = Command :: new ( "cargo" ) ;
183- starknet_compile_commmand. args ( base_compile_args. clone ( ) ) ;
171+ starknet_compile_commmand. args ( base_compile_args. to_owned ( ) ) ;
184172 starknet_compile_commmand. args ( [
185173 "starknet-compile" ,
186174 "--" ,
@@ -194,6 +182,20 @@ pub fn starknet_compile(
194182 sierra_output. stdout
195183}
196184
185+ /// Compile Sierra code into CASM.
186+ fn starknet_sierra_compile ( path : String , base_compile_args : & mut Vec < String > ) -> Vec < u8 > {
187+ let mut sierra_compile_command = Command :: new ( "cargo" ) ;
188+ sierra_compile_command. args ( base_compile_args) ;
189+ sierra_compile_command. args ( [
190+ "starknet-sierra-compile" ,
191+ path. as_str ( ) ,
192+ "--allowed-libfuncs-list-name" ,
193+ "all" ,
194+ ] ) ;
195+ let casm_output = run_and_verify_output ( & mut sierra_compile_command) ;
196+ casm_output. stdout
197+ }
198+
197199/// Verifies that the required dependencies are available before compiling; panics if unavailable.
198200fn verify_cairo0_compiler_deps ( ) {
199201 // Python compiler. Verify correct version.
0 commit comments