Skip to content

Commit ce63acb

Browse files
authored
feat(eips): serde untagged for EIP-7685 RequestsOrHash (#2216)
* feat(eips): serde untagged for EIP-7685 RequestsOrHash * helper functions
1 parent fe6cef5 commit ce63acb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/eips/src/eip7685.rs

+11
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl Requests {
129129
/// needed to simulate the presence of requests without holding actual data.
130130
#[derive(Debug, Clone, PartialEq, Eq, Hash, derive_more::From)]
131131
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
132+
#[cfg_attr(feature = "serde", serde(untagged))]
132133
pub enum RequestsOrHash {
133134
/// Stores a list of requests, allowing for dynamic requests hash calculation.
134135
Requests(Requests),
@@ -163,6 +164,16 @@ impl RequestsOrHash {
163164
Self::Hash(_) => None,
164165
}
165166
}
167+
168+
/// Returns `true` if the variant is a list of requests.
169+
pub const fn is_requests(&self) -> bool {
170+
matches!(self, Self::Requests(_))
171+
}
172+
173+
/// Returns `true` if the variant is a precomputed hash.
174+
pub const fn is_hash(&self) -> bool {
175+
matches!(self, Self::Hash(_))
176+
}
166177
}
167178

168179
impl Default for RequestsOrHash {

0 commit comments

Comments
 (0)