Skip to content

Commit dd8634f

Browse files
chore(blockifier): add is_legacy method
1 parent 58aca6d commit dd8634f

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
@@ -180,6 +180,10 @@ impl FeatureContract {
180180
}
181181
}
182182

183+
pub fn is_legacy(&self) -> bool {
184+
matches!(self, Self::LegacyTestContract)
185+
}
186+
183187
/// Unique integer representing each unique contract. Used to derive "class hash" and "address".
184188
fn get_integer_base(self) -> u32 {
185189
self.get_cairo_version_bit()
@@ -279,15 +283,16 @@ impl FeatureContract {
279283
cairo0_compile(self.get_source_path(), extra_arg, false)
280284
}
281285
CairoVersion::Cairo1 => {
282-
let (tag_override, cargo_arg) = match self {
283-
Self::LegacyTestContract => (
286+
let (tag_override, cargo_arg) = if self.is_legacy() {
287+
(
284288
// Legacy contract requires specific compiler tag (which is the point of
285289
// the test contract), + to build the compiler an
286290
// older rust version is required.
287291
Some(LEGACY_CONTRACT_COMPILER_TAG.into()),
288292
Some(String::from("+nightly-2023-07-05")),
289-
),
290-
_ => (None, None),
293+
)
294+
} else {
295+
(None, None)
291296
};
292297
cairo1_compile(self.get_source_path(), tag_override, cargo_arg)
293298
}

0 commit comments

Comments
 (0)