diff --git a/crates/rpc-types-eth/src/filter.rs b/crates/rpc-types-eth/src/filter.rs index abdfaab0b7f..09d6551e693 100644 --- a/crates/rpc-types-eth/src/filter.rs +++ b/crates/rpc-types-eth/src/filter.rs @@ -668,6 +668,36 @@ pub enum ValueOrArray { Array(Vec), } +impl ValueOrArray { + /// Get the value if present. + pub const fn as_value(&self) -> Option<&T> { + if let Self::Value(value) = self { + Some(value) + } else { + None + } + } + + /// Get the array if present. + pub fn as_array(&self) -> Option<&[T]> { + if let Self::Array(array) = self { + Some(array) + } else { + None + } + } + + /// Check if the enum is a single value. + pub const fn is_value(&self) -> bool { + matches!(self, Self::Value(_)) + } + + /// Check if the enum is an array. + pub const fn is_array(&self) -> bool { + matches!(self, Self::Array(_)) + } +} + impl From
for ValueOrArray
{ fn from(src: Address) -> Self { Self::Value(src)