Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit e41627d

Browse files
committed
Move starknet-contract-class to SiR
1 parent 493a7d1 commit e41627d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+193
-198
lines changed

Cargo.lock

Lines changed: 111 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@ with_mimalloc = ["mimalloc"]
1111
cairo_1_tests = []
1212

1313
[workspace]
14-
members = ["crates/starknet-contract-class", "cli", "fuzzer"]
14+
members = ["cli", "fuzzer"]
1515

1616
[workspace.dependencies]
17-
cairo-vm = { version = "0.8.1", features = ["cairo-1-hints"]}
17+
cairo-vm = { version = "0.8.1", features = ["cairo-1-hints"] }
1818
starknet_api = "0.1.0"
1919
num-traits = "0.2.15"
2020

2121
[dependencies]
2222
cairo-lang-starknet = "2.0.0"
2323
cairo-lang-casm = "2.0.0"
24-
cairo-vm = { workspace=true, features = ["cairo-1-hints"]}
24+
cairo-vm = { workspace = true, features = ["cairo-1-hints"] }
2525
getset = "0.1.2"
2626
lazy_static = "1.4.0"
2727
num-bigint = { version = "0.4", features = ["serde"] }
2828
num-integer = "0.1.45"
2929
num-traits = { workspace = true }
3030
serde = { version = "1.0.152", features = ["derive"] }
31-
serde_json = { version = "1.0", features = ["arbitrary_precision", "raw_value"] }
31+
serde_json = { version = "1.0", features = [
32+
"arbitrary_precision",
33+
"raw_value",
34+
] }
3235
sha3 = "0.10.1"
3336
starknet_api = { workspace = true }
3437
starknet-crypto = "0.5.1"
@@ -38,7 +41,6 @@ mimalloc = { version = "0.1.29", default-features = false, optional = true }
3841
hex = "0.4.3"
3942
cargo-llvm-cov = "0.5.14"
4043
anyhow = "1.0.66"
41-
starknet-contract-class = { path = "./crates/starknet-contract-class", version = "0.2.0" }
4244
once_cell = "1.17.1"
4345

4446
[dev-dependencies]

crates/starknet-contract-class/Cargo.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

fuzzer/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ num-traits = { workspace = true }
1212
starknet_api = { workspace = true }
1313
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
1414
tempfile = "3.2.0"
15-
cairo-vm = { workspace=true, features = ["cairo-1-hints"]}
16-
starknet-contract-class = { path = "../crates/starknet-contract-class/", version = "0.2.0" }
15+
cairo-vm = { workspace = true, features = ["cairo-1-hints"] }

