@@ -10,6 +10,7 @@ pub mod test;
1010
1111pub const STARKNET_COMPILE_DEPRECATED : & str = "starknet-compile-deprecated" ;
1212pub const CAIRO0_COMPILE : & str = "cairo-compile" ;
13+ pub const CAIRO0_FORMAT : & str = "cairo-format" ;
1314pub const EXPECTED_CAIRO0_VERSION : & str = "0.14.0a1" ;
1415
1516/// The local python requirements used to determine the cairo0 compiler version.
@@ -27,26 +28,26 @@ pip install -r {:#?}"#,
2728} ) ;
2829
2930#[ derive( thiserror:: Error , Debug ) ]
30- pub enum Cairo0CompilerVersionError {
31+ pub enum Cairo0ScriptVersionError {
3132 #[ error(
32- "{compiler } version is not correct: required {required}, got {existing}. Are you in the \
33+ "{script } version is not correct: required {required}, got {existing}. Are you in the \
3334 venv? If not, run the following commands:\n {}", * ENTER_VENV_INSTRUCTIONS
3435 ) ]
35- IncorrectVersion { compiler : String , existing : String , required : String } ,
36+ IncorrectVersion { script : String , existing : String , required : String } ,
3637 #[ error(
3738 "{0}. Are you in the venv? If not, run the following commands:\n {}" ,
3839 * ENTER_VENV_INSTRUCTIONS
3940 ) ]
4041 NotFound ( String ) ,
4142}
4243
43- pub fn cairo0_compilers_correct_version ( ) -> Result < ( ) , Cairo0CompilerVersionError > {
44- for compiler in [ CAIRO0_COMPILE , STARKNET_COMPILE_DEPRECATED ] {
45- let version = match Command :: new ( compiler ) . arg ( "--version" ) . output ( ) {
44+ pub fn cairo0_scripts_correct_version ( ) -> Result < ( ) , Cairo0ScriptVersionError > {
45+ for script in [ CAIRO0_COMPILE , CAIRO0_FORMAT , STARKNET_COMPILE_DEPRECATED ] {
46+ let version = match Command :: new ( script ) . arg ( "--version" ) . output ( ) {
4647 Ok ( output) => String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ,
4748 Err ( error) => {
48- return Err ( Cairo0CompilerVersionError :: NotFound ( format ! (
49- "Failed to get {compiler } version: {error}."
49+ return Err ( Cairo0ScriptVersionError :: NotFound ( format ! (
50+ "Failed to get {script } version: {error}."
5051 ) ) ) ;
5152 }
5253 } ;
@@ -55,11 +56,11 @@ pub fn cairo0_compilers_correct_version() -> Result<(), Cairo0CompilerVersionErr
5556 . replace ( "==" , " " )
5657 . split ( " " )
5758 . nth ( 1 )
58- . ok_or ( Cairo0CompilerVersionError :: NotFound ( "No compiler version found." . to_string ( ) ) ) ?
59+ . ok_or ( Cairo0ScriptVersionError :: NotFound ( "No script version found." . to_string ( ) ) ) ?
5960 != EXPECTED_CAIRO0_VERSION
6061 {
61- return Err ( Cairo0CompilerVersionError :: IncorrectVersion {
62- compiler : compiler . to_string ( ) ,
62+ return Err ( Cairo0ScriptVersionError :: IncorrectVersion {
63+ script : script . to_string ( ) ,
6364 existing : version,
6465 required : EXPECTED_CAIRO0_VERSION . to_string ( ) ,
6566 } ) ;
@@ -71,15 +72,15 @@ pub fn cairo0_compilers_correct_version() -> Result<(), Cairo0CompilerVersionErr
7172
7273/// Verifies that the required Cairo0 compiler is available; panics if unavailable.
7374/// For use in tests only. If cairo0 compiler verification is required in business logic, use
74- /// `crate::cairo0_compiler::cairo0_compilers_correct_version ` instead.
75+ /// `crate::cairo0_compiler::cairo0_scripts_correct_version ` instead.
7576#[ cfg( any( test, feature = "testing" ) ) ]
7677pub fn verify_cairo0_compiler_deps ( ) {
77- let specific_error = match cairo0_compilers_correct_version ( ) {
78+ let specific_error = match cairo0_scripts_correct_version ( ) {
7879 Ok ( _) => {
7980 return ;
8081 }
81- Err ( Cairo0CompilerVersionError :: NotFound ( _) ) => "no installed cairo-lang found" . to_string ( ) ,
82- Err ( Cairo0CompilerVersionError :: IncorrectVersion { existing, .. } ) => {
82+ Err ( Cairo0ScriptVersionError :: NotFound ( _) ) => "no installed cairo-lang found" . to_string ( ) ,
83+ Err ( Cairo0ScriptVersionError :: IncorrectVersion { existing, .. } ) => {
8384 format ! ( "installed version: {existing}" )
8485 }
8586 } ;
0 commit comments