From 20f70c555de0ed7941e63777f60078ee2036d71c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 23 Dec 2024 11:53:04 +0100 Subject: [PATCH] fix: support hex values for conditional options (#1824) --- crates/rpc-types-eth/src/erc4337.rs | 42 ++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/crates/rpc-types-eth/src/erc4337.rs b/crates/rpc-types-eth/src/erc4337.rs index 728bf56c9e0..6947e3ef234 100644 --- a/crates/rpc-types-eth/src/erc4337.rs +++ b/crates/rpc-types-eth/src/erc4337.rs @@ -18,23 +18,57 @@ pub struct ConditionalOptions { pub known_accounts: AddressHashMap, /// The minimal block number at which the transaction can be included. /// `None` indicates no minimum block number constraint. - #[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))] + #[cfg_attr( + feature = "serde", + serde( + default, + with = "alloy_serde::quantity::opt", + 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. - #[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))] + #[cfg_attr( + feature = "serde", + serde( + default, + with = "alloy_serde::quantity::opt", + 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. - #[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))] + #[cfg_attr( + feature = "serde", + serde( + default, + with = "alloy_serde::quantity::opt", + 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. - #[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))] + #[cfg_attr( + feature = "serde", + serde( + default, + with = "alloy_serde::quantity::opt", + skip_serializing_if = "Option::is_none" + ) + )] pub timestamp_max: Option, } /// Represents the expected state of an account for a transaction to be conditionally accepted. +/// +/// Allows for a user to express their preference of a known prestate at a particular account. Only +/// one of the storage root or storage slots is allowed to be set. If the storage root is set, then +/// the user prefers their transaction to only be included in a block if the account's storage root +/// matches. If the storage slots are set, then the user prefers their transaction to only be +/// included if the particular storage slot values from state match. #[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))]