@@ -124,36 +124,6 @@ pub fn cairo1_compile(
124124 cargo_nightly_arg : Option < String > ,
125125) -> CompilationArtifacts {
126126 let mut base_compile_args = vec ! [ ] ;
127-
128- let sierra_output =
129- starknet_compile ( path, git_tag_override, cargo_nightly_arg, & mut base_compile_args) ;
130-
131- let mut temp_file = NamedTempFile :: new ( ) . unwrap ( ) ;
132- temp_file. write_all ( & sierra_output) . unwrap ( ) ;
133- let temp_path_str = temp_file. into_temp_path ( ) ;
134-
135- // Sierra -> CASM.
136- let mut sierra_compile_command = Command :: new ( "cargo" ) ;
137- sierra_compile_command. args ( base_compile_args) ;
138- sierra_compile_command. args ( [
139- "starknet-sierra-compile" ,
140- temp_path_str. to_str ( ) . unwrap ( ) ,
141- "--allowed-libfuncs-list-name" ,
142- "all" ,
143- ] ) ;
144- let casm_output = run_and_verify_output ( & mut sierra_compile_command) ;
145-
146- CompilationArtifacts :: Cairo1 { casm : casm_output. stdout , sierra : sierra_output }
147- }
148-
149- /// Compile Cairo1 Contract into their Sierra version using the compiler version set in the
150- /// Cargo.toml
151- pub fn starknet_compile (
152- path : String ,
153- git_tag_override : Option < String > ,
154- cargo_nightly_arg : Option < String > ,
155- base_compile_args : & mut Vec < String > ,
156- ) -> Vec < u8 > {
157127 verify_cairo1_compiler_deps ( git_tag_override) ;
158128
159129 let cairo1_compiler_path = local_cairo1_compiler_repo_path ( ) ;
@@ -169,9 +139,27 @@ pub fn starknet_compile(
169139 base_compile_args. insert ( 0 , format ! ( "+nightly-{nightly_version}" ) ) ;
170140 }
171141
142+ let sierra_output = starknet_compile ( path, & mut base_compile_args) ;
143+
144+ let mut temp_file = NamedTempFile :: new ( ) . unwrap ( ) ;
145+ temp_file. write_all ( & sierra_output) . unwrap ( ) ;
146+ let temp_path_str = temp_file. into_temp_path ( ) ;
147+
148+ // Sierra -> CASM.
149+ let casm_output = starknet_sierra_compile (
150+ temp_path_str. to_str ( ) . unwrap ( ) . to_string ( ) ,
151+ & mut base_compile_args,
152+ ) ;
153+
154+ CompilationArtifacts :: Cairo1 { casm : casm_output, sierra : sierra_output }
155+ }
156+
157+ /// Compile Cairo1 Contract into their Sierra version using the compiler version set in the
158+ /// Cargo.toml
159+ pub fn starknet_compile ( path : String , base_compile_args : & mut [ String ] ) -> Vec < u8 > {
172160 // Cairo -> Sierra.
173161 let mut starknet_compile_commmand = Command :: new ( "cargo" ) ;
174- starknet_compile_commmand. args ( base_compile_args. clone ( ) ) ;
162+ starknet_compile_commmand. args ( base_compile_args. to_owned ( ) ) ;
175163 starknet_compile_commmand. args ( [
176164 "starknet-compile" ,
177165 "--" ,
@@ -185,6 +173,20 @@ pub fn starknet_compile(
185173 sierra_output. stdout
186174}
187175
176+ /// Compile Sierra code into CASM.
177+ fn starknet_sierra_compile ( path : String , base_compile_args : & mut Vec < String > ) -> Vec < u8 > {
178+ let mut sierra_compile_command = Command :: new ( "cargo" ) ;
179+ sierra_compile_command. args ( base_compile_args) ;
180+ sierra_compile_command. args ( [
181+ "starknet-sierra-compile" ,
182+ & path,
183+ "--allowed-libfuncs-list-name" ,
184+ "all" ,
185+ ] ) ;
186+ let casm_output = run_and_verify_output ( & mut sierra_compile_command) ;
187+ casm_output. stdout
188+ }
189+
188190/// Verifies that the required dependencies are available before compiling; panics if unavailable.
189191fn verify_cairo0_compiler_deps ( ) {
190192 // Python compiler. Verify correct version.
0 commit comments