From a7457ea221347b860dcd3fe7b281c7c9633bb09e Mon Sep 17 00:00:00 2001 From: Aviv Greenburg Date: Tue, 12 Nov 2024 18:21:04 +0200 Subject: [PATCH] chore(blockifier): consider slightly different implementation of account tx getters --- .../src/transaction/account_transaction.rs | 25 ++----------------- .../src/executable_transaction.rs | 19 +++++++------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 3879b8f9cc..382fdbe4e8 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -96,19 +96,6 @@ macro_rules! implement_tx_getter_calls { $(pub fn $field(&self) -> $field_type { self.tx.$field() })* -}; -} - -macro_rules! implement_account_tx_inner_getters { - ($(($field:ident, $field_type:ty)),*) => { - $(pub fn $field(&self) -> $field_type { - match &self.tx { - // TODO(AvivG): Consider moving some of the logic to the Transaction enum. - Transaction::Declare(tx) => tx.tx.$field().clone(), - Transaction::DeployAccount(tx) => tx.tx.$field().clone(), - Transaction::Invoke(tx) => tx.tx.$field().clone(), - } - })* }; } @@ -138,12 +125,7 @@ impl From for AccountTransaction { impl HasRelatedFeeType for AccountTransaction { fn version(&self) -> TransactionVersion { - // TODO(AvivG): Consider moving some of the logic to the Transaction enum. - match &self.tx { - Transaction::Declare(tx) => tx.tx.version(), - Transaction::DeployAccount(tx) => tx.tx.version(), - Transaction::Invoke(tx) => tx.tx.version(), - } + self.tx.version() } fn is_l1_handler(&self) -> bool { @@ -156,10 +138,7 @@ impl AccountTransaction { (resource_bounds, ValidResourceBounds), (tip, Tip), (sender_address, ContractAddress), - (tx_hash, TransactionHash) - ); - - implement_account_tx_inner_getters!( + (tx_hash, TransactionHash), (signature, TransactionSignature), (nonce, Nonce), (nonce_data_availability_mode, DataAvailabilityMode), diff --git a/crates/starknet_api/src/executable_transaction.rs b/crates/starknet_api/src/executable_transaction.rs index ec0a3557fa..fe3e20f9f4 100644 --- a/crates/starknet_api/src/executable_transaction.rs +++ b/crates/starknet_api/src/executable_transaction.rs @@ -60,7 +60,16 @@ pub enum AccountTransaction { } impl AccountTransaction { - implement_account_tx_inner_getters!((resource_bounds, ValidResourceBounds), (tip, Tip)); + implement_account_tx_inner_getters!( + (resource_bounds, ValidResourceBounds), + (tip, Tip), + (signature, TransactionSignature), + (nonce, Nonce), + (nonce_data_availability_mode, DataAvailabilityMode), + (fee_data_availability_mode, DataAvailabilityMode), + (paymaster_data, PaymasterData), + (version, TransactionVersion) + ); pub fn contract_address(&self) -> ContractAddress { match self { @@ -74,14 +83,6 @@ impl AccountTransaction { self.contract_address() } - pub fn nonce(&self) -> Nonce { - match self { - AccountTransaction::Declare(tx_data) => tx_data.tx.nonce(), - AccountTransaction::DeployAccount(tx_data) => tx_data.tx.nonce(), - AccountTransaction::Invoke(tx_data) => tx_data.tx.nonce(), - } - } - pub fn tx_hash(&self) -> TransactionHash { match self { AccountTransaction::Declare(tx_data) => tx_data.tx_hash,