Skip to content

Commit

Permalink
chore(blockifier): consider slightly different implementation of acco…
Browse files Browse the repository at this point in the history
…unt tx getters
  • Loading branch information
avivg-starkware committed Nov 17, 2024
1 parent a3f457a commit a7457ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
25 changes: 2 additions & 23 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
})*
};
}

Expand Down Expand Up @@ -138,12 +125,7 @@ impl From<InvokeTransaction> 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 {
Expand All @@ -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),
Expand Down
19 changes: 10 additions & 9 deletions crates/starknet_api/src/executable_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit a7457ea

Please sign in to comment.