diff --git a/crates/blockifier/src/execution/contract_class.rs b/crates/blockifier/src/execution/contract_class.rs index 316b9a01a4..c8bf596bb0 100644 --- a/crates/blockifier/src/execution/contract_class.rs +++ b/crates/blockifier/src/execution/contract_class.rs @@ -29,13 +29,12 @@ use itertools::Itertools; use semver::Version; use serde::de::Error as DeserializationError; use serde::{Deserialize, Deserializer, Serialize}; -use starknet_api::contract_class::ContractClass as RawContractClass; +use starknet_api::contract_class::{ContractClass as RawContractClass, EntryPointType}; use starknet_api::core::EntryPointSelector; use starknet_api::deprecated_contract_class::{ ContractClass as DeprecatedContractClass, EntryPoint, EntryPointOffset, - EntryPointType, Program as DeprecatedProgram, }; use starknet_types_core::felt::Felt; diff --git a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs index 3cc4ca8835..63aeeef433 100644 --- a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs +++ b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs @@ -5,8 +5,8 @@ use cairo_vm::types::layout_name::LayoutName; use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable}; use cairo_vm::vm::errors::vm_errors::VirtualMachineError; use cairo_vm::vm::runners::cairo_runner::{CairoArg, CairoRunner, ExecutionResources}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::EntryPointSelector; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::hash::StarkHash; use super::execution_utils::SEGMENT_ARENA_BUILTIN_SIZE; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index fe9cc94b05..f0acd50035 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -17,8 +17,8 @@ use cairo_vm::vm::errors::vm_errors::VirtualMachineError; use cairo_vm::vm::runners::cairo_runner::{ExecutionResources, ResourceTracker, RunResources}; use cairo_vm::vm::vm_core::VirtualMachine; use num_bigint::{BigUint, TryFromBigIntError}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::Calldata; use starknet_api::StarknetApiError; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs index f8f1da0a65..7fb9b7911a 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs @@ -2,6 +2,7 @@ use cairo_vm::types::relocatable::Relocatable; use cairo_vm::vm::vm_core::VirtualMachine; use serde::Deserialize; use starknet_api::block::{BlockNumber, BlockTimestamp}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ calculate_contract_address, ClassHash, @@ -9,7 +10,6 @@ use starknet_api::core::{ EntryPointSelector, EthAddress, }; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{ Calldata, diff --git a/crates/blockifier/src/execution/entry_point.rs b/crates/blockifier/src/execution/entry_point.rs index 9abdaa3ed5..e3ebce173c 100644 --- a/crates/blockifier/src/execution/entry_point.rs +++ b/crates/blockifier/src/execution/entry_point.rs @@ -6,8 +6,8 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::{ExecutionResources, ResourceTracker, RunResources}; use num_traits::{Inv, Zero}; use serde::Serialize; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{Calldata, TransactionVersion}; use starknet_types_core::felt::Felt; diff --git a/crates/blockifier/src/execution/errors.rs b/crates/blockifier/src/execution/errors.rs index 5098506c62..b507a7a21e 100644 --- a/crates/blockifier/src/execution/errors.rs +++ b/crates/blockifier/src/execution/errors.rs @@ -8,8 +8,8 @@ use cairo_vm::vm::errors::runner_errors::RunnerError; use cairo_vm::vm::errors::trace_errors::TraceError; use cairo_vm::vm::errors::vm_errors::VirtualMachineError; use num_bigint::{BigInt, TryFromBigIntError}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_types_core::felt::Felt; use thiserror::Error; diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index 6cde330c2c..0b33ea25d3 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -13,8 +13,8 @@ use cairo_vm::vm::errors::memory_errors::MemoryError; use cairo_vm::vm::errors::vm_errors::VirtualMachineError; use cairo_vm::vm::runners::cairo_runner::{ExecutionResources, ResourceTracker, RunResources}; use cairo_vm::vm::vm_core::VirtualMachine; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{AllResourceBounds, Calldata, Resource, ValidResourceBounds}; use starknet_api::StarknetApiError; diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index 86dee95a80..541b100945 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -2,6 +2,7 @@ use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable}; use cairo_vm::vm::vm_core::VirtualMachine; use num_traits::ToPrimitive; use starknet_api::block::{BlockHash, BlockNumber}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ calculate_contract_address, ClassHash, @@ -9,7 +10,6 @@ use starknet_api::core::{ EntryPointSelector, EthAddress, }; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{ Calldata, diff --git a/crates/blockifier/src/test_utils/contracts.rs b/crates/blockifier/src/test_utils/contracts.rs index a177ae719b..cb76b26968 100644 --- a/crates/blockifier/src/test_utils/contracts.rs +++ b/crates/blockifier/src/test_utils/contracts.rs @@ -1,3 +1,4 @@ +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, CompiledClassHash, @@ -8,7 +9,6 @@ use starknet_api::core::{ use starknet_api::deprecated_contract_class::{ ContractClass as DeprecatedContractClass, EntryPointOffset, - EntryPointType, }; use starknet_api::{class_hash, contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 14e7622e74..9221160775 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::block::GasPriceVector; use starknet_api::calldata; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::transaction::Resource::{L1DataGas, L1Gas, L2Gas}; use starknet_api::transaction::{ AccountDeploymentData, diff --git a/crates/blockifier/src/transaction/transactions.rs b/crates/blockifier/src/transaction/transactions.rs index d20abdf981..5af47ce605 100644 --- a/crates/blockifier/src/transaction/transactions.rs +++ b/crates/blockifier/src/transaction/transactions.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::transaction::{ AccountDeploymentData, Calldata, diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index e12e163179..1ad5d2ccb4 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -9,8 +9,8 @@ use num_traits::Pow; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::block::GasPriceVector; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ChainId, ClassHash, ContractAddress, EthAddress, Nonce, PatriciaKey}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::execution_resources::GasVector; use starknet_api::state::StorageKey; use starknet_api::test_utils::invoke::InvokeTxArgs; diff --git a/crates/blockifier_reexecution/src/state_reader/compile.rs b/crates/blockifier_reexecution/src/state_reader/compile.rs index b3203c5659..1b7e188cf8 100644 --- a/crates/blockifier_reexecution/src/state_reader/compile.rs +++ b/crates/blockifier_reexecution/src/state_reader/compile.rs @@ -13,8 +13,9 @@ use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::types::program::Program; use flate2::bufread; use serde::Deserialize; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::EntryPointSelector; -use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointOffset, EntryPointType}; +use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointOffset}; use starknet_api::hash::StarkHash; use starknet_core::types::{ CompressedLegacyContractClass, diff --git a/crates/papyrus_common/src/class_hash.rs b/crates/papyrus_common/src/class_hash.rs index 11f7ab12c2..fe74ecd885 100644 --- a/crates/papyrus_common/src/class_hash.rs +++ b/crates/papyrus_common/src/class_hash.rs @@ -3,9 +3,10 @@ mod class_hash_test; use lazy_static::lazy_static; use sha3::Digest; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::ClassHash; use starknet_api::hash::PoseidonHash; -use starknet_api::state::{ContractClass, EntryPointType}; +use starknet_api::state::ContractClass; use starknet_types_core::felt::Felt; use starknet_types_core::hash::{Poseidon, StarkHash}; diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index f38bd773dd..cfb61b6fd2 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -57,13 +57,10 @@ use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::{StorageError, StorageReader}; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockNumber, NonzeroGasPrice, StarknetVersion}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ChainId, ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; use starknet_api::data_availability::L1DataAvailabilityMode; -// TODO: merge multiple EntryPointType structs in SN_API into one. -use starknet_api::deprecated_contract_class::{ - ContractClass as DeprecatedContractClass, - EntryPointType, -}; +use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{StateNumber, ThinStateDiff}; use starknet_api::transaction::{ Calldata, diff --git a/crates/papyrus_execution/src/objects.rs b/crates/papyrus_execution/src/objects.rs index cc14739f77..9898c3527d 100644 --- a/crates/papyrus_execution/src/objects.rs +++ b/crates/papyrus_execution/src/objects.rs @@ -23,6 +23,7 @@ use papyrus_common::state::{ }; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockTimestamp, GasPrice, GasPricePerToken}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, ContractAddress, @@ -31,7 +32,6 @@ use starknet_api::core::{ SequencerContractAddress, }; use starknet_api::data_availability::L1DataAvailabilityMode; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::execution_resources::{ Builtin, ExecutionResources, diff --git a/crates/papyrus_execution/src/testing_instances.rs b/crates/papyrus_execution/src/testing_instances.rs index 218eb1185a..7d464ccf3f 100644 --- a/crates/papyrus_execution/src/testing_instances.rs +++ b/crates/papyrus_execution/src/testing_instances.rs @@ -5,8 +5,8 @@ pub use blockifier::abi::abi_utils::get_storage_var_address; use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; use starknet_api::block::GasPrice; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::execution_resources::ExecutionResources; use starknet_api::transaction::{Calldata, EventContent, Fee, MessageToL1}; use starknet_api::{contract_address, felt, patricia_key}; diff --git a/crates/papyrus_protobuf/src/converters/class.rs b/crates/papyrus_protobuf/src/converters/class.rs index 596501ae42..0cf9565f8f 100644 --- a/crates/papyrus_protobuf/src/converters/class.rs +++ b/crates/papyrus_protobuf/src/converters/class.rs @@ -3,6 +3,7 @@ use std::convert::{TryFrom, TryInto}; use papyrus_common::pending_classes::ApiContractClass; use prost::Message; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, EntryPointSelector}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::{deprecated_contract_class, state}; @@ -100,7 +101,7 @@ impl TryFrom for deprecated_contract_class::ContractClass if !value.constructors.is_empty() { entry_points_by_type.insert( - deprecated_contract_class::EntryPointType::Constructor, + EntryPointType::Constructor, value .constructors .into_iter() @@ -110,7 +111,7 @@ impl TryFrom for deprecated_contract_class::ContractClass } if !value.externals.is_empty() { entry_points_by_type.insert( - deprecated_contract_class::EntryPointType::External, + EntryPointType::External, value .externals .into_iter() @@ -120,7 +121,7 @@ impl TryFrom for deprecated_contract_class::ContractClass } if !value.l1_handlers.is_empty() { entry_points_by_type.insert( - deprecated_contract_class::EntryPointType::L1Handler, + EntryPointType::L1Handler, value .l1_handlers .into_iter() @@ -142,7 +143,7 @@ impl From for protobuf::Cairo0Class { protobuf::Cairo0Class { constructors: value .entry_points_by_type - .get(&deprecated_contract_class::EntryPointType::Constructor) + .get(&EntryPointType::Constructor) .unwrap_or(&vec![]) .iter() .cloned() @@ -150,7 +151,7 @@ impl From for protobuf::Cairo0Class { .collect(), externals: value .entry_points_by_type - .get(&deprecated_contract_class::EntryPointType::External) + .get(&EntryPointType::External) .unwrap_or(&vec![]) .iter() .cloned() @@ -158,7 +159,7 @@ impl From for protobuf::Cairo0Class { .collect(), l1_handlers: value .entry_points_by_type - .get(&deprecated_contract_class::EntryPointType::L1Handler) + .get(&EntryPointType::L1Handler) .unwrap_or(&vec![]) .iter() .cloned() @@ -186,7 +187,7 @@ impl TryFrom for state::ContractClass { })?; if !entry_points.constructors.is_empty() { entry_points_by_type.insert( - state::EntryPointType::Constructor, + EntryPointType::Constructor, entry_points .constructors .into_iter() @@ -196,7 +197,7 @@ impl TryFrom for state::ContractClass { } if !entry_points.externals.is_empty() { entry_points_by_type.insert( - state::EntryPointType::External, + EntryPointType::External, entry_points .externals .into_iter() @@ -206,7 +207,7 @@ impl TryFrom for state::ContractClass { } if !entry_points.l1_handlers.is_empty() { entry_points_by_type.insert( - state::EntryPointType::L1Handler, + EntryPointType::L1Handler, entry_points .l1_handlers .into_iter() @@ -229,7 +230,7 @@ impl From for protobuf::Cairo1Class { let entry_points = Some(protobuf::Cairo1EntryPoints { constructors: value .entry_points_by_type - .get(&state::EntryPointType::Constructor) + .get(&EntryPointType::Constructor) .unwrap_or(&vec![]) .iter() .cloned() @@ -238,7 +239,7 @@ impl From for protobuf::Cairo1Class { externals: value .entry_points_by_type - .get(&state::EntryPointType::External) + .get(&EntryPointType::External) .unwrap_or(&vec![]) .iter() .cloned() @@ -246,7 +247,7 @@ impl From for protobuf::Cairo1Class { .collect(), l1_handlers: value .entry_points_by_type - .get(&state::EntryPointType::L1Handler) + .get(&EntryPointType::L1Handler) .unwrap_or(&vec![]) .iter() .cloned() diff --git a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs index 29ab05fcd3..af8ae45540 100644 --- a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs @@ -8,12 +8,12 @@ use papyrus_test_utils::{ get_rng, GetTestInstance, }; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPoint as DeprecatedEntryPoint, - EntryPointType as DeprecatedEntryPointType, EventAbiEntry, FunctionAbiEntry, StructAbiEntry, @@ -140,15 +140,15 @@ fn declare_v1_fits_rpc() { abi, entry_points_by_type: HashMap::from([ ( - DeprecatedEntryPointType::Constructor, + EntryPointType::Constructor, vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], ), ( - DeprecatedEntryPointType::External, + EntryPointType::External, vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], ), ( - DeprecatedEntryPointType::L1Handler, + EntryPointType::L1Handler, vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], ), ]), diff --git a/crates/papyrus_rpc/src/v0_8/deprecated_contract_class.rs b/crates/papyrus_rpc/src/v0_8/deprecated_contract_class.rs index 0625c917b4..d0c162ec3c 100644 --- a/crates/papyrus_rpc/src/v0_8/deprecated_contract_class.rs +++ b/crates/papyrus_rpc/src/v0_8/deprecated_contract_class.rs @@ -2,7 +2,8 @@ use std::collections::HashMap; use papyrus_storage::db::serialization::StorageSerdeError; use serde::{Deserialize, Serialize}; -use starknet_api::deprecated_contract_class::{ContractClassAbiEntry, EntryPoint, EntryPointType}; +use starknet_api::contract_class::EntryPointType; +use starknet_api::deprecated_contract_class::{ContractClassAbiEntry, EntryPoint}; use crate::compression_utils::compress_and_encode; diff --git a/crates/papyrus_rpc/src/v0_8/execution.rs b/crates/papyrus_rpc/src/v0_8/execution.rs index 2bcda34c6f..1e8c03700e 100644 --- a/crates/papyrus_rpc/src/v0_8/execution.rs +++ b/crates/papyrus_rpc/src/v0_8/execution.rs @@ -10,8 +10,8 @@ use papyrus_execution::objects::{ TransactionTrace as ExecutionTransactionTrace, }; use serde::{Deserialize, Serialize}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress}; -use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::ThinStateDiff as StarknetApiThinStateDiff; use super::state::ThinStateDiff; diff --git a/crates/papyrus_rpc/src/v0_8/execution_test.rs b/crates/papyrus_rpc/src/v0_8/execution_test.rs index 4ab860aaba..5160040918 100644 --- a/crates/papyrus_rpc/src/v0_8/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_8/execution_test.rs @@ -50,6 +50,7 @@ use starknet_api::block::{ BlockTimestamp, GasPricePerToken, }; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, CompiledClassHash, @@ -61,10 +62,7 @@ use starknet_api::core::{ SequencerContractAddress, }; use starknet_api::data_availability::L1DataAvailabilityMode; -use starknet_api::deprecated_contract_class::{ - ContractClass as SN_API_DeprecatedContractClass, - EntryPointType, -}; +use starknet_api::deprecated_contract_class::ContractClass as SN_API_DeprecatedContractClass; use starknet_api::hash::StarkHash; use starknet_api::state::{StorageKey, ThinStateDiff as StarknetApiStateDiff}; use starknet_api::test_utils::read_json_file; diff --git a/crates/papyrus_rpc/src/v0_8/state.rs b/crates/papyrus_rpc/src/v0_8/state.rs index 7730b24c17..f701b278f1 100644 --- a/crates/papyrus_rpc/src/v0_8/state.rs +++ b/crates/papyrus_rpc/src/v0_8/state.rs @@ -2,13 +2,9 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockHash; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, GlobalRoot, Nonce}; -use starknet_api::state::{ - EntryPoint, - EntryPointType, - StorageKey, - ThinStateDiff as starknet_api_ThinStateDiff, -}; +use starknet_api::state::{EntryPoint, StorageKey, ThinStateDiff as starknet_api_ThinStateDiff}; use starknet_client::reader::objects::state::{ DeclaredClassHashEntry as ClientDeclaredClassHashEntry, DeployedContract as ClientDeployedContract, diff --git a/crates/papyrus_storage/src/serialization/serializers.rs b/crates/papyrus_storage/src/serialization/serializers.rs index 7cd25da6be..148fe6d553 100644 --- a/crates/papyrus_storage/src/serialization/serializers.rs +++ b/crates/papyrus_storage/src/serialization/serializers.rs @@ -28,6 +28,7 @@ use starknet_api::block::{ GasPricePerToken, StarknetVersion, }; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, CompiledClassHash, @@ -51,7 +52,6 @@ use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry, EntryPoint as DeprecatedEntryPoint, EntryPointOffset, - EntryPointType as DeprecatedEntryPointType, EventAbiEntry, EventType, FunctionAbiEntry, @@ -66,14 +66,7 @@ use starknet_api::deprecated_contract_class::{ }; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasAmount, GasVector}; use starknet_api::hash::{PoseidonHash, StarkHash}; -use starknet_api::state::{ - ContractClass, - EntryPoint, - EntryPointType, - FunctionIndex, - StorageKey, - ThinStateDiff, -}; +use starknet_api::state::{ContractClass, EntryPoint, FunctionIndex, StorageKey, ThinStateDiff}; use starknet_api::transaction::{ AccountDeploymentData, AllResourceBounds, @@ -238,11 +231,6 @@ auto_storage_serde! { pub selector: EntryPointSelector, pub offset: EntryPointOffset, } - pub enum DeprecatedEntryPointType { - Constructor = 0, - External = 1, - L1Handler = 2, - } pub struct EntryPoint { pub function_idx: FunctionIndex, pub selector: EntryPointSelector, @@ -999,9 +987,7 @@ impl StorageSerde for DeprecatedContractClass { abi: Option::>::deserialize_from(data)?, program: Program::deserialize_from(data)?, entry_points_by_type: - HashMap::>::deserialize_from( - bytes, - )?, + HashMap::>::deserialize_from(bytes)?, }) } } diff --git a/crates/papyrus_storage/src/utils.rs b/crates/papyrus_storage/src/utils.rs index bcb33c99e9..01a4ef5d77 100644 --- a/crates/papyrus_storage/src/utils.rs +++ b/crates/papyrus_storage/src/utils.rs @@ -10,8 +10,9 @@ use std::io::{BufWriter, Write}; use metrics::{absolute_counter, gauge}; use serde::Serialize; use starknet_api::block::BlockNumber; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ChainId, ClassHash, CompiledClassHash}; -use starknet_api::state::{EntryPoint, EntryPointType}; +use starknet_api::state::EntryPoint; use starknet_types_core::felt::Felt; use tracing::debug; diff --git a/crates/papyrus_test_utils/src/lib.rs b/crates/papyrus_test_utils/src/lib.rs index 321a19e412..26d222f049 100644 --- a/crates/papyrus_test_utils/src/lib.rs +++ b/crates/papyrus_test_utils/src/lib.rs @@ -50,6 +50,7 @@ use starknet_api::block::{ GasPricePerToken, StarknetVersion, }; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, CompiledClassHash, @@ -72,7 +73,6 @@ use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry, EntryPoint as DeprecatedEntryPoint, EntryPointOffset, - EntryPointType as DeprecatedEntryPointType, EventAbiEntry, EventType, FunctionAbiEntry, @@ -102,7 +102,6 @@ use starknet_api::rpc_transaction::{ use starknet_api::state::{ ContractClass, EntryPoint, - EntryPointType, FunctionIndex, StateDiff, StorageKey, @@ -488,7 +487,7 @@ auto_impl_get_test_instance! { pub struct DeprecatedContractClass { pub abi: Option>, pub program: Program, - pub entry_points_by_type: HashMap>, + pub entry_points_by_type: HashMap>, } pub enum ContractClassAbiEntry { Event(EventAbiEntry) = 0, @@ -592,11 +591,6 @@ auto_impl_get_test_instance! { pub selector: EntryPointSelector, pub offset: EntryPointOffset, } - pub enum DeprecatedEntryPointType { - Constructor = 0, - External = 1, - L1Handler = 2, - } pub struct EntryPoint { pub function_idx: FunctionIndex, pub selector: EntryPointSelector, diff --git a/crates/starknet_api/src/contract_class.rs b/crates/starknet_api/src/contract_class.rs index 381d73d122..6470347578 100644 --- a/crates/starknet_api/src/contract_class.rs +++ b/crates/starknet_api/src/contract_class.rs @@ -4,6 +4,23 @@ use serde::{Deserialize, Serialize}; use crate::core::CompiledClassHash; use crate::deprecated_contract_class::ContractClass as DeprecatedContractClass; +#[derive( + Debug, Default, Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, +)] +#[serde(deny_unknown_fields)] +pub enum EntryPointType { + /// A constructor entry point. + #[serde(rename = "CONSTRUCTOR")] + Constructor, + /// An external entry point. + #[serde(rename = "EXTERNAL")] + #[default] + External, + /// An L1 handler entry point. + #[serde(rename = "L1_HANDLER")] + L1Handler, +} + /// Represents a raw Starknet contract class. #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub enum ContractClass { diff --git a/crates/starknet_api/src/deprecated_contract_class.rs b/crates/starknet_api/src/deprecated_contract_class.rs index a16b2cbef3..ac74f12af1 100644 --- a/crates/starknet_api/src/deprecated_contract_class.rs +++ b/crates/starknet_api/src/deprecated_contract_class.rs @@ -7,6 +7,7 @@ use serde::de::Error as DeserializationError; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::Value; +use crate::contract_class::EntryPointType; use crate::core::EntryPointSelector; use crate::hash::StarkHash; use crate::serde_utils::deserialize_optional_contract_class_abi_entry_vector; @@ -164,24 +165,6 @@ where ) } -/// An entry point type of a [ContractClass](`crate::deprecated_contract_class::ContractClass`). -#[derive( - Debug, Default, Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, -)] -#[serde(deny_unknown_fields)] -pub enum EntryPointType { - /// A constructor entry point. - #[serde(rename = "CONSTRUCTOR")] - Constructor, - /// An external4 entry point. - #[serde(rename = "EXTERNAL")] - #[default] - External, - /// An L1 handler entry point. - #[serde(rename = "L1_HANDLER")] - L1Handler, -} - /// An entry point of a [ContractClass](`crate::deprecated_contract_class::ContractClass`). #[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] pub struct EntryPoint { diff --git a/crates/starknet_api/src/state.rs b/crates/starknet_api/src/state.rs index ed6dd2ef70..d7351617fc 100644 --- a/crates/starknet_api/src/state.rs +++ b/crates/starknet_api/src/state.rs @@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize}; use starknet_types_core::felt::Felt; use crate::block::{BlockHash, BlockNumber}; +use crate::contract_class::EntryPointType; use crate::core::{ ClassHash, CompiledClassHash, @@ -210,23 +211,6 @@ pub struct ContractClass { pub abi: String, } -#[derive( - Debug, Default, Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, -)] -#[serde(deny_unknown_fields)] -pub enum EntryPointType { - /// A constructor entry point. - #[serde(rename = "CONSTRUCTOR")] - Constructor, - /// An external entry point. - #[serde(rename = "EXTERNAL")] - #[default] - External, - /// An L1 handler entry point. - #[serde(rename = "L1_HANDLER")] - L1Handler, -} - /// An entry point of a [ContractClass](`crate::state::ContractClass`). #[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] pub struct EntryPoint { diff --git a/crates/starknet_client/src/reader/objects/state.rs b/crates/starknet_client/src/reader/objects/state.rs index c20656d83c..0a22ec272e 100644 --- a/crates/starknet_client/src/reader/objects/state.rs +++ b/crates/starknet_client/src/reader/objects/state.rs @@ -9,8 +9,9 @@ pub use papyrus_common::state::{ }; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockHash; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, GlobalRoot, Nonce}; -use starknet_api::state::{EntryPoint, EntryPointType}; +use starknet_api::state::EntryPoint; use starknet_types_core::felt::Felt; /// A state update derived from a single block as returned by the starknet gateway. diff --git a/crates/starknet_client/src/reader/objects/test_utils.rs b/crates/starknet_client/src/reader/objects/test_utils.rs index f4d0f8491e..130aa84d3b 100644 --- a/crates/starknet_client/src/reader/objects/test_utils.rs +++ b/crates/starknet_client/src/reader/objects/test_utils.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, CompiledClassHash, @@ -11,7 +12,7 @@ use starknet_api::core::{ }; use starknet_api::execution_resources::GasVector; use starknet_api::hash::StarkHash; -use starknet_api::state::{EntryPoint, EntryPointType}; +use starknet_api::state::EntryPoint; use starknet_api::transaction::{ AccountDeploymentData, Calldata, diff --git a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs index 2767a4bb57..a04c01e65c 100644 --- a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs +++ b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs @@ -8,6 +8,7 @@ use indexmap::indexmap; use mockito::mock; use pretty_assertions::assert_eq; use starknet_api::block::{BlockHash, BlockNumber}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, ContractAddress, @@ -24,12 +25,11 @@ use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry, EntryPoint as DeprecatedEntryPoint, EntryPointOffset, - EntryPointType as DeprecatedEntryPointType, FunctionAbiEntry, Program, TypedParameter, }; -use starknet_api::state::{EntryPoint, EntryPointType, FunctionIndex}; +use starknet_api::state::{EntryPoint, FunctionIndex}; use starknet_api::transaction::{Fee, TransactionHash, TransactionSignature, TransactionVersion}; use starknet_api::{felt, patricia_key}; @@ -262,9 +262,9 @@ async fn deprecated_contract_class() { reference_manager: serde_json::Value::Object(serde_json::Map::new()), }, entry_points_by_type: HashMap::from([ - (DeprecatedEntryPointType::L1Handler, vec![]), + (EntryPointType::L1Handler, vec![]), ( - DeprecatedEntryPointType::Constructor, + EntryPointType::Constructor, vec![DeprecatedEntryPoint { selector: EntryPointSelector(felt!( "0x028ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194" @@ -273,7 +273,7 @@ async fn deprecated_contract_class() { }], ), ( - DeprecatedEntryPointType::External, + EntryPointType::External, vec![DeprecatedEntryPoint { selector: EntryPointSelector(felt!( "0x0000000000000000000000000000000000000000000000000000000000000000" diff --git a/crates/starknet_client/src/writer/objects/test_utils.rs b/crates/starknet_client/src/writer/objects/test_utils.rs index e13e17ccea..a585fe01dd 100644 --- a/crates/starknet_client/src/writer/objects/test_utils.rs +++ b/crates/starknet_client/src/writer/objects/test_utils.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress}; use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPoint as DeprecatedEntryPoint, - EntryPointType as DeprecatedEntryPointType, }; use starknet_api::transaction::TransactionHash; @@ -21,7 +21,7 @@ auto_impl_get_test_instance! { pub struct DeprecatedContractClass { pub abi: Option>, pub compressed_program: String, - pub entry_points_by_type: HashMap>, + pub entry_points_by_type: HashMap>, } pub struct InvokeResponse { pub code: SuccessfulStarknetErrorCode, diff --git a/crates/starknet_client/src/writer/objects/transaction.rs b/crates/starknet_client/src/writer/objects/transaction.rs index 50adae8afd..9ffffeeaf0 100644 --- a/crates/starknet_client/src/writer/objects/transaction.rs +++ b/crates/starknet_client/src/writer/objects/transaction.rs @@ -14,6 +14,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; +use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ ClassHash, CompiledClassHash, @@ -24,9 +25,8 @@ use starknet_api::core::{ use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPoint as DeprecatedEntryPoint, - EntryPointType as DeprecatedEntryPointType, }; -use starknet_api::state::{EntryPoint, EntryPointType}; +use starknet_api::state::EntryPoint; use starknet_api::transaction::{ AccountDeploymentData, Calldata, @@ -270,7 +270,7 @@ pub struct DeprecatedContractClass { #[serde(rename = "program")] // TODO(shahak): Create a struct for a compressed base64 value. pub compressed_program: String, - pub entry_points_by_type: HashMap>, + pub entry_points_by_type: HashMap>, } #[derive(Debug, Clone, Default, Eq, PartialEq, Deserialize, Serialize)]