@@ -13,6 +13,7 @@ pub mod test;
1313
1414pub const STARKNET_COMPILE_DEPRECATED : & str = "starknet-compile-deprecated" ;
1515pub const CAIRO0_COMPILE : & str = "cairo-compile" ;
16+ pub const CAIRO0_FORMAT : & str = "cairo-format" ;
1617pub const EXPECTED_CAIRO0_VERSION : & str = "0.14.0a1" ;
1718
1819/// The local python requirements used to determine the cairo0 compiler version.
@@ -21,20 +22,20 @@ pub(crate) static PIP_REQUIREMENTS_FILE: LazyLock<PathBuf> =
2122 LazyLock :: new ( || resolve_project_relative_path ( "scripts/requirements.txt" ) . unwrap ( ) ) ;
2223
2324#[ derive( thiserror:: Error , Debug ) ]
24- pub enum Cairo0CompilerVersionError {
25- #[ error( "{compiler } version is not correct: required {required}, got {existing}." ) ]
26- IncorrectVersion { compiler : String , existing : String , required : String } ,
25+ pub enum Cairo0ScriptVersionError {
26+ #[ error( "{script } version is not correct: required {required}, got {existing}." ) ]
27+ IncorrectVersion { script : String , existing : String , required : String } ,
2728 #[ error( "{0} not found." ) ]
2829 NotFound ( String ) ,
2930}
3031
31- pub fn cairo0_compilers_correct_version ( ) -> Result < ( ) , Cairo0CompilerVersionError > {
32- for compiler in [ CAIRO0_COMPILE , STARKNET_COMPILE_DEPRECATED ] {
33- let version = match Command :: new ( compiler ) . arg ( "--version" ) . output ( ) {
32+ pub fn cairo0_scripts_correct_version ( ) -> Result < ( ) , Cairo0ScriptVersionError > {
33+ for script in [ CAIRO0_COMPILE , CAIRO0_FORMAT , STARKNET_COMPILE_DEPRECATED ] {
34+ let version = match Command :: new ( script ) . arg ( "--version" ) . output ( ) {
3435 Ok ( output) => String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ,
3536 Err ( error) => {
36- return Err ( Cairo0CompilerVersionError :: NotFound ( format ! (
37- "Failed to get {compiler } version: {error}."
37+ return Err ( Cairo0ScriptVersionError :: NotFound ( format ! (
38+ "Failed to get {script } version: {error}."
3839 ) ) ) ;
3940 }
4041 } ;
@@ -43,11 +44,11 @@ pub fn cairo0_compilers_correct_version() -> Result<(), Cairo0CompilerVersionErr
4344 . replace ( "==" , " " )
4445 . split ( " " )
4546 . nth ( 1 )
46- . ok_or ( Cairo0CompilerVersionError :: NotFound ( "No compiler version found." . to_string ( ) ) ) ?
47+ . ok_or ( Cairo0ScriptVersionError :: NotFound ( "No script version found." . to_string ( ) ) ) ?
4748 != EXPECTED_CAIRO0_VERSION
4849 {
49- return Err ( Cairo0CompilerVersionError :: IncorrectVersion {
50- compiler : compiler . to_string ( ) ,
50+ return Err ( Cairo0ScriptVersionError :: IncorrectVersion {
51+ script : script . to_string ( ) ,
5152 existing : version,
5253 required : EXPECTED_CAIRO0_VERSION . to_string ( ) ,
5354 } ) ;
@@ -59,15 +60,15 @@ pub fn cairo0_compilers_correct_version() -> Result<(), Cairo0CompilerVersionErr
5960
6061/// Verifies that the required Cairo0 compiler is available; panics if unavailable.
6162/// For use in tests only. If cairo0 compiler verification is required in business logic, use
62- /// `crate::cairo0_compiler::cairo0_compilers_correct_version ` instead.
63+ /// `crate::cairo0_compiler::cairo0_scripts_correct_version ` instead.
6364#[ cfg( any( test, feature = "testing" ) ) ]
6465pub fn verify_cairo0_compiler_deps ( ) {
65- let specific_error = match cairo0_compilers_correct_version ( ) {
66+ let specific_error = match cairo0_scripts_correct_version ( ) {
6667 Ok ( _) => {
6768 return ;
6869 }
69- Err ( Cairo0CompilerVersionError :: NotFound ( _) ) => "no installed cairo-lang found" . to_string ( ) ,
70- Err ( Cairo0CompilerVersionError :: IncorrectVersion { existing, .. } ) => {
70+ Err ( Cairo0ScriptVersionError :: NotFound ( _) ) => "no installed cairo-lang found" . to_string ( ) ,
71+ Err ( Cairo0ScriptVersionError :: IncorrectVersion { existing, .. } ) => {
7172 format ! ( "installed version: {existing}" )
7273 }
7374 } ;
0 commit comments