From 15d22a6da24da89dafbb5b35228102cc040dceaa Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Mon, 19 Aug 2024 20:38:22 +0300 Subject: [PATCH] chore: define try from snapi executable transaction for account tx --- .../src/transaction/account_transaction.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 2395274b70..73a19e4425 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -76,6 +76,29 @@ pub enum AccountTransaction { Invoke(InvokeTransaction), } +impl TryFrom for AccountTransaction { + type Error = TransactionExecutionError; + + fn try_from( + executable_transaction: starknet_api::executable_transaction::Transaction, + ) -> Result { + match executable_transaction { + starknet_api::executable_transaction::Transaction::Declare(declare_tx) => { + Ok(Self::Declare(declare_tx.try_into()?)) + } + starknet_api::executable_transaction::Transaction::DeployAccount(deploy_account_tx) => { + Ok(Self::DeployAccount(DeployAccountTransaction { + tx: deploy_account_tx, + only_query: false, + })) + } + starknet_api::executable_transaction::Transaction::Invoke(invoke_tx) => { + Ok(Self::Invoke(InvokeTransaction { tx: invoke_tx, only_query: false })) + } + } + } +} + impl HasRelatedFeeType for AccountTransaction { fn version(&self) -> TransactionVersion { match self {