From 3ee69381386e4af9a95691c11e1f5769f0eff84b 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 +- crates/mempool/src/mempool_test.rs | 2 +- crates/native_blockifier/src/py_block_executor_test.rs | 2 +- crates/native_blockifier/src/py_test_utils.rs | 2 +- crates/starknet_api/src/core.rs | 4 ++-- 8 files changed, 9 insertions(+), 9 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/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/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/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)) }; }