diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 7bd74809889..f34e83ce2f1 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -91,23 +91,10 @@ pub struct AccountTransaction { only_query: bool, } -macro_rules! implement_tx_getter_calls { - ($(($field:ident, $field_type:ty)),*) => { - $(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(), - } + self.tx.$field() })* }; } @@ -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 { @@ -157,11 +139,13 @@ impl AccountTransaction { (nonce, Nonce), (nonce_data_availability_mode, DataAvailabilityMode), (fee_data_availability_mode, DataAvailabilityMode), - (paymaster_data, PaymasterData) + (paymaster_data, PaymasterData), + (sender_address, ContractAddress), + (tx_hash, TransactionHash), + (resource_bounds, ValidResourceBounds), + (tip, Tip) ); - implement_tx_getter_calls!((resource_bounds, ValidResourceBounds), (tip, Tip)); - pub fn new(tx: starknet_api::executable_transaction::AccountTransaction) -> Self { AccountTransaction { tx, only_query: false } } @@ -170,10 +154,6 @@ impl AccountTransaction { AccountTransaction { tx, only_query: true } } - pub fn sender_address(&self) -> ContractAddress { - self.tx.sender_address() - } - pub fn class_hash(&self) -> Option { match &self.tx { Transaction::Declare(tx) => Some(tx.tx.class_hash()), @@ -237,17 +217,7 @@ impl AccountTransaction { } pub fn signature_length(&self) -> usize { - let signature = match &self.tx { - Transaction::Declare(tx) => tx.signature(), - Transaction::DeployAccount(tx) => tx.signature(), - Transaction::Invoke(tx) => tx.signature(), - }; - - signature.0.len() - } - - pub fn tx_hash(&self) -> TransactionHash { - self.tx.tx_hash() + self.signature().0.len() } pub fn enforce_fee(&self) -> bool { diff --git a/crates/starknet_api/src/executable_transaction.rs b/crates/starknet_api/src/executable_transaction.rs index ec0a3557fa6..81dc5269dba 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!( + (signature, TransactionSignature), + (nonce, Nonce), + (resource_bounds, ValidResourceBounds), + (tip, Tip), + (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, @@ -151,8 +152,14 @@ impl DeclareTransaction { (nonce, Nonce), (sender_address, ContractAddress), (signature, TransactionSignature), - (version, TransactionVersion) + (version, TransactionVersion), + (resource_bounds, ValidResourceBounds), + (tip, Tip), + (nonce_data_availability_mode, DataAvailabilityMode), + (fee_data_availability_mode, DataAvailabilityMode), + (paymaster_data, PaymasterData) ); + implement_getter_calls!((tx_hash, TransactionHash)); pub fn create( declare_tx: crate::transaction::DeclareTransaction,