From 0ccf6f3094faa019f0a80171a6c6737f33b07554 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Sun, 20 Oct 2024 06:53:50 +0300 Subject: [PATCH] chore: make the patricia_key and class_hash macros self contained --- crates/blockifier/src/bouncer_test.rs | 2 +- crates/blockifier/src/concurrency/test_utils.rs | 2 +- crates/blockifier/src/test_utils/struct_impls.rs | 2 +- crates/blockifier/src/transaction/objects_test.rs | 2 +- .../blockifier_reexecution/src/state_reader/rpc_https_test.rs | 2 +- crates/blockifier_reexecution/src/state_reader/utils.rs | 2 +- crates/mempool/src/mempool_test.rs | 2 +- crates/mempool/tests/flow_test.rs | 2 +- crates/native_blockifier/src/py_block_executor_test.rs | 2 +- crates/native_blockifier/src/py_test_utils.rs | 2 +- crates/papyrus_execution/src/lib.rs | 2 +- crates/papyrus_execution/src/testing_instances.rs | 2 +- crates/papyrus_rpc/src/test_utils.rs | 2 +- crates/starknet_api/src/core.rs | 4 ++-- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index 6973eae1fed..fae063b3647 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -6,7 +6,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use rstest::rstest; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; use starknet_api::transaction::Fee; -use starknet_api::{class_hash, contract_address, felt, patricia_key, storage_key}; +use starknet_api::{class_hash, contract_address, patricia_key, storage_key}; use super::BouncerConfig; use crate::blockifier::transaction_executor::TransactionExecutorError; diff --git a/crates/blockifier/src/concurrency/test_utils.rs b/crates/blockifier/src/concurrency/test_utils.rs index 87722b11713..a8c8b92871f 100644 --- a/crates/blockifier/src/concurrency/test_utils.rs +++ b/crates/blockifier/src/concurrency/test_utils.rs @@ -1,6 +1,6 @@ use rstest::fixture; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; -use starknet_api::{class_hash, contract_address, felt, patricia_key}; +use starknet_api::{class_hash, contract_address, patricia_key}; use crate::concurrency::versioned_state::{ThreadSafeVersionedState, VersionedState}; use crate::context::BlockContext; diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index ca373e5ba49..46dbdc4f5c7 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -6,7 +6,7 @@ use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp, NonzeroGasPric use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::hash::StarkHash; use starknet_api::transaction::{Fee, TransactionHash, TransactionVersion}; -use starknet_api::{calldata, contract_address, felt, patricia_key}; +use starknet_api::{calldata, contract_address, patricia_key}; use starknet_types_core::felt::Felt; use super::update_json_value; diff --git a/crates/blockifier/src/transaction/objects_test.rs b/crates/blockifier/src/transaction/objects_test.rs index a5bd07b8f93..bcbdd26ef16 100644 --- a/crates/blockifier/src/transaction/objects_test.rs +++ b/crates/blockifier/src/transaction/objects_test.rs @@ -2,7 +2,7 @@ use rstest::rstest; use starknet_api::core::{ClassHash, ContractAddress, EthAddress, PatriciaKey}; use starknet_api::state::StorageKey; use starknet_api::transaction::L2ToL1Payload; -use starknet_api::{class_hash, felt, patricia_key}; +use starknet_api::{class_hash, patricia_key}; use starknet_types_core::felt::Felt; use crate::execution::call_info::{ diff --git a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs index 73b546cde21..fb2565a5d45 100644 --- a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs @@ -3,10 +3,10 @@ use blockifier::blockifier::block::BlockInfo; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::block::{BlockNumber, StarknetVersion}; +use starknet_api::class_hash; use starknet_api::core::ClassHash; use starknet_api::test_utils::read_json_file; use starknet_api::transaction::Transaction; -use starknet_api::{class_hash, felt}; use starknet_core::types::ContractClass::{Legacy, Sierra}; use crate::state_reader::compile::legacy_to_contract_class_v0; diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 4ca8df129e1..6d519ec894b 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -4,7 +4,7 @@ use indexmap::IndexMap; use papyrus_execution::{ETH_FEE_CONTRACT_ADDRESS, STRK_FEE_CONTRACT_ADDRESS}; use starknet_api::core::{ChainId, ContractAddress, PatriciaKey}; use starknet_api::transaction::{Transaction, TransactionHash}; -use starknet_api::{contract_address, felt, patricia_key}; +use starknet_api::{contract_address, patricia_key}; use starknet_gateway::config::RpcStateReaderConfig; use crate::state_reader::test_state_reader::ReexecutionResult; diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index ac1426e22a1..6c1c1762ad2 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -2,7 +2,7 @@ use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::core::{ContractAddress, PatriciaKey}; use starknet_api::executable_transaction::Transaction; -use starknet_api::{contract_address, felt, invoke_tx_args, nonce, patricia_key}; +use starknet_api::{contract_address, invoke_tx_args, nonce, patricia_key}; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::AddTransactionArgs; diff --git a/crates/mempool/tests/flow_test.rs b/crates/mempool/tests/flow_test.rs index 4caf19cd9c6..b396c4f1282 100644 --- a/crates/mempool/tests/flow_test.rs +++ b/crates/mempool/tests/flow_test.rs @@ -1,6 +1,6 @@ use rstest::{fixture, rstest}; use starknet_api::core::{ContractAddress, PatriciaKey}; -use starknet_api::{contract_address, felt, invoke_tx_args, nonce, patricia_key}; +use starknet_api::{contract_address, invoke_tx_args, nonce, patricia_key}; use starknet_mempool::add_tx_input; use starknet_mempool::mempool::Mempool; use starknet_mempool::test_utils::{ diff --git a/crates/native_blockifier/src/py_block_executor_test.rs b/crates/native_blockifier/src/py_block_executor_test.rs index 965a30a204b..4a62edd47ee 100644 --- a/crates/native_blockifier/src/py_block_executor_test.rs +++ b/crates/native_blockifier/src/py_block_executor_test.rs @@ -6,8 +6,8 @@ use blockifier::state::state_api::StateReader; use cached::Cached; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use pretty_assertions::assert_eq; +use starknet_api::class_hash; use starknet_api::core::ClassHash; -use starknet_api::{class_hash, felt}; use starknet_types_core::felt::Felt; use crate::py_block_executor::{PyBlockExecutor, PyOsConfig}; diff --git a/crates/native_blockifier/src/py_test_utils.rs b/crates/native_blockifier/src/py_test_utils.rs index 0e664237906..2050bd3b7fa 100644 --- a/crates/native_blockifier/src/py_test_utils.rs +++ b/crates/native_blockifier/src/py_test_utils.rs @@ -3,8 +3,8 @@ use std::collections::HashMap; use blockifier::execution::contract_class::ContractClassV0; use blockifier::state::cached_state::CachedState; use blockifier::test_utils::dict_state_reader::DictStateReader; +use starknet_api::class_hash; use starknet_api::core::ClassHash; -use starknet_api::{class_hash, felt}; pub const TOKEN_FOR_TESTING_CLASS_HASH: &str = "0x30"; // This package is run within the StarkWare repository build directory. diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index 8f1c68831f7..2f8645cd397 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -75,7 +75,7 @@ use starknet_api::transaction::{ TransactionVersion, }; use starknet_api::transaction_hash::get_transaction_hash; -use starknet_api::{contract_address, felt, patricia_key, StarknetApiError}; +use starknet_api::{contract_address, patricia_key, StarknetApiError}; use state_reader::ExecutionStateReader; use tracing::trace; diff --git a/crates/papyrus_execution/src/testing_instances.rs b/crates/papyrus_execution/src/testing_instances.rs index 7d464ccf3f3..df18279dde6 100644 --- a/crates/papyrus_execution/src/testing_instances.rs +++ b/crates/papyrus_execution/src/testing_instances.rs @@ -9,7 +9,7 @@ use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; use starknet_api::execution_resources::ExecutionResources; use starknet_api::transaction::{Calldata, EventContent, Fee, MessageToL1}; -use starknet_api::{contract_address, felt, patricia_key}; +use starknet_api::{contract_address, patricia_key}; use starknet_types_core::felt::Felt; use crate::objects::{ diff --git a/crates/papyrus_rpc/src/test_utils.rs b/crates/papyrus_rpc/src/test_utils.rs index d3c19e4fe2c..713093192c5 100644 --- a/crates/papyrus_rpc/src/test_utils.rs +++ b/crates/papyrus_rpc/src/test_utils.rs @@ -15,7 +15,7 @@ use regex::Regex; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use starknet_api::core::{ChainId, ContractAddress, PatriciaKey}; -use starknet_api::{contract_address, felt, patricia_key}; +use starknet_api::{contract_address, patricia_key}; use starknet_client::reader::PendingData; use starknet_client::writer::MockStarknetWriter; use strum::IntoEnumIterator; diff --git a/crates/starknet_api/src/core.rs b/crates/starknet_api/src/core.rs index bb8100d238c..83d84678bcf 100644 --- a/crates/starknet_api/src/core.rs +++ b/crates/starknet_api/src/core.rs @@ -373,7 +373,7 @@ impl Debug for PatriciaKey { #[macro_export] macro_rules! patricia_key { ($s:expr) => { - PatriciaKey::try_from(felt!($s)).unwrap() + PatriciaKey::try_from($crate::felt!($s)).unwrap() }; } @@ -382,7 +382,7 @@ macro_rules! patricia_key { #[macro_export] macro_rules! class_hash { ($s:expr) => { - ClassHash(felt!($s)) + ClassHash($crate::felt!($s)) }; }