diff --git a/crates/rpc-types-engine/src/payload.rs b/crates/rpc-types-engine/src/payload.rs index bb397af6e22..b34a84aa1c9 100644 --- a/crates/rpc-types-engine/src/payload.rs +++ b/crates/rpc-types-engine/src/payload.rs @@ -649,6 +649,15 @@ pub enum ExecutionPayload { } impl ExecutionPayload { + /// Converts [`ExecutionPayloadV1`] to [`Block`] + pub fn try_into_block(self) -> Result, PayloadError> { + match self { + Self::V1(payload) => payload.try_into_block(), + Self::V2(payload) => payload.try_into_block(), + Self::V3(payload) => payload.try_into_block(), + } + } + /// Returns a reference to the V1 payload. pub const fn as_v1(&self) -> &ExecutionPayloadV1 { match self { @@ -767,6 +776,14 @@ impl From for ExecutionPayload { } } +impl TryFrom for Block { + type Error = PayloadError; + + fn try_from(value: ExecutionPayload) -> Result { + value.try_into_block() + } +} + // Deserializes untagged ExecutionPayload by trying each variant in falling order #[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ExecutionPayload {