diff --git a/Cargo.lock b/Cargo.lock index df2c50d277..2ddfe1a287 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10602,6 +10602,7 @@ dependencies = [ "serde", "serde_json", "starknet-types-core", + "starknet_api", "thiserror", "tokio", "tracing", diff --git a/crates/starknet_sequencer_infra/Cargo.toml b/crates/starknet_sequencer_infra/Cargo.toml index 537c3295be..6b44f2be4d 100644 --- a/crates/starknet_sequencer_infra/Cargo.toml +++ b/crates/starknet_sequencer_infra/Cargo.toml @@ -19,6 +19,7 @@ papyrus_config.workspace = true rstest.workspace = true serde = { workspace = true, features = ["derive"] } serde_json.workspace = true +starknet_api.workspace = true thiserror.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tracing.workspace = true diff --git a/crates/starknet_sequencer_infra/src/serde_utils_test.rs b/crates/starknet_sequencer_infra/src/serde_utils_test.rs index b4f0e52e72..6b6bc2cf54 100644 --- a/crates/starknet_sequencer_infra/src/serde_utils_test.rs +++ b/crates/starknet_sequencer_infra/src/serde_utils_test.rs @@ -1,6 +1,16 @@ use std::fmt::Debug; use serde::{Deserialize, Serialize}; +use starknet_api::data_availability::DataAvailabilityMode; +use starknet_api::rpc_transaction::{ + RpcDeclareTransaction, + RpcDeclareTransactionV3, + RpcDeployAccountTransaction, + RpcDeployAccountTransactionV3, + RpcInvokeTransaction, + RpcInvokeTransactionV3, + RpcTransaction, +}; use starknet_types_core::felt::Felt; use crate::serde_utils::SerdeWrapper; @@ -40,3 +50,61 @@ fn test_serde_felt() { let data: Felt = Felt::ONE; test_generic_data_serde(data); } + +#[test] +fn test_serde_rpc_invoke_tx() { + let invoke_tx = RpcInvokeTransactionV3 { + sender_address: Default::default(), + calldata: Default::default(), + signature: Default::default(), + nonce: Default::default(), + resource_bounds: Default::default(), + tip: Default::default(), + paymaster_data: Default::default(), + account_deployment_data: Default::default(), + nonce_data_availability_mode: DataAvailabilityMode::L1, + fee_data_availability_mode: DataAvailabilityMode::L1, + }; + let rpc_invoke_tx = RpcInvokeTransaction::V3(invoke_tx); + + test_generic_data_serde(RpcTransaction::Invoke(rpc_invoke_tx)); +} + +#[test] +fn test_serde_rpc_deploy_account_tx() { + let deploy_account_tx = RpcDeployAccountTransactionV3 { + signature: Default::default(), + nonce: Default::default(), + class_hash: Default::default(), + resource_bounds: Default::default(), + contract_address_salt: Default::default(), + constructor_calldata: Default::default(), + tip: Default::default(), + paymaster_data: Default::default(), + nonce_data_availability_mode: DataAvailabilityMode::L1, + fee_data_availability_mode: DataAvailabilityMode::L1, + }; + let rpc_deploy_account_tx = RpcDeployAccountTransaction::V3(deploy_account_tx); + + test_generic_data_serde(RpcTransaction::DeployAccount(rpc_deploy_account_tx)); +} + +#[test] +fn test_serde_rpc_declare_tx() { + let declare_tx = RpcDeclareTransactionV3 { + sender_address: Default::default(), + compiled_class_hash: Default::default(), + signature: Default::default(), + nonce: Default::default(), + contract_class: Default::default(), + resource_bounds: Default::default(), + tip: Default::default(), + paymaster_data: Default::default(), + account_deployment_data: Default::default(), + nonce_data_availability_mode: DataAvailabilityMode::L1, + fee_data_availability_mode: DataAvailabilityMode::L1, + }; + let rpc_declare_tx = RpcDeclareTransaction::V3(declare_tx); + + test_generic_data_serde(RpcTransaction::Declare(rpc_declare_tx)); +}