From e87bd1c845ec359f80d9a2d82e7889b733b879f3 Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Tue, 30 Jul 2024 12:06:22 +0300 Subject: [PATCH] chore(blockifier): add is_legacy method --- crates/blockifier/src/test_utils/contracts.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/blockifier/src/test_utils/contracts.rs b/crates/blockifier/src/test_utils/contracts.rs index f97c2fe5fda..575ba4c223a 100644 --- a/crates/blockifier/src/test_utils/contracts.rs +++ b/crates/blockifier/src/test_utils/contracts.rs @@ -178,6 +178,10 @@ impl FeatureContract { } } + pub fn is_legacy(&self) -> bool { + matches!(self, Self::LegacyTestContract) + } + /// Unique integer representing each unique contract. Used to derive "class hash" and "address". fn get_integer_base(self) -> u32 { self.get_cairo_version_bit() @@ -273,15 +277,16 @@ impl FeatureContract { cairo0_compile(self.get_source_path(), extra_arg, false) } CairoVersion::Cairo1 => { - let (tag_override, cargo_nightly_arg) = match self { - Self::LegacyTestContract => ( + let (tag_override, cargo_nightly_arg) = if self.is_legacy() { + ( // Legacy contract requires specific compiler tag (which is the point of // the test contract), + to build the compiler an // older rust version is required. Some(LEGACY_CONTRACT_COMPILER_TAG.into()), Some(String::from("2023-07-05")), - ), - _ => (None, None), + ) + } else { + (None, None) }; cairo1_compile(self.get_source_path(), tag_override, cargo_nightly_arg) }