diff --git a/crates/mempool_test_utils/src/starknet_api_test_utils.rs b/crates/mempool_test_utils/src/starknet_api_test_utils.rs index b0bb48bd02..acfc42b982 100644 --- a/crates/mempool_test_utils/src/starknet_api_test_utils.rs +++ b/crates/mempool_test_utils/src/starknet_api_test_utils.rs @@ -15,9 +15,9 @@ use starknet_api::block::GasPrice; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::executable_transaction::AccountTransaction; use starknet_api::execution_resources::GasAmount; -use starknet_api::rpc_transaction::{ContractClass, RpcDeployAccountTransactionV3, RpcTransaction}; +use starknet_api::rpc_transaction::{ContractClass, RpcTransaction}; use starknet_api::test_utils::declare::rpc_declare_tx; -use starknet_api::test_utils::deploy_account::DeployAccountTxArgs; +use starknet_api::test_utils::deploy_account::rpc_deploy_account_tx; use starknet_api::test_utils::invoke::{rpc_invoke_tx, InvokeTxArgs}; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::fields::{ @@ -28,7 +28,6 @@ use starknet_api::transaction::fields::{ TransactionSignature, ValidResourceBounds, }; -use starknet_api::transaction::TransactionVersion; use starknet_api::{declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args, nonce}; use starknet_types_core::felt::Felt; @@ -362,33 +361,6 @@ impl Contract { } } -pub fn rpc_deploy_account_tx(deploy_tx_args: DeployAccountTxArgs) -> RpcTransaction { - if deploy_tx_args.version != TransactionVersion::THREE { - panic!("Unsupported transaction version: {:?}.", deploy_tx_args.version); - } - - let ValidResourceBounds::AllResources(resource_bounds) = deploy_tx_args.resource_bounds else { - panic!("Unsupported resource bounds type: {:?}.", deploy_tx_args.resource_bounds) - }; - - starknet_api::rpc_transaction::RpcTransaction::DeployAccount( - starknet_api::rpc_transaction::RpcDeployAccountTransaction::V3( - RpcDeployAccountTransactionV3 { - resource_bounds, - tip: deploy_tx_args.tip, - contract_address_salt: deploy_tx_args.contract_address_salt, - class_hash: deploy_tx_args.class_hash, - constructor_calldata: deploy_tx_args.constructor_calldata, - nonce: deploy_tx_args.nonce, - signature: deploy_tx_args.signature, - nonce_data_availability_mode: deploy_tx_args.nonce_data_availability_mode, - fee_data_availability_mode: deploy_tx_args.fee_data_availability_mode, - paymaster_data: deploy_tx_args.paymaster_data, - }, - ), - ) -} - pub fn rpc_tx_to_json(tx: &RpcTransaction) -> String { let mut tx_json = serde_json::to_value(tx) .unwrap_or_else(|tx| panic!("Failed to serialize transaction: {tx:?}")); diff --git a/crates/starknet_api/src/test_utils/deploy_account.rs b/crates/starknet_api/src/test_utils/deploy_account.rs index 726c74ba8f..8d64aeb658 100644 --- a/crates/starknet_api/src/test_utils/deploy_account.rs +++ b/crates/starknet_api/src/test_utils/deploy_account.rs @@ -2,6 +2,11 @@ use super::NonceManager; use crate::core::{calculate_contract_address, ClassHash, ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::DeployAccountTransaction as ExecutableDeployAccountTransaction; +use crate::rpc_transaction::{ + RpcDeployAccountTransaction, + RpcDeployAccountTransactionV3, + RpcTransaction, +}; use crate::transaction::fields::{ Calldata, ContractAddressSalt, @@ -124,3 +129,26 @@ pub fn executable_deploy_account_tx( ExecutableDeployAccountTransaction { tx, tx_hash, contract_address } } + +pub fn rpc_deploy_account_tx(deploy_tx_args: DeployAccountTxArgs) -> RpcTransaction { + if deploy_tx_args.version != TransactionVersion::THREE { + panic!("Unsupported transaction version: {:?}.", deploy_tx_args.version); + } + + let ValidResourceBounds::AllResources(resource_bounds) = deploy_tx_args.resource_bounds else { + panic!("Unsupported resource bounds type: {:?}.", deploy_tx_args.resource_bounds) + }; + + RpcTransaction::DeployAccount(RpcDeployAccountTransaction::V3(RpcDeployAccountTransactionV3 { + resource_bounds, + tip: deploy_tx_args.tip, + contract_address_salt: deploy_tx_args.contract_address_salt, + class_hash: deploy_tx_args.class_hash, + constructor_calldata: deploy_tx_args.constructor_calldata, + nonce: deploy_tx_args.nonce, + signature: deploy_tx_args.signature, + nonce_data_availability_mode: deploy_tx_args.nonce_data_availability_mode, + fee_data_availability_mode: deploy_tx_args.fee_data_availability_mode, + paymaster_data: deploy_tx_args.paymaster_data, + })) +} diff --git a/crates/starknet_gateway/src/test_utils.rs b/crates/starknet_gateway/src/test_utils.rs index d7e2ecdc9f..d8866fdffe 100644 --- a/crates/starknet_gateway/src/test_utils.rs +++ b/crates/starknet_gateway/src/test_utils.rs @@ -1,10 +1,10 @@ -use mempool_test_utils::starknet_api_test_utils::rpc_deploy_account_tx; use starknet_api::block::GasPrice; use starknet_api::core::ContractAddress; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasAmount; use starknet_api::rpc_transaction::{ContractClass, RpcTransaction}; use starknet_api::test_utils::declare::{rpc_declare_tx, TEST_SENDER_ADDRESS}; +use starknet_api::test_utils::deploy_account::rpc_deploy_account_tx; use starknet_api::test_utils::invoke::rpc_invoke_tx; use starknet_api::transaction::fields::{ AccountDeploymentData,