Skip to content

Commit

Permalink
feat: upgrade cairo compiler to 2.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Aug 20, 2024
1 parent 56e044b commit 689d03f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 55 deletions.
84 changes: 42 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async-trait = "0.1.68"
auto_impl = "1.1.0"
bigdecimal = "0.4.1"
cairo-starknet-2-6-4 = { package = "cairo-lang-starknet-classes", git = "https://github.com/starkware-libs/cairo", tag = "v2.6.4" }
cairo-starknet-2-7-0 = { package = "cairo-lang-starknet-classes", git = "https://github.com/starkware-libs/cairo", tag = "v2.7.0" }
cairo-starknet-2-7-1 = { package = "cairo-lang-starknet-classes", git = "https://github.com/starkware-libs/cairo", tag = "v2.7.1" }
chrono = "0.4.26"
clap = { version = "4.3.8", features = ["derive", "env", "string"] }
clap_complete = "4.3.1"
Expand Down
2 changes: 1 addition & 1 deletion src/casm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl CasmArgs {
Some(network) => {
let auto_version = match network {
Network::Sepolia | Network::SepoliaIntegration => {
CompilerVersion::V2_7_0
CompilerVersion::V2_7_1
}
Network::Mainnet => CompilerVersion::V2_6_4,
};
Expand Down
22 changes: 11 additions & 11 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use cairo_starknet_2_6_4::{
casm_contract_class::CasmContractClass as Cairo264CasmClass,
contract_class::ContractClass as Cairo264Class,
};
use cairo_starknet_2_7_0::{
casm_contract_class::CasmContractClass as Cairo270CasmClass,
contract_class::ContractClass as Cairo270Class,
use cairo_starknet_2_7_1::{
casm_contract_class::CasmContractClass as Cairo271CasmClass,
contract_class::ContractClass as Cairo271Class,
};
use clap::{builder::PossibleValue, ValueEnum};
use starknet::core::types::{
Expand All @@ -36,7 +36,7 @@ pub struct CompilerBinary {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompilerVersion {
V2_6_4,
V2_7_0,
V2_7_1,
}

impl BuiltInCompiler {
Expand Down Expand Up @@ -68,13 +68,13 @@ impl BuiltInCompiler {

serde_json::to_string(&casm_contract)?
}
CompilerVersion::V2_7_0 => {
CompilerVersion::V2_7_1 => {
// TODO: directly convert type without going through JSON
let contract_class: Cairo270Class = serde_json::from_str(&sierra_class_json)?;
let contract_class: Cairo271Class = serde_json::from_str(&sierra_class_json)?;

// TODO: implement the `validate_compatible_sierra_version` call

let casm_contract = Cairo270CasmClass::from_contract_class(
let casm_contract = Cairo271CasmClass::from_contract_class(
contract_class,
false,
MAX_BYTECODE_SIZE,
Expand Down Expand Up @@ -142,13 +142,13 @@ impl Default for CompilerVersion {

impl ValueEnum for CompilerVersion {
fn value_variants<'a>() -> &'a [Self] {
&[Self::V2_6_4, Self::V2_7_0]
&[Self::V2_6_4, Self::V2_7_1]
}

fn to_possible_value(&self) -> Option<PossibleValue> {
match self {
Self::V2_6_4 => Some(PossibleValue::new("2.6.4").alias("v2.6.4")),
Self::V2_7_0 => Some(PossibleValue::new("2.7.0").alias("v2.7.0")),
Self::V2_7_1 => Some(PossibleValue::new("2.7.1").alias("v2.7.1")),
}
}
}
Expand All @@ -159,7 +159,7 @@ impl FromStr for CompilerVersion {
fn from_str(s: &str) -> Result<Self> {
match s {
"2.6.4" | "v2.6.4" => Ok(Self::V2_6_4),
"2.7.0" | "v2.7.0" => Ok(Self::V2_7_0),
"2.7.1" | "v2.7.1" => Ok(Self::V2_7_1),
_ => Err(anyhow::anyhow!("unknown version: {}", s)),
}
}
Expand All @@ -169,7 +169,7 @@ impl Display for CompilerVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CompilerVersion::V2_6_4 => write!(f, "2.6.4"),
CompilerVersion::V2_7_0 => write!(f, "2.7.0"),
CompilerVersion::V2_7_1 => write!(f, "2.7.1"),
}
}
}
Expand Down

0 comments on commit 689d03f

Please sign in to comment.