Skip to content

Commit

Permalink
chore: make the patricia_key and class_hash macros self contained
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Oct 23, 2024
1 parent bbecffb commit 0ccf6f3
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/src/bouncer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/concurrency/test_utils.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/test_utils/struct_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/transaction/objects_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier_reexecution/src/state_reader/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/mempool/tests/flow_test.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion crates/native_blockifier/src/py_block_executor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion crates/native_blockifier/src/py_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/papyrus_execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/papyrus_execution/src/testing_instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion crates/papyrus_rpc/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_api/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
}

Expand All @@ -382,7 +382,7 @@ macro_rules! patricia_key {
#[macro_export]
macro_rules! class_hash {
($s:expr) => {
ClassHash(felt!($s))
ClassHash($crate::felt!($s))
};
}

Expand Down

0 comments on commit 0ccf6f3

Please sign in to comment.