@@ -11,13 +11,13 @@ use execution::process_transaction;
11
11
use serde:: Deserialize ;
12
12
use serde_json:: json;
13
13
use std:: {
14
- ffi:: { c_char, c_longlong, c_uchar, c_ulonglong, c_void, CStr , CString } ,
15
- slice,
16
- sync:: Arc ,
17
14
collections:: BTreeMap ,
15
+ ffi:: { c_char, c_longlong, c_uchar, c_ulonglong, c_void, CStr , CString } ,
18
16
fs:: File ,
19
17
io:: Read ,
20
18
path:: Path ,
19
+ slice,
20
+ sync:: Arc ,
21
21
} ;
22
22
23
23
use anyhow:: Result ;
@@ -67,8 +67,8 @@ use starknet_api::{
67
67
use starknet_types_core:: felt:: Felt ;
68
68
use std:: str:: FromStr ;
69
69
type StarkFelt = Felt ;
70
- use once_cell:: sync:: Lazy ;
71
70
use anyhow:: Context ;
71
+ use once_cell:: sync:: Lazy ;
72
72
73
73
// Allow users to call CONSTRUCTOR entry point type which has fixed entry_point_felt "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194"
74
74
pub static CONSTRUCTOR_ENTRY_POINT_FELT : Lazy < StarkFelt > = Lazy :: new ( || {
@@ -707,11 +707,14 @@ fn build_block_context(
707
707
708
708
#[ allow( static_mut_refs) ]
709
709
fn get_versioned_constants ( version : * const c_char ) -> VersionedConstants {
710
- let starknet_version = unsafe { CStr :: from_ptr ( version) } . to_str ( )
710
+ let starknet_version = unsafe { CStr :: from_ptr ( version) }
711
+ . to_str ( )
711
712
. ok ( )
712
713
. and_then ( |version_str| StarknetVersion :: try_from ( version_str) . ok ( ) ) ;
713
714
714
- if let ( Some ( custom_constants) , Some ( version) ) = ( unsafe { & CUSTOM_VERSIONED_CONSTANTS } , starknet_version) {
715
+ if let ( Some ( custom_constants) , Some ( version) ) =
716
+ ( unsafe { & CUSTOM_VERSIONED_CONSTANTS } , starknet_version)
717
+ {
715
718
if let Some ( constants) = custom_constants. 0 . get ( & version) {
716
719
return constants. clone ( ) ;
717
720
}
@@ -731,15 +734,18 @@ impl VersionedConstantsMap {
731
734
let mut result = BTreeMap :: new ( ) ;
732
735
733
736
for ( version, path) in version_with_path {
734
- let mut file = File :: open ( Path :: new ( & path) ) . with_context ( || format ! ( "Failed to open file: {}" , path) ) ?;
737
+ let mut file = File :: open ( Path :: new ( & path) )
738
+ . with_context ( || format ! ( "Failed to open file: {}" , path) ) ?;
735
739
736
740
let mut contents = String :: new ( ) ;
737
- file. read_to_string ( & mut contents) . with_context ( || format ! ( "Failed to read contents of file: {}" , path) ) ?;
741
+ file. read_to_string ( & mut contents)
742
+ . with_context ( || format ! ( "Failed to read contents of file: {}" , path) ) ?;
738
743
739
- let constants: VersionedConstants =
740
- serde_json :: from_str ( & contents ) . with_context ( || format ! ( "Failed to parse JSON in file: {}" , path) ) ?;
744
+ let constants: VersionedConstants = serde_json :: from_str ( & contents )
745
+ . with_context ( || format ! ( "Failed to parse JSON in file: {}" , path) ) ?;
741
746
742
- let parsed_version = StarknetVersion :: try_from ( version. as_str ( ) ) . with_context ( || format ! ( "Failed to parse version string: {}" , version) ) ?;
747
+ let parsed_version = StarknetVersion :: try_from ( version. as_str ( ) )
748
+ . with_context ( || format ! ( "Failed to parse version string: {}" , version) ) ?;
743
749
744
750
result. insert ( parsed_version, constants) ;
745
751
}
@@ -764,19 +770,21 @@ pub extern "C" fn setVersionedConstants(json_bytes: *const c_char) -> *const c_c
764
770
}
765
771
} ;
766
772
767
- let versioned_constants_files_paths: Result < BTreeMap < String , String > , _ > = serde_json:: from_str ( json_str) ;
773
+ let versioned_constants_files_paths: Result < BTreeMap < String , String > , _ > =
774
+ serde_json:: from_str ( json_str) ;
768
775
if let Ok ( paths) = versioned_constants_files_paths {
769
776
match VersionedConstantsMap :: from_file ( paths) {
770
- Ok ( custom_constants) => {
771
- unsafe {
772
- CUSTOM_VERSIONED_CONSTANTS = Some ( custom_constants) ;
773
- return CString :: new ( "" ) . unwrap ( ) . into_raw ( ) ;
774
- }
777
+ Ok ( custom_constants) => unsafe {
778
+ CUSTOM_VERSIONED_CONSTANTS = Some ( custom_constants) ;
779
+ return CString :: new ( "" ) . unwrap ( ) . into_raw ( ) ;
775
780
} ,
776
781
Err ( e) => {
777
- return CString :: new ( format ! ( "Failed to load versioned constants from paths: {}" , e) )
778
- . unwrap ( )
779
- . into_raw ( ) ;
782
+ return CString :: new ( format ! (
783
+ "Failed to load versioned constants from paths: {}" ,
784
+ e
785
+ ) )
786
+ . unwrap ( )
787
+ . into_raw ( ) ;
780
788
}
781
789
}
782
790
} else {
0 commit comments