Skip to content

Commit e87bd1c

Browse files
chore(blockifier): add is_legacy method
1 parent 1b9c871 commit e87bd1c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/blockifier/src/test_utils/contracts.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ impl FeatureContract {
178178
}
179179
}
180180

181+
pub fn is_legacy(&self) -> bool {
182+
matches!(self, Self::LegacyTestContract)
183+
}
184+
181185
/// Unique integer representing each unique contract. Used to derive "class hash" and "address".
182186
fn get_integer_base(self) -> u32 {
183187
self.get_cairo_version_bit()
@@ -273,15 +277,16 @@ impl FeatureContract {
273277
cairo0_compile(self.get_source_path(), extra_arg, false)
274278
}
275279
CairoVersion::Cairo1 => {
276-
let (tag_override, cargo_nightly_arg) = match self {
277-
Self::LegacyTestContract => (
280+
let (tag_override, cargo_nightly_arg) = if self.is_legacy() {
281+
(
278282
// Legacy contract requires specific compiler tag (which is the point of
279283
// the test contract), + to build the compiler an
280284
// older rust version is required.
281285
Some(LEGACY_CONTRACT_COMPILER_TAG.into()),
282286
Some(String::from("2023-07-05")),
283-
),
284-
_ => (None, None),
287+
)
288+
} else {
289+
(None, None)
285290
};
286291
cairo1_compile(self.get_source_path(), tag_override, cargo_nightly_arg)
287292
}

0 commit comments

Comments
 (0)