Skip to content

Commit

Permalink
chore(blockifier): enforce_fee() impl by api::executable_transaction:…
Browse files Browse the repository at this point in the history
…:AccountTransaction
  • Loading branch information
avivg-starkware committed Dec 2, 2024
1 parent 8fda3f9 commit 3444829
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 1 addition & 5 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,7 @@ impl<U: UpdatableState> ExecutableTransaction<U> for AccountTransaction {

impl TransactionInfoCreator for AccountTransaction {
fn create_tx_info(&self) -> TransactionInfo {
match &self.tx {
Transaction::Declare(tx) => tx.create_tx_info(self.only_query),
Transaction::DeployAccount(tx) => tx.create_tx_info(self.only_query),
Transaction::Invoke(tx) => tx.create_tx_info(self.only_query),
}
self.tx.create_tx_info(self.only_query)
}
}

Expand Down
16 changes: 16 additions & 0 deletions crates/blockifier/src/transaction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::contract_class::EntryPointType;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress};
use starknet_api::executable_transaction::{
AccountTransaction,
DeclareTransaction,
DeployAccountTransaction,
InvokeTransaction,
Expand Down Expand Up @@ -179,6 +180,16 @@ impl TransactionInfoCreator for L1HandlerTransaction {
}
}

impl TransactionInfoCreatorInner for AccountTransaction {
fn create_tx_info(&self, only_query: bool) -> TransactionInfo {
match self {
Self::Declare(tx) => tx.create_tx_info(only_query),
Self::DeployAccount(tx) => tx.create_tx_info(only_query),
Self::Invoke(tx) => tx.create_tx_info(only_query),
}
}
}

impl<S: State> Executable<S> for DeclareTransaction {
fn run_execute(
&self,
Expand Down Expand Up @@ -393,6 +404,11 @@ impl TransactionInfoCreatorInner for InvokeTransaction {
}
}

/// Determines whether the fee should be enforced for the given transaction.
pub fn enforce_fee(tx: &AccountTransaction, only_query: bool) -> bool {
tx.create_tx_info(only_query).enforce_fee()
}

/// Attempts to declare a contract class by setting the contract class in the state with the
/// specified class hash.
fn try_declare<S: State>(
Expand Down

0 comments on commit 3444829

Please sign in to comment.