diff --git a/crates/rpc-types-eth/src/eip4337.rs b/crates/rpc-types-eth/src/eip4337.rs new file mode 100644 index 00000000000..0a43da2f44f --- /dev/null +++ b/crates/rpc-types-eth/src/eip4337.rs @@ -0,0 +1,41 @@ +use alloy_primitives::{Address, BlockNumber, B256, U256}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +/// Options for conditional raw transaction submissions. +// reference for the implementation +// See also +#[derive(Debug, Serialize, Deserialize, Clone, Default)] +#[serde(rename_all = "camelCase")] +pub struct ConditionalOptions { + /// A map of account addresses to their expected storage states. + /// Each account can have a specified storage root or explicit slot-value pairs. + #[serde(default)] + pub known_accounts: HashMap, + /// The minimal block number at which the transaction can be included. + /// `None` indicates no minimum block number constraint. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block_number_min: Option, + /// The maximal block number at which the transaction can be included. + /// `None` indicates no maximum block number constraint. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block_number_max: Option, + /// The minimal timestamp at which the transaction can be included. + /// `None` indicates no minimum timestamp constraint. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub timestamp_min: Option, + /// The maximal timestamp at which the transaction can be included. + /// `None` indicates no maximum timestamp constraint. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub timestamp_max: Option, +} + +/// Represents the expected state of an account for a transaction to be conditionally accepted. +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(untagged)] +pub enum AccountStorage { + /// Expected storage root hash of the account. + RootHash(B256), + /// Explicit storage slots and their expected values. + Slots(HashMap), +} diff --git a/crates/rpc-types-eth/src/lib.rs b/crates/rpc-types-eth/src/lib.rs index 46a5f3b4bd6..2219acba233 100644 --- a/crates/rpc-types-eth/src/lib.rs +++ b/crates/rpc-types-eth/src/lib.rs @@ -46,3 +46,6 @@ pub use transaction::*; mod work; pub use work::Work; + +/// This module provides implementations for EIP-4337. +pub mod eip4337; diff --git a/crates/rpc-types-eth/src/transaction/request.rs b/crates/rpc-types-eth/src/transaction/request.rs index 6fae40d2b89..36c85addd3c 100644 --- a/crates/rpc-types-eth/src/transaction/request.rs +++ b/crates/rpc-types-eth/src/transaction/request.rs @@ -8,7 +8,6 @@ use alloy_consensus::{ use alloy_primitives::{Address, Bytes, ChainId, TxKind, B256, U256}; use serde::{Deserialize, Serialize}; use std::hash::Hash; - /// Represents _all_ transaction requests to/from RPC. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "camelCase")]