From cfcde0696d203891947bbb40a7d815322fdd539d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 28 Dec 2024 10:51:15 +0100 Subject: [PATCH] feat: add ExecutionPayloadFieldV2 into ExecutionPayload (#1858) --- crates/rpc-types-engine/src/payload.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/rpc-types-engine/src/payload.rs b/crates/rpc-types-engine/src/payload.rs index 85e6320bdb9..5144a493597 100644 --- a/crates/rpc-types-engine/src/payload.rs +++ b/crates/rpc-types-engine/src/payload.rs @@ -68,6 +68,14 @@ impl ExecutionPayloadFieldV2 { Self::V2(payload) => payload.payload_inner, } } + + /// Converts this payload variant into the corresponding [ExecutionPayload] + pub fn into_payload(self) -> ExecutionPayload { + match self { + Self::V1(payload) => ExecutionPayload::V1(payload), + Self::V2(payload) => ExecutionPayload::V2(payload), + } + } } /// This is the input to `engine_newPayloadV2`, which may or may not have a withdrawals field. @@ -830,6 +838,12 @@ impl From for ExecutionPayload { } } +impl From for ExecutionPayload { + fn from(payload: ExecutionPayloadFieldV2) -> Self { + payload.into_payload() + } +} + impl From for ExecutionPayload { fn from(payload: ExecutionPayloadV3) -> Self { Self::V3(payload)