From 33660365e73c48da0f39ea794736985577d2cfb1 Mon Sep 17 00:00:00 2001 From: Aviv Greenburg Date: Sun, 1 Dec 2024 14:32:37 +0200 Subject: [PATCH] chore(blockifier): enforce_fee() impl by api::executable_transaction::AccountTransaction --- .../src/transaction/account_transaction.rs | 6 +----- .../blockifier/src/transaction/transactions.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) 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..effa40574f 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,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(