@@ -130,36 +130,6 @@ pub fn cairo1_compile(
130130 cargo_nightly_arg : Option < String > ,
131131) -> CompilationArtifacts {
132132 let mut base_compile_args = vec ! [ ] ;
133-
134- let sierra_output =
135- starknet_compile ( path, git_tag_override, cargo_nightly_arg, & mut base_compile_args) ;
136-
137- let mut temp_file = NamedTempFile :: new ( ) . unwrap ( ) ;
138- temp_file. write_all ( & sierra_output) . unwrap ( ) ;
139- let temp_path_str = temp_file. into_temp_path ( ) ;
140-
141- // Sierra -> CASM.
142- let mut sierra_compile_command = Command :: new ( "cargo" ) ;
143- sierra_compile_command. args ( base_compile_args) ;
144- sierra_compile_command. args ( [
145- "starknet-sierra-compile" ,
146- temp_path_str. to_str ( ) . unwrap ( ) ,
147- "--allowed-libfuncs-list-name" ,
148- "all" ,
149- ] ) ;
150- let casm_output = run_and_verify_output ( & mut sierra_compile_command) ;
151-
152- CompilationArtifacts :: Cairo1 { casm : casm_output. stdout , sierra : sierra_output }
153- }
154-
155- /// Compile Cairo1 Contract into their Sierra version using the compiler version set in the
156- /// Cargo.toml
157- pub fn starknet_compile (
158- path : String ,
159- git_tag_override : Option < String > ,
160- cargo_nightly_arg : Option < String > ,
161- base_compile_args : & mut Vec < String > ,
162- ) -> Vec < u8 > {
163133 verify_cairo1_compiler_deps ( git_tag_override) ;
164134
165135 let cairo1_compiler_path = local_cairo1_compiler_repo_path ( ) ;
@@ -175,9 +145,27 @@ pub fn starknet_compile(
175145 base_compile_args. insert ( 0 , format ! ( "+nightly-{nightly_version}" ) ) ;
176146 }
177147
148+ let sierra_output = starknet_compile ( path, & mut base_compile_args) ;
149+
150+ let mut temp_file = NamedTempFile :: new ( ) . unwrap ( ) ;
151+ temp_file. write_all ( & sierra_output) . unwrap ( ) ;
152+ let temp_path_str = temp_file. into_temp_path ( ) ;
153+
154+ // Sierra -> CASM.
155+ let casm_output = starknet_sierra_compile (
156+ temp_path_str. to_str ( ) . unwrap ( ) . to_string ( ) ,
157+ & mut base_compile_args,
158+ ) ;
159+
160+ CompilationArtifacts :: Cairo1 { casm : casm_output, sierra : sierra_output }
161+ }
162+
163+ /// Compile Cairo1 Contract into their Sierra version using the compiler version set in the
164+ /// Cargo.toml
165+ pub fn starknet_compile ( path : String , base_compile_args : & mut [ String ] ) -> Vec < u8 > {
178166 // Cairo -> Sierra.
179167 let mut starknet_compile_commmand = Command :: new ( "cargo" ) ;
180- starknet_compile_commmand. args ( base_compile_args. clone ( ) ) ;
168+ starknet_compile_commmand. args ( base_compile_args. to_owned ( ) ) ;
181169 starknet_compile_commmand. args ( [
182170 "starknet-compile" ,
183171 "--" ,
@@ -191,6 +179,20 @@ pub fn starknet_compile(
191179 sierra_output. stdout
192180}
193181
182+ /// Compile Sierra code into CASM.
183+ fn starknet_sierra_compile ( path : String , base_compile_args : & mut Vec < String > ) -> Vec < u8 > {
184+ let mut sierra_compile_command = Command :: new ( "cargo" ) ;
185+ sierra_compile_command. args ( base_compile_args) ;
186+ sierra_compile_command. args ( [
187+ "starknet-sierra-compile" ,
188+ & path,
189+ "--allowed-libfuncs-list-name" ,
190+ "all" ,
191+ ] ) ;
192+ let casm_output = run_and_verify_output ( & mut sierra_compile_command) ;
193+ casm_output. stdout
194+ }
195+
194196/// Verifies that the required dependencies are available before compiling; panics if unavailable.
195197fn verify_cairo0_compiler_deps ( ) {
196198 // Python compiler. Verify correct version.
0 commit comments