Skip to content

Commit

Permalink
Refactor get_versioned_constants function in lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushinDaniil committed Aug 12, 2024
1 parent 8a8b774 commit 982b903
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vm/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,14 @@ lazy_static! {

#[allow(static_mut_refs)]
fn get_versioned_constants(version: *const c_char) -> VersionedConstants {
let version_str = unsafe { CStr::from_ptr(version) }.to_str().unwrap();
let version = StarknetVersion::from_str(version_str)
.unwrap_or(StarknetVersion::from_str("0.0.0").unwrap());
let version_str = unsafe { CStr::from_ptr(version) }
.to_str()
.unwrap_or("0.0.0");

let version = match StarknetVersion::from_str(version_str) {
Ok(v) => v,
Err(_) => StarknetVersion::from_str("0.0.0").unwrap(),
};

if let Some(constants) = unsafe { &CUSTOM_VERSIONED_CONSTANTS } {
constants.clone()
Expand Down

0 comments on commit 982b903

Please sign in to comment.