Skip to content

Commit

Permalink
refactor(transaction): add common getters to tramsaction
Browse files Browse the repository at this point in the history
  • Loading branch information
meship-starkware committed Jul 30, 2024
1 parent 0a4d9c2 commit 2f07d14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use starknet_api::calldata;
use starknet_api::core::{ContractAddress, EntryPointSelector};
use starknet_api::deprecated_contract_class::EntryPointType;
use starknet_api::transaction::{Calldata, Fee, ResourceBounds, TransactionVersion};
use starknet_api::transaction::{
Calldata,
Fee,
ResourceBounds,
TransactionHash,
TransactionVersion,
};
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::selector_from_name;
Expand Down Expand Up @@ -191,6 +197,14 @@ impl AccountTransaction {
Ok(())
}

pub fn get_transaction_hash(&self) -> &TransactionHash {
match self {
AccountTransaction::Invoke(tx) => &tx.tx_hash,
AccountTransaction::Declare(tx) => &tx.tx_hash,
AccountTransaction::DeployAccount(tx) => &tx.tx_hash,
}
}

fn check_fee_bounds(
&self,
tx_context: &TransactionContext,
Expand Down
7 changes: 7 additions & 0 deletions crates/blockifier/src/transaction/transaction_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ impl Transaction {
_ => unimplemented!(),
}
}

pub fn get_transaction_hash(tx: &Transaction) -> &TransactionHash {
match tx {
Transaction::AccountTransaction(tx) => tx.get_transaction_hash(),
Transaction::L1HandlerTransaction(tx) => &tx.tx_hash,
}
}
}

impl TransactionInfoCreator for Transaction {
Expand Down

0 comments on commit 2f07d14

Please sign in to comment.