Skip to content

Commit

Permalink
chore(starknet_api): shorten executable_transaction usage path
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Dec 5, 2024
1 parent 6c11734 commit 605abe6
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions crates/starknet_api/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::transaction_hash::{
get_invoke_transaction_v3_hash,
get_l1_handler_transaction_hash,
};
use crate::StarknetApiError;
use crate::{executable_transaction, StarknetApiError};

#[cfg(test)]
#[path = "transaction_test.rs"]
Expand Down Expand Up @@ -116,37 +116,35 @@ impl Transaction {
}
}

impl From<crate::executable_transaction::Transaction> for Transaction {
fn from(tx: crate::executable_transaction::Transaction) -> Self {
impl From<executable_transaction::Transaction> for Transaction {
fn from(tx: executable_transaction::Transaction) -> Self {
match tx {
crate::executable_transaction::Transaction::L1Handler(tx) => {
Transaction::L1Handler(tx.tx)
}
crate::executable_transaction::Transaction::Account(account_tx) => match account_tx {
crate::executable_transaction::AccountTransaction::Declare(tx) => {
executable_transaction::Transaction::L1Handler(tx) => Transaction::L1Handler(tx.tx),
executable_transaction::Transaction::Account(account_tx) => match account_tx {
executable_transaction::AccountTransaction::Declare(tx) => {
Transaction::Declare(tx.tx)
}
crate::executable_transaction::AccountTransaction::DeployAccount(tx) => {
executable_transaction::AccountTransaction::DeployAccount(tx) => {
Transaction::DeployAccount(tx.tx)
}
crate::executable_transaction::AccountTransaction::Invoke(tx) => {
executable_transaction::AccountTransaction::Invoke(tx) => {
Transaction::Invoke(tx.tx)
}
},
}
}
}

impl From<(Transaction, TransactionHash)> for crate::executable_transaction::Transaction {
impl From<(Transaction, TransactionHash)> for executable_transaction::Transaction {
fn from((tx, tx_hash): (Transaction, TransactionHash)) -> Self {
match tx {
Transaction::Invoke(tx) => crate::executable_transaction::Transaction::Account(
crate::executable_transaction::AccountTransaction::Invoke(
crate::executable_transaction::InvokeTransaction { tx, tx_hash },
Transaction::Invoke(tx) => executable_transaction::Transaction::Account(
executable_transaction::AccountTransaction::Invoke(
executable_transaction::InvokeTransaction { tx, tx_hash },
),
),
Transaction::L1Handler(tx) => crate::executable_transaction::Transaction::L1Handler(
crate::executable_transaction::L1HandlerTransaction {
Transaction::L1Handler(tx) => executable_transaction::Transaction::L1Handler(
executable_transaction::L1HandlerTransaction {
tx,
tx_hash,
// TODO (yael 1/12/2024): The paid fee should be an input from the l1_handler.
Expand Down

0 comments on commit 605abe6

Please sign in to comment.