cairo_lang_starknet_classes/
compiler_version.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
4pub struct VersionId {
5    pub major: usize,
6    pub minor: usize,
7    pub patch: usize,
8}
9
10pub const CONTRACT_SEGMENTATION_MINOR_VERSION: usize = 5;
11
12impl std::fmt::Display for VersionId {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
15    }
16}
17
18/// The version of the high level compiler that compiled the contract. Should be the same as the
19/// rust workspace version.
20pub fn current_compiler_version_id() -> VersionId {
21    VersionId {
22        major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(),
23        minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(),
24        patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(),
25    }
26}
27
28/// The version of the Sierra compiler that compiled the contract.
29///
30/// Major version should be updated in any non-backwards compatible change of the Sierra compiler.
31/// Minor version should be updated in any backwards compatible change of the Sierra compiler.
32/// For more information see docs/CONTRIBUTING.md.
33pub fn current_sierra_version_id() -> VersionId {
34    VersionId { major: 1, minor: 7, patch: 0 }
35}