Skip to content

Commit

Permalink
chore: refactor deploy account as wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Aug 1, 2024
1 parent 81ec384 commit 8d26abe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
26 changes: 19 additions & 7 deletions crates/blockifier/src/transaction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,13 @@ impl TransactionInfoCreator for DeclareTransaction {
}
#[derive(Debug, Clone)]
pub struct DeployAccountTransaction {
pub tx: starknet_api::transaction::DeployAccountTransaction,
pub tx_hash: TransactionHash,
pub contract_address: ContractAddress,
pub tx: starknet_api::executable_transaction::DeployAccountTransaction,
// Indicates the presence of the only_query bit in the version.
pub only_query: bool,
}

impl Deref for DeployAccountTransaction {
type Target = starknet_api::transaction::DeployAccountTransaction;
type Target = starknet_api::executable_transaction::DeployAccountTransaction;

fn deref(&self) -> &Self::Target {
&self.tx
Expand All @@ -301,15 +299,29 @@ impl DeployAccountTransaction {
tx_hash: TransactionHash,
contract_address: ContractAddress,
) -> Self {
Self { tx: deploy_account_tx, tx_hash, contract_address, only_query: false }
Self {
tx: starknet_api::executable_transaction::DeployAccountTransaction {
tx: deploy_account_tx,
tx_hash,
contract_address,
},
only_query: false,
}
}

pub fn new_for_query(
deploy_account_tx: starknet_api::transaction::DeployAccountTransaction,
tx_hash: TransactionHash,
contract_address: ContractAddress,
) -> Self {
Self { tx: deploy_account_tx, tx_hash, contract_address, only_query: true }
Self {
tx: starknet_api::executable_transaction::DeployAccountTransaction {
tx: deploy_account_tx,
tx_hash,
contract_address,
},
only_query: true,
}
}

pub fn tx(&self) -> &starknet_api::transaction::DeployAccountTransaction {
Expand Down Expand Up @@ -357,7 +369,7 @@ impl TransactionInfoCreator for DeployAccountTransaction {
only_query: self.only_query,
};

match &self.tx {
match &self.tx.tx {
starknet_api::transaction::DeployAccountTransaction::V1(tx) => {
TransactionInfo::Deprecated(DeprecatedTransactionInfo {
common_fields,
Expand Down
10 changes: 10 additions & 0 deletions crates/starknet_api/src/executable_transaction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ops::Deref;

use crate::core::{ContractAddress, Nonce};
use crate::state::ContractClass;
use crate::transaction::{Tip, TransactionHash};
Expand Down Expand Up @@ -68,6 +70,14 @@ pub struct DeployAccountTransaction {
pub contract_address: ContractAddress,
}

impl Deref for DeployAccountTransaction {
type Target = crate::transaction::DeployAccountTransaction;

fn deref(&self) -> &Self::Target {
&self.tx
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct InvokeTransaction {
pub tx: crate::transaction::InvokeTransaction,
Expand Down

0 comments on commit 8d26abe

Please sign in to comment.