Skip to content

Commit

Permalink
chore(starknet_api): move transaction constants to snapi
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Nov 17, 2024
1 parent 863c886 commit 8fa9411
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/src/abi/abi_utils_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use starknet_api::core::EntryPointSelector;
use starknet_api::felt;
use starknet_api::transaction::constants as tx_constants;

use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants as abi_constants;
use crate::transaction::constants as tx_constants;

#[test]
fn test_selector_from_name() {
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/concurrency/worker_logic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Mutex;
use rstest::rstest;
use starknet_api::core::{ContractAddress, Nonce};
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME;
use starknet_api::transaction::fields::{ContractAddressSalt, Fee, ValidResourceBounds};
use starknet_api::transaction::TransactionVersion;
use starknet_api::{contract_address, declare_tx_args, felt, invoke_tx_args, nonce, storage_key};
Expand Down Expand Up @@ -32,7 +33,6 @@ use crate::test_utils::{
TEST_ERC20_CONTRACT_ADDRESS2,
};
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::constants::DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME;
use crate::transaction::objects::HasRelatedFeeType;
use crate::transaction::test_utils::{
account_invoke_tx,
Expand Down
16 changes: 8 additions & 8 deletions crates/blockifier/src/execution/stack_trace_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ use starknet_api::core::{
Nonce,
};
use starknet_api::executable_transaction::AccountTransaction as Transaction;
use starknet_api::transaction::constants::{
DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME,
EXECUTE_ENTRY_POINT_NAME,
FELT_TRUE,
VALIDATE_DECLARE_ENTRY_POINT_NAME,
VALIDATE_DEPLOY_ENTRY_POINT_NAME,
VALIDATE_ENTRY_POINT_NAME,
};
use starknet_api::transaction::fields::{
ContractAddressSalt,
Fee,
Expand Down Expand Up @@ -37,14 +45,6 @@ use crate::execution::syscalls::hint_processor::ENTRYPOINT_FAILED_ERROR;
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::initial_test_state::{fund_account, test_state};
use crate::test_utils::{create_calldata, CairoVersion, BALANCE};
use crate::transaction::constants::{
DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME,
EXECUTE_ENTRY_POINT_NAME,
FELT_TRUE,
VALIDATE_DECLARE_ENTRY_POINT_NAME,
VALIDATE_DEPLOY_ENTRY_POINT_NAME,
VALIDATE_ENTRY_POINT_NAME,
};
use crate::transaction::test_utils::{
account_invoke_tx,
block_context,
Expand Down
3 changes: 1 addition & 2 deletions crates/blockifier/src/fee/receipt_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rstest::{fixture, rstest};
use starknet_api::execution_resources::GasVector;
use starknet_api::transaction::fields::GasVectorComputationMode;
use starknet_api::transaction::L2ToL1Payload;
use starknet_api::transaction::{constants, L2ToL1Payload};
use starknet_api::{invoke_tx_args, nonce};
use starknet_types_core::felt::Felt;

Expand All @@ -24,7 +24,6 @@ use crate::state::cached_state::StateChangesCount;
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::{create_calldata, create_trivial_calldata, CairoVersion, BALANCE};
use crate::transaction::constants;
use crate::transaction::objects::HasRelatedFeeType;
use crate::transaction::test_utils::{
account_invoke_tx,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/test_utils/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use starknet_api::executable_transaction::{
InvokeTransaction as ExecutableInvokeTransaction,
};
use starknet_api::test_utils::invoke::InvokeTxArgs;
use starknet_api::transaction::constants::EXECUTE_ENTRY_POINT_NAME;
use starknet_api::transaction::{InvokeTransaction, InvokeTransactionV0, TransactionVersion};

use crate::abi::abi_utils::selector_from_name;
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::constants::EXECUTE_ENTRY_POINT_NAME;

pub fn invoke_tx(invoke_args: InvokeTxArgs) -> AccountTransaction {
let tx_hash = invoke_args.tx_hash;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/test_utils/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cached::proc_macro::cached;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use starknet_api::core::ContractAddress;
use starknet_api::test_utils::invoke::InvokeTxArgs;
use starknet_api::transaction::constants;
use starknet_api::{calldata, felt};

use crate::abi::abi_utils::{get_fee_token_var_address, selector_from_name};
Expand All @@ -13,7 +14,6 @@ use crate::execution::entry_point::{CallEntryPoint, EntryPointExecutionContext};
use crate::state::state_api::State;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::BALANCE;
use crate::transaction::constants;
use crate::transaction::objects::FeeType;
use crate::transaction::test_utils::account_invoke_tx;

Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/test_utils/transfers_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use starknet_api::core::ContractAddress;
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use starknet_api::transaction::fields::Fee;
use starknet_api::transaction::TransactionVersion;
use starknet_api::{calldata, felt, invoke_tx_args};
Expand All @@ -17,7 +18,6 @@ use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::invoke::invoke_tx;
use crate::test_utils::{CairoVersion, BALANCE, MAX_FEE};
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use crate::transaction::transaction_execution::Transaction;

const N_ACCOUNTS: u16 = 10000;
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod account_transaction;
pub mod constants;
#[cfg(test)]
pub mod error_format_test;
pub mod errors;
Expand Down
3 changes: 1 addition & 2 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use starknet_api::transaction::fields::{
TransactionSignature,
ValidResourceBounds,
};
use starknet_api::transaction::{TransactionHash, TransactionVersion};
use starknet_api::transaction::{constants, TransactionHash, TransactionVersion};
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::selector_from_name;
Expand All @@ -47,7 +47,6 @@ use crate::fee::receipt::TransactionReceipt;
use crate::retdata;
use crate::state::cached_state::{StateChanges, TransactionalState};
use crate::state::state_api::{State, StateReader, UpdatableState};
use crate::transaction::constants;
use crate::transaction::errors::{
TransactionExecutionError,
TransactionFeeError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use starknet_api::hash::StarkHash;
use starknet_api::state::StorageKey;
use starknet_api::test_utils::invoke::InvokeTxArgs;
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use starknet_api::transaction::fields::{
AllResourceBounds,
Calldata,
Expand Down Expand Up @@ -82,7 +83,6 @@ use crate::test_utils::{
MAX_FEE,
};
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use crate::transaction::objects::{FeeType, HasRelatedFeeType, TransactionInfoCreator};
use crate::transaction::test_utils::{
account_invoke_tx,
Expand Down
3 changes: 1 addition & 2 deletions crates/blockifier/src/transaction/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use starknet_api::transaction::fields::{
TransactionSignature,
ValidResourceBounds,
};
use starknet_api::transaction::TransactionVersion;
use starknet_api::transaction::{constants, TransactionVersion};
use starknet_api::{calldata, declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args};
use starknet_types_core::felt::Felt;
use strum::IntoEnumIterator;
Expand Down Expand Up @@ -43,7 +43,6 @@ use crate::test_utils::{
MAX_FEE,
};
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::constants;
use crate::transaction::objects::{FeeType, TransactionExecutionInfo, TransactionExecutionResult};
use crate::transaction::transaction_types::TransactionType;
use crate::transaction::transactions::ExecutableTransaction;
Expand Down
8 changes: 6 additions & 2 deletions crates/blockifier/src/transaction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ use starknet_api::transaction::fields::{
Fee,
TransactionSignature,
};
use starknet_api::transaction::{DeclareTransactionV2, DeclareTransactionV3, TransactionVersion};
use starknet_api::transaction::{
constants,
DeclareTransactionV2,
DeclareTransactionV3,
TransactionVersion,
};

use crate::abi::abi_utils::selector_from_name;
use crate::context::{BlockContext, TransactionContext};
Expand All @@ -30,7 +35,6 @@ use crate::execution::execution_utils::execute_deployment;
use crate::state::cached_state::TransactionalState;
use crate::state::errors::StateError;
use crate::state::state_api::{State, UpdatableState};
use crate::transaction::constants;
use crate::transaction::errors::TransactionExecutionError;
use crate::transaction::objects::{
CommonAccountFields,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use starknet_api::transaction::fields::{
ValidResourceBounds,
};
use starknet_api::transaction::{
constants,
EventContent,
EventData,
EventKey,
Expand Down Expand Up @@ -117,7 +118,6 @@ use crate::test_utils::{
TEST_SEQUENCER_ADDRESS,
};
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::constants;
use crate::transaction::errors::{
TransactionExecutionError,
TransactionFeeError,
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_api/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use crate::StarknetApiError;
#[path = "transaction_test.rs"]
mod transaction_test;

pub mod constants;
pub mod fields;

// TODO(Noa, 14/11/2023): Replace QUERY_VERSION_BASE_BIT with a lazy calculation.
Expand Down

0 comments on commit 8fa9411

Please sign in to comment.