diff --git a/crates/blockifier/src/test_utils/declare.rs b/crates/blockifier/src/test_utils/declare.rs index d78f3ff06c..798c73f244 100644 --- a/crates/blockifier/src/test_utils/declare.rs +++ b/crates/blockifier/src/test_utils/declare.rs @@ -7,6 +7,7 @@ use crate::transaction::transactions::DeclareTransaction; pub fn declare_tx(declare_tx_args: DeclareTxArgs, class_info: ClassInfo) -> AccountTransaction { let tx_hash = declare_tx_args.tx_hash; let declare_tx = starknet_api::test_utils::declare::declare_tx(declare_tx_args); + let executable_declare = DeclareTransaction::new(declare_tx, tx_hash, class_info).unwrap(); - AccountTransaction::Declare(DeclareTransaction::new(declare_tx, tx_hash, class_info).unwrap()) + executable_declare.into() } diff --git a/crates/blockifier/src/test_utils/deploy_account.rs b/crates/blockifier/src/test_utils/deploy_account.rs index b48ae6a320..480762c3fb 100644 --- a/crates/blockifier/src/test_utils/deploy_account.rs +++ b/crates/blockifier/src/test_utils/deploy_account.rs @@ -24,5 +24,6 @@ pub fn deploy_account_tx( ); let executable_deploy_account_tx = DeployAccountTransaction::new(deploy_account_tx, tx_hash, contract_address); - AccountTransaction::DeployAccount(executable_deploy_account_tx) + + executable_deploy_account_tx.into() } diff --git a/crates/blockifier/src/test_utils/invoke.rs b/crates/blockifier/src/test_utils/invoke.rs index d4fff4923b..40218f1a51 100644 --- a/crates/blockifier/src/test_utils/invoke.rs +++ b/crates/blockifier/src/test_utils/invoke.rs @@ -27,5 +27,5 @@ pub fn invoke_tx(invoke_args: InvokeTxArgs) -> AccountTransaction { true => InvokeTransaction::new_for_query(invoke_tx, tx_hash), false => InvokeTransaction::new(invoke_tx, tx_hash), }; - AccountTransaction::Invoke(invoke_tx) + invoke_tx.into() } diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 271763cb74..219fc69b2e 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -77,7 +77,7 @@ mod flavors_test; mod post_execution_test; /// Represents a paid Starknet transaction. -#[derive(Clone, Debug, derive_more::From)] +#[derive(Clone, Debug)] pub enum AccountTransaction { Declare(DeclareTransaction), DeployAccount(DeployAccountTransaction), @@ -142,6 +142,24 @@ impl TryFrom for AccountTrans } } +impl From for AccountTransaction { + fn from(tx: DeclareTransaction) -> Self { + Self::Declare(tx) + } +} + +impl From for AccountTransaction { + fn from(tx: DeployAccountTransaction) -> Self { + Self::DeployAccount(tx) + } +} + +impl From for AccountTransaction { + fn from(tx: InvokeTransaction) -> Self { + Self::Invoke(tx) + } +} + impl HasRelatedFeeType for AccountTransaction { fn version(&self) -> TransactionVersion { match self { diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index abe7d11f30..3af8e29812 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -759,17 +759,16 @@ fn test_fail_declare(block_context: BlockContext, max_fee: Fee) { state.set_contract_class(class_hash, contract_class.clone().try_into().unwrap()).unwrap(); state.set_compiled_class_hash(class_hash, declare_tx.compiled_class_hash).unwrap(); let class_info = calculate_class_info_for_testing(contract_class); - let declare_account_tx = AccountTransaction::Declare( - DeclareTransaction::new( - starknet_api::transaction::DeclareTransaction::V2(DeclareTransactionV2 { - nonce: next_nonce, - ..declare_tx - }), - TransactionHash::default(), - class_info, - ) - .unwrap(), - ); + let declare_account_tx: AccountTransaction = DeclareTransaction::new( + starknet_api::transaction::DeclareTransaction::V2(DeclareTransactionV2 { + nonce: next_nonce, + ..declare_tx + }), + TransactionHash::default(), + class_info, + ) + .unwrap() + .into(); // Fail execution, assert nonce and balance are unchanged. let tx_info = declare_account_tx.create_tx_info();