fuzzer/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate honggfuzz;
66
use cairo_vm::felt::Felt252;
77
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
88
use num_traits::Zero;
9-
use starknet_contract_class::EntryPointType;
9+
use starknet_in_rust::EntryPointType;
1010
use starknet_in_rust::{
1111
definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION},
1212
execution::{

src/core/contract_address/deprecated_contract_address.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use crate::services::api::contract_classes::deprecated_parsed_contract_class::{
2+
ContractEntryPoint, EntryPointType,
3+
};
14
/// Contains functionality for computing class hashes for deprecated Declare transactions
25
/// (ie, declarations that do not correspond to Cairo 1 contracts)
36
/// The code used for hinted class hash computation was extracted from the Pathfinder and xJonathanLEI implementations
@@ -13,7 +16,6 @@ use cairo_vm::felt::Felt252;
1316
use num_traits::Zero;
1417
use serde::Serialize;
1518
use sha3::Digest;
16-
use starknet_contract_class::{ContractEntryPoint, EntryPointType};
1719
use std::{borrow::Cow, collections::BTreeMap, io};
1820

1921
/// Instead of doing a Mask with 250 bits, we are only masking the most significant byte.
@@ -352,10 +354,10 @@ mod tests {
352354
use std::{fs, str::FromStr};
353355

354356
use super::*;
357+
use crate::services::api::contract_classes::deprecated_parsed_contract_class::ParsedContractClass;
355358
use cairo_vm::felt::{felt_str, Felt252};
356359
use coverage_helper::test;
357360
use num_traits::Num;
358-
use starknet_contract_class::ParsedContractClass;
359361

360362
#[test]
361363
fn test_compute_hinted_class_hash_with_abi() {

src/core/contract_address/sierra_contract_address.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use crate::core::errors::contract_address_errors::ContractAddressError;
2+
use crate::services::api::contract_classes::deprecated_parsed_contract_class::{
3+
ContractEntryPoint, EntryPointType,
4+
};
25
use cairo_lang_starknet::{
36
contract::starknet_keccak, contract_class::ContractClass as SierraContractClass,
47
};
58
use cairo_vm::felt::Felt252;
6-
use starknet_contract_class::{ContractEntryPoint, EntryPointType};
79
use starknet_crypto::{poseidon_hash_many, FieldElement};
810

911
const CONTRACT_CLASS_VERSION: &[u8] = b"CONTRACT_CLASS_V0.1.0";

src/execution/execution_entry_point.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use crate::services::api::contract_classes::deprecated_parsed_contract_class::{
2+
ContractEntryPoint, EntryPointType,
3+
};
14
use crate::{
25
definitions::{block_context::BlockContext, constants::DEFAULT_ENTRY_POINT_SELECTOR},
36
runner::StarknetRunner,
@@ -31,7 +34,6 @@ use cairo_vm::{
3134
vm_core::VirtualMachine,
3235
},
3336
};
34-
use starknet_contract_class::{ContractEntryPoint, EntryPointType};
3537

3638
use super::{
3739
CallInfo, CallResult, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext,

src/execution/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub mod execution_entry_point;
22
pub mod gas_usage;
33
pub mod os_usage;
44

5+
use crate::services::api::contract_classes::deprecated_parsed_contract_class::EntryPointType;
56
use crate::{
67
definitions::{
78
block_context::StarknetChainId, constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR,
@@ -19,7 +20,6 @@ use cairo_vm::{
1920
};
2021
use getset::Getters;
2122
use num_traits::{ToPrimitive, Zero};
22-
use starknet_contract_class::EntryPointType;
2323
use std::collections::{HashMap, HashSet};
2424

2525
#[derive(Debug, Clone, PartialEq, Eq)]

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ use utils::Address;
2525
extern crate assert_matches;
2626

2727
// Re-exports
28+
pub use crate::services::api::contract_classes::deprecated_parsed_contract_class::{
29+
ContractEntryPoint, EntryPointType,
30+
};
2831
pub use cairo_lang_starknet::casm_contract_class::CasmContractClass;
2932
pub use cairo_lang_starknet::contract_class::ContractClass;
3033
pub use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass;
3134
pub use cairo_vm::felt::Felt252;
32-
pub use starknet_contract_class::EntryPointType;
3335

3436
pub mod core;
3537
pub mod definitions;
@@ -205,6 +207,7 @@ mod test {
205207
use crate::estimate_message_fee;
206208
use crate::hash_utils::calculate_contract_address;
207209
use crate::services::api::contract_classes::deprecated_contract_class::ContractClass;
210+
use crate::services::api::contract_classes::deprecated_parsed_contract_class::EntryPointType;
208211
use crate::state::state_api::State;
209212
use crate::testing::{
210213
create_account_tx_test_state, TEST_ACCOUNT_CONTRACT_ADDRESS, TEST_CONTRACT_ADDRESS,
@@ -218,7 +221,6 @@ mod test {
218221
use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass;
219222
use cairo_vm::felt::{felt_str, Felt252};
220223
use num_traits::{Num, One, Zero};
221-
use starknet_contract_class::EntryPointType;
222224

223225
use crate::{
224226
call_contract,
@@ -258,7 +260,7 @@ mod test {
258260
ContractClass::try_from(PathBuf::from(TEST_CONTRACT_PATH)).unwrap();
259261

260262
let entrypoints = contract_class.entry_points_by_type;
261-
let entrypoint_selector = &entrypoints.get(&EntryPointType::External).unwrap()[0].selector;
263+
let entrypoint_selector = entrypoints.get(&EntryPointType::External).unwrap()[0].selector();
262264

263265
let (block_context, state) = create_account_tx_test_state().unwrap();
264266

0 commit comments

Comments
 (0)