Skip to content

Commit 31c66c4

Browse files
committed
test3
1 parent e222f18 commit 31c66c4

File tree

14 files changed

+141
-125
lines changed

14 files changed

+141
-125
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cheatnet/src/forking/state.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::cell::{Ref, RefCell};
2828
use std::collections::HashMap;
2929
use std::io::Read;
3030
use std::sync::Arc;
31-
use universal_sierra_compiler_api::{SierraType, compile_sierra};
31+
use universal_sierra_compiler_api::compile_contract_sierra;
3232
use url::Url;
3333

3434
#[derive(Debug)]
@@ -239,13 +239,10 @@ impl StateReader for ForkStateReader {
239239
SierraVersion::extract_from_program(&flattened_class.sierra_program)
240240
.expect("Unable to extract Sierra version from Sierra program");
241241

242-
match compile_sierra::<String>(&sierra_contract_class, &SierraType::Contract) {
242+
match compile_contract_sierra(&sierra_contract_class) {
243243
Ok(casm_contract_class_raw) => Ok(RunnableCompiledClass::V1(
244-
CompiledClassV1::try_from_json_string(
245-
&casm_contract_class_raw,
246-
sierra_version,
247-
)
248-
.expect("Unable to create RunnableCompiledClass::V1"),
244+
CompiledClassV1::try_from((casm_contract_class_raw, sierra_version))
245+
.expect("Unable to create RunnableCompiledClass::V1"),
249246
)),
250247
Err(err) => Err(StateReadError(err.to_string())),
251248
}

crates/forge-runner/src/running/hints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use cairo_lang_casm::hints::Hint;
22
use cairo_vm::serde::deserialize_program::{ApTracking, FlowTrackingData, HintParams};
33
use std::collections::HashMap;
4-
use universal_sierra_compiler_api::AssembledCairoProgramWithSerde;
4+
use universal_sierra_compiler_api::representation::AssembledCairoProgramWithSerde;
55

66
pub fn hints_by_representation(
77
assembled_program: &AssembledCairoProgramWithSerde,

crates/forge-runner/src/running/setup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use cairo_vm::vm::runners::cairo_runner::CairoRunner;
1515
use cheatnet::constants::build_test_entry_point;
1616
use starknet_api::deprecated_contract_class::EntryPointOffset;
1717
use std::collections::HashMap;
18-
use universal_sierra_compiler_api::AssembledProgramWithDebugInfo;
18+
use universal_sierra_compiler_api::representation::RawCasmProgram;
1919

2020
// Based on structure from https://github.com/starkware-libs/sequencer/blob/e417a9e7d50cbd78065d357763df2fbc2ad41f7c/crates/blockifier/src/execution/entry_point_execution.rs#L39
2121
// Logic of `initialize_execution_context` had to be modified so this struct ended up modified as well.
@@ -96,7 +96,7 @@ pub fn entry_point_initial_budget(syscall_hint_processor: &SyscallHintProcessor)
9696

9797
pub fn build_test_call_and_entry_point(
9898
test_details: &TestDetails,
99-
casm_program: &AssembledProgramWithDebugInfo,
99+
casm_program: &RawCasmProgram,
100100
program: &Program,
101101
) -> (ExecutableCallEntryPoint, EntryPointV1) {
102102
let sierra_instruction_idx = test_details.sierra_entry_point_statement_idx;

crates/forge-runner/src/running/with_config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use cairo_lang_utils::unordered_hash_map::UnorderedHashMap;
1919
use rayon::iter::IntoParallelRefIterator;
2020
use rayon::iter::ParallelIterator;
2121
use std::{collections::HashMap, sync::Arc};
22-
use universal_sierra_compiler_api::{SierraType, compile_sierra_at_path};
22+
use universal_sierra_compiler_api::compile_raw_sierra_at_path;
2323

2424
#[tracing::instrument(skip_all, level = "debug")]
2525
pub fn test_target_with_config(
@@ -42,9 +42,8 @@ pub fn test_target_with_config(
4242
let funcs = by_id!(funcs);
4343
let type_declarations = by_id!(type_declarations);
4444

45-
let casm_program = Arc::new(compile_sierra_at_path(
45+
let casm_program = Arc::new(compile_raw_sierra_at_path(
4646
&test_target_raw.sierra_program_path,
47-
&SierraType::Raw,
4847
)?);
4948

5049
let sierra_program_registry =

crates/forge/src/run_tests/resolve_config.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ mod tests {
134134
use forge_runner::package_tests::with_config::{TestCaseConfig, TestCaseWithConfig};
135135
use forge_runner::{expected_result::ExpectedTestResult, package_tests::TestDetails};
136136
use std::sync::Arc;
137-
use universal_sierra_compiler_api::{SierraType, compile_sierra};
137+
use universal_sierra_compiler_api::compile_raw_sierra;
138138
use url::Url;
139139

140140
fn program_for_testing() -> ProgramArtifact {
@@ -155,11 +155,8 @@ mod tests {
155155
sierra_program: program_for_testing(),
156156
sierra_program_path: Arc::default(),
157157
casm_program: Arc::new(
158-
compile_sierra(
159-
&serde_json::to_value(&program_for_testing().program).unwrap(),
160-
&SierraType::Raw,
161-
)
162-
.unwrap(),
158+
compile_raw_sierra(&serde_json::to_value(&program_for_testing().program).unwrap())
159+
.unwrap(),
163160
),
164161
test_cases: vec![TestCaseWithConfig {
165162
name: "crate1::do_thing".to_string(),

crates/forge/src/test_filter.rs

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ mod tests {
141141
};
142142
use forge_runner::package_tests::{TestDetails, TestTargetLocation};
143143
use std::sync::Arc;
144-
use universal_sierra_compiler_api::{SierraType, compile_sierra};
144+
use universal_sierra_compiler_api::compile_raw_sierra;
145145

146146
fn program_for_testing() -> ProgramArtifact {
147147
ProgramArtifact {
@@ -190,11 +190,8 @@ mod tests {
190190
sierra_program: program_for_testing(),
191191
sierra_program_path: Arc::default(),
192192
casm_program: Arc::new(
193-
compile_sierra(
194-
&serde_json::to_value(&program_for_testing().program).unwrap(),
195-
&SierraType::Raw,
196-
)
197-
.unwrap(),
193+
compile_raw_sierra(&serde_json::to_value(&program_for_testing().program).unwrap())
194+
.unwrap(),
198195
),
199196
test_cases: vec![
200197
TestCaseWithResolvedConfig {
@@ -478,11 +475,8 @@ mod tests {
478475
sierra_program: program_for_testing(),
479476
sierra_program_path: Arc::default(),
480477
casm_program: Arc::new(
481-
compile_sierra(
482-
&serde_json::to_value(&program_for_testing().program).unwrap(),
483-
&SierraType::Raw,
484-
)
485-
.unwrap(),
478+
compile_raw_sierra(&serde_json::to_value(&program_for_testing().program).unwrap())
479+
.unwrap(),
486480
),
487481
test_cases: vec![],
488482
tests_location: TestTargetLocation::Lib,
@@ -526,11 +520,8 @@ mod tests {
526520
sierra_program: program_for_testing(),
527521
sierra_program_path: Arc::default(),
528522
casm_program: Arc::new(
529-
compile_sierra(
530-
&serde_json::to_value(&program_for_testing().program).unwrap(),
531-
&SierraType::Raw,
532-
)
533-
.unwrap(),
523+
compile_raw_sierra(&serde_json::to_value(&program_for_testing().program).unwrap())
524+
.unwrap(),
534525
),
535526
test_cases: vec![
536527
TestCaseWithResolvedConfig {
@@ -726,17 +717,13 @@ mod tests {
726717
}
727718

728719
#[test]
729-
#[expect(clippy::too_many_lines)]
730720
fn filtering_with_only_ignored() {
731721
let mocked_tests = TestTargetWithResolvedConfig {
732722
sierra_program: program_for_testing(),
733723
sierra_program_path: Arc::default(),
734724
casm_program: Arc::new(
735-
compile_sierra(
736-
&serde_json::to_value(&program_for_testing().program).unwrap(),
737-
&SierraType::Raw,
738-
)
739-
.unwrap(),
725+
compile_raw_sierra(&serde_json::to_value(&program_for_testing().program).unwrap())
726+
.unwrap(),
740727
),
741728
test_cases: vec![
742729
TestCaseWithResolvedConfig {
@@ -847,11 +834,8 @@ mod tests {
847834
sierra_program: program_for_testing(),
848835
sierra_program_path: Arc::default(),
849836
casm_program: Arc::new(
850-
compile_sierra(
851-
&serde_json::to_value(&program_for_testing().program).unwrap(),
852-
&SierraType::Raw,
853-
)
854-
.unwrap(),
837+
compile_raw_sierra(&serde_json::to_value(&program_for_testing().program).unwrap())
838+
.unwrap(),
855839
),
856840
test_cases: vec![
857841
TestCaseWithResolvedConfig {

crates/scarb-api/src/artifacts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use itertools::Itertools;
88
use rayon::iter::{IntoParallelIterator, ParallelIterator};
99
use std::collections::HashMap;
1010
use std::fs;
11-
use universal_sierra_compiler_api::{SierraType, compile_sierra_at_path};
11+
use universal_sierra_compiler_api::compile_contract_sierra_at_path;
1212

1313
mod deserialized;
1414
mod representation;
@@ -106,7 +106,7 @@ impl StarknetArtifactsFiles {
106106
fn compile_artifact_at_path(&self, path: &Utf8Path) -> Result<StarknetContractArtifacts> {
107107
let sierra = fs::read_to_string(path)?;
108108

109-
let casm = compile_sierra_at_path(path, &SierraType::Contract)?;
109+
let casm = serde_json::to_string(&compile_contract_sierra_at_path(path)?)?;
110110

111111
#[cfg(feature = "cairo-native")]
112112
let executor = self.compile_to_native(&sierra)?;

crates/sncast/src/starknet_commands/declare_from.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use starknet::providers::Provider;
1515
use starknet::providers::jsonrpc::{HttpTransport, JsonRpcClient};
1616
use starknet::signers::LocalWallet;
1717
use starknet_types_core::felt::Felt;
18-
use universal_sierra_compiler_api::{SierraType, compile_sierra};
18+
use universal_sierra_compiler_api::compile_contract_sierra;
1919

2020
#[derive(Args)]
2121
#[command(about = "Declare a contract by fetching it from a different Starknet instance", long_about = None)]
@@ -110,11 +110,13 @@ pub async fn declare_from(
110110
let sierra: SierraClass = flattened_sierra_to_sierra(flattened_sierra)
111111
.expect("Failed to parse flattened sierra class");
112112

113-
let casm_json: String = compile_sierra(
114-
&serde_json::to_value(&sierra).expect("Failed to convert sierra to json value"),
115-
&SierraType::Contract,
113+
let casm_json: String = serde_json::to_string(
114+
&compile_contract_sierra(
115+
&serde_json::to_value(&sierra).expect("Failed to convert sierra to json value"),
116+
)
117+
.expect("Failed to compile sierra to casm"),
116118
)
117-
.expect("Failed to compile sierra to casm");
119+
.expect("serialization should succeed");
118120
let casm: CompiledClass = serde_json::from_str(&casm_json)
119121
.expect("Failed to deserialize casm JSON into CompiledClass");
120122
let sierra_class_hash = sierra.class_hash().map_err(anyhow::Error::from)?;

crates/universal-sierra-compiler-api/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ which.workspace = true
1212
tempfile.workspace = true
1313
num-bigint.workspace = true
1414
cairo-lang-casm.workspace = true
15+
cairo-lang-starknet-classes.workspace = true
1516
camino.workspace = true
1617
tracing.workspace = true
1718
strum_macros.workspace = true

0 commit comments

Comments
 (0)