Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Change DeprecatedAccountTxContext fields from private to public. (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
NirLevi-starkware authored Oct 4, 2023
1 parent 7387447 commit 8766f79
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 54 deletions.
36 changes: 14 additions & 22 deletions crates/blockifier/src/transaction/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::transaction::errors::TransactionExecutionError;

pub type TransactionExecutionResult<T> = Result<T, TransactionExecutionError>;

macro_rules! implement_inner_account_tx_context_getter_calls {
macro_rules! implement_getters {
($(($field:ident, $field_type:ty)),*) => {
$(pub fn $field(&self) -> $field_type {
match self{
Expand All @@ -34,9 +34,8 @@ pub enum AccountTransactionContext {
}

impl AccountTransactionContext {
implement_inner_account_tx_context_getter_calls!(
implement_getters!(
(transaction_hash, TransactionHash),
(max_fee, Fee),
(version, TransactionVersion),
(nonce, Nonce),
(sender_address, ContractAddress)
Expand All @@ -48,6 +47,12 @@ impl AccountTransactionContext {
}
}

pub fn max_fee(&self) -> Fee {
match self {
Self::Deprecated(context) => context.max_fee,
}
}

pub fn is_v0(&self) -> bool {
self.version() == TransactionVersion::ZERO
}
Expand All @@ -66,25 +71,12 @@ impl HasRelatedFeeType for AccountTransactionContext {
/// Contains the account information of the transaction (outermost call).
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct DeprecatedAccountTransactionContext {
transaction_hash: TransactionHash,
max_fee: Fee,
version: TransactionVersion,
signature: TransactionSignature,
nonce: Nonce,
sender_address: ContractAddress,
}

impl DeprecatedAccountTransactionContext {
pub fn new(
transaction_hash: TransactionHash,
max_fee: Fee,
version: TransactionVersion,
signature: TransactionSignature,
nonce: Nonce,
sender_address: ContractAddress,
) -> Self {
Self { transaction_hash, max_fee, version, signature, nonce, sender_address }
}
pub transaction_hash: TransactionHash,
pub max_fee: Fee,
pub version: TransactionVersion,
pub signature: TransactionSignature,
pub nonce: Nonce,
pub sender_address: ContractAddress,
}

/// Contains the information gathered by the execution of a transaction.
Expand Down
64 changes: 32 additions & 32 deletions crates/blockifier/src/transaction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ impl DeclareTransaction {
pub fn get_account_tx_context(&self) -> AccountTransactionContext {
match self.tx.version() {
TransactionVersion::ZERO | TransactionVersion::ONE | TransactionVersion::TWO => {
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext::new(
self.tx_hash(),
self.max_fee(),
self.tx.version(),
self.tx.signature(),
self.tx.nonce(),
self.tx.sender_address(),
))
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext {
transaction_hash: self.tx_hash(),
max_fee: self.max_fee(),
version: self.tx.version(),
signature: self.tx.signature(),
nonce: self.tx.nonce(),
sender_address: self.tx.sender_address(),
})
}
_ => unreachable!("Not implemented for tx version {:?}", self.tx.version()),
}
Expand Down Expand Up @@ -267,14 +267,14 @@ impl DeployAccountTransaction {
pub fn get_account_tx_context(&self) -> AccountTransactionContext {
match self.tx.version() {
TransactionVersion::ONE => {
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext::new(
self.tx_hash,
self.max_fee(),
self.tx.version(),
self.tx.signature(),
self.tx.nonce(),
self.contract_address,
))
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext {
transaction_hash: self.tx_hash,
max_fee: self.max_fee(),
version: self.tx.version(),
signature: self.tx.signature(),
nonce: self.tx.nonce(),
sender_address: self.contract_address,
})
}
_ => unreachable!("Not implemented for tx version {:?}", self.tx.version()),
}
Expand Down Expand Up @@ -337,14 +337,14 @@ impl InvokeTransaction {
pub fn get_account_tx_context(&self) -> AccountTransactionContext {
match self.tx.version() {
TransactionVersion::ZERO | TransactionVersion::ONE => {
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext::new(
self.tx_hash,
self.max_fee(),
self.tx.version(),
self.tx.signature(),
self.tx.nonce(),
self.tx.sender_address(),
))
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext {
transaction_hash: self.tx_hash,
max_fee: self.max_fee(),
version: self.tx.version(),
signature: self.tx.signature(),
nonce: self.tx.nonce(),
sender_address: self.tx.sender_address(),
})
}
_ => unreachable!("Not implemented for tx version {:?}", self.tx.version()),
}
Expand Down Expand Up @@ -436,13 +436,13 @@ impl<S: State> Executable<S> for L1HandlerTransaction {

impl L1HandlerTransaction {
pub fn get_account_tx_context(&self) -> AccountTransactionContext {
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext::new(
self.tx_hash,
Fee::default(),
self.tx.version,
TransactionSignature::default(),
self.tx.nonce,
self.tx.contract_address,
))
AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext {
transaction_hash: self.tx_hash,
max_fee: Fee::default(),
version: self.tx.version,
signature: TransactionSignature::default(),
nonce: self.tx.nonce,
sender_address: self.tx.contract_address,
})
}
}

0 comments on commit 8766f79

Please sign in to comment.