From b3238416b0e86602f0525551b390b1a43b7629f1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 18 Sep 2024 14:47:45 +0200 Subject: [PATCH] feat: add block num hash helper --- crates/rpc-types-engine/src/payload.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/rpc-types-engine/src/payload.rs b/crates/rpc-types-engine/src/payload.rs index 93e37fb0291..86c030f9503 100644 --- a/crates/rpc-types-engine/src/payload.rs +++ b/crates/rpc-types-engine/src/payload.rs @@ -7,7 +7,7 @@ use alloc::{ use alloy_consensus::{Blob, Bytes48}; use alloy_eips::{ eip4844::BlobTransactionSidecar, eip4895::Withdrawal, eip6110::DepositRequest, - eip7002::WithdrawalRequest, eip7251::ConsolidationRequest, + eip7002::WithdrawalRequest, eip7251::ConsolidationRequest, BlockNumHash, }; use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256}; use core::iter::{FromIterator, IntoIterator}; @@ -192,6 +192,13 @@ pub struct ExecutionPayloadV1 { pub transactions: Vec, } +impl ExecutionPayloadV1 { + /// Returns the block number and hash as a [`BlockNumHash`]. + pub const fn block_num_hash(&self) -> BlockNumHash { + BlockNumHash::new(self.block_number, self.block_hash) + } +} + /// This structure maps on the ExecutionPayloadV2 structure of the beacon chain spec. /// /// See also: @@ -843,6 +850,11 @@ impl ExecutionPayload { self.as_v1().block_number } + /// Returns the block number for this payload. + pub const fn block_num_hash(&self) -> BlockNumHash { + self.as_v1().block_num_hash() + } + /// Returns the prev randao for this payload. pub const fn prev_randao(&self) -> B256 { self.as_v1().prev_randao