Skip to content

Commit 6799aa3

Browse files
chore(blockifier): add is_legacy method
1 parent f400d64 commit 6799aa3

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()
@@ -269,15 +273,16 @@ impl FeatureContract {
269273
cairo0_compile(self.get_source_path(), extra_arg, false)
270274
}
271275
CairoVersion::Cairo1 => {
272-
let (tag_override, cargo_arg) = match self {
273-
Self::LegacyTestContract => (
276+
let (tag_override, cargo_arg) = if self.is_legacy() {
277+
(
274278
// Legacy contract requires specific compiler tag (which is the point of
275279
// the test contract), + to build the compiler an
276280
// older rust version is required.
277281
Some(LEGACY_CONTRACT_COMPILER_TAG.into()),
278282
Some(String::from("+nightly-2023-07-05")),
279-
),
280-
_ => (None, None),
283+
)
284+
} else {
285+
(None, None)
281286
};
282287
cairo1_compile(self.get_source_path(), tag_override, cargo_arg)
283288
}

0 commit comments

Comments
 (0)