Skip to content

Commit 9a950bf

Browse files
chore(blockifier): add is_legacy method
1 parent 2618e0f commit 9a950bf

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

182+
pub fn is_legacy(&self) -> bool {
183+
matches!(self, Self::LegacyTestContract)
184+
}
185+
182186
/// Unique integer representing each unique contract. Used to derive "class hash" and "address".
183187
fn get_integer_base(self) -> u32 {
184188
self.get_cairo_version_bit()
@@ -276,15 +280,16 @@ impl FeatureContract {
276280
cairo0_compile(self.get_source_path(), extra_arg, false)
277281
}
278282
CairoVersion::Cairo1 => {
279-
let (tag_override, cargo_arg) = match self {
280-
Self::LegacyTestContract => (
283+
let (tag_override, cargo_arg) = if self.is_legacy() {
284+
(
281285
// Legacy contract requires specific compiler tag (which is the point of
282286
// the test contract), + to build the compiler an
283287
// older rust version is required.
284288
Some(LEGACY_CONTRACT_COMPILER_TAG.into()),
285289
Some(String::from("+nightly-2023-07-05")),
286-
),
287-
_ => (None, None),
290+
)
291+
} else {
292+
(None, None)
288293
};
289294
cairo1_compile(self.get_source_path(), tag_override, cargo_arg)
290295
}

0 commit comments

Comments
 (0)