diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 2c06fda963..3d87f93c85 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -768,11 +768,7 @@ impl ExecutableTransaction 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) } } diff --git a/crates/blockifier/src/transaction/transactions.rs b/crates/blockifier/src/transaction/transactions.rs index 9005f73e4d..106423c1c3 100644 --- a/crates/blockifier/src/transaction/transactions.rs +++ b/crates/blockifier/src/transaction/transactions.rs @@ -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, @@ -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 Executable for DeclareTransaction { fn run_execute( &self, @@ -393,6 +404,12 @@ 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 { + // TODO(AvivG): Consider implemetation without 'create_tx_info'. + 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(