diff --git a/crates/rpc-engine-types/src/payload.rs b/crates/rpc-engine-types/src/payload.rs index 1007a6796b9..b4f6e14e912 100644 --- a/crates/rpc-engine-types/src/payload.rs +++ b/crates/rpc-engine-types/src/payload.rs @@ -3,7 +3,7 @@ use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256}; use alloy_rpc_types::{ kzg::{Blob, Bytes48}, - transaction::request::BlobTransactionSidecar, + transaction::BlobTransactionSidecar, withdrawal::Withdrawal, }; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; diff --git a/crates/rpc-types/src/eth/transaction/blob.rs b/crates/rpc-types/src/eth/transaction/blob.rs new file mode 100644 index 00000000000..f21cb7224ab --- /dev/null +++ b/crates/rpc-types/src/eth/transaction/blob.rs @@ -0,0 +1,16 @@ +//! EIP-4844 related types. + +use crate::kzg::{Blob, Bytes48}; +use serde::{Deserialize, Serialize}; + +/// This represents a set of blobs, and its corresponding commitments and proofs. +#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] +#[repr(C)] +pub struct BlobTransactionSidecar { + /// The blob data. + pub blobs: Vec, + /// The blob commitments. + pub commitments: Vec, + /// The blob proofs. + pub proofs: Vec, +} diff --git a/crates/rpc-types/src/eth/transaction/mod.rs b/crates/rpc-types/src/eth/transaction/mod.rs index a89af3729cd..e48b4fda28b 100644 --- a/crates/rpc-types/src/eth/transaction/mod.rs +++ b/crates/rpc-types/src/eth/transaction/mod.rs @@ -3,6 +3,7 @@ use crate::eth::other::OtherFields; pub use access_list::{AccessList, AccessListItem, AccessListWithGasUsed}; use alloy_primitives::{Address, Bytes, B256, U128, U256, U64}; +pub use blob::BlobTransactionSidecar; pub use common::TransactionInfo; pub use receipt::{OptimismTransactionReceiptFields, TransactionReceipt}; use serde::{Deserialize, Serialize}; @@ -15,6 +16,8 @@ mod receipt; pub mod request; mod signature; +mod blob; + /// Transaction object used in RPC #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/crates/rpc-types/src/eth/transaction/request.rs b/crates/rpc-types/src/eth/transaction/request.rs index 4968fa050ab..dc8e57131da 100644 --- a/crates/rpc-types/src/eth/transaction/request.rs +++ b/crates/rpc-types/src/eth/transaction/request.rs @@ -1,9 +1,5 @@ //! Alloy basic Transaction Request type. -use crate::{ - eth::transaction::AccessList, - kzg::{Blob, Bytes48}, - other::OtherFields, -}; +use crate::{eth::transaction::AccessList, other::OtherFields, BlobTransactionSidecar}; use alloy_primitives::{Address, Bytes, B256, U128, U256, U64, U8}; use serde::{Deserialize, Serialize}; @@ -47,38 +43,6 @@ pub struct TransactionRequest { pub other: OtherFields, } -/// Optimism specific transaction fields -#[derive(Debug, Copy, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct OptimismTransactionFields { - /// Hash that uniquely identifies the source of the deposit. - #[serde(rename = "sourceHash", skip_serializing_if = "Option::is_none")] - pub source_hash: Option, - /// The ETH value to mint on L2 - #[serde(rename = "mint", skip_serializing_if = "Option::is_none")] - pub mint: Option, - /// Field indicating whether the transaction is a system transaction, and therefore - /// exempt from the L2 gas limit. - #[serde(rename = "isSystemTx", skip_serializing_if = "Option::is_none")] - pub is_system_tx: Option, -} - -impl From for OtherFields { - fn from(value: OptimismTransactionFields) -> Self { - serde_json::to_value(value).unwrap().try_into().unwrap() - } -} - -/// This represents a set of blobs, and its corresponding commitments and proofs. -#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] -#[repr(C)] -pub struct BlobTransactionSidecar { - /// The blob data. - pub blobs: Vec, - /// The blob commitments. - pub commitments: Vec, - /// The blob proofs. - pub proofs: Vec, -} // == impl TransactionRequest == impl TransactionRequest { @@ -136,3 +100,24 @@ impl TransactionRequest { self } } + +/// Optimism specific transaction fields +#[derive(Debug, Copy, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct OptimismTransactionFields { + /// Hash that uniquely identifies the source of the deposit. + #[serde(rename = "sourceHash", skip_serializing_if = "Option::is_none")] + pub source_hash: Option, + /// The ETH value to mint on L2 + #[serde(rename = "mint", skip_serializing_if = "Option::is_none")] + pub mint: Option, + /// Field indicating whether the transaction is a system transaction, and therefore + /// exempt from the L2 gas limit. + #[serde(rename = "isSystemTx", skip_serializing_if = "Option::is_none")] + pub is_system_tx: Option, +} + +impl From for OtherFields { + fn from(value: OptimismTransactionFields) -> Self { + serde_json::to_value(value).unwrap().try_into().unwrap() + } +}