From ab8d58397b67d80f7929c528483ff5f11ec5fd9a Mon Sep 17 00:00:00 2001 From: Yael Doweck Date: Wed, 4 Dec 2024 16:28:36 +0200 Subject: [PATCH] chore(starknet_api): shorten executable_transaction usage path --- crates/starknet_api/src/transaction.rs | 30 ++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/starknet_api/src/transaction.rs b/crates/starknet_api/src/transaction.rs index f096a2695d..77d9b4747f 100644 --- a/crates/starknet_api/src/transaction.rs +++ b/crates/starknet_api/src/transaction.rs @@ -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"] @@ -116,20 +116,18 @@ impl Transaction { } } -impl From for Transaction { - fn from(tx: crate::executable_transaction::Transaction) -> Self { +impl From 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) } }, @@ -137,16 +135,16 @@ impl From for Transaction { } } -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.