diff --git a/crates/rpc-types-engine/src/payload.rs b/crates/rpc-types-engine/src/payload.rs index 68b5a6d9969..3efc968476d 100644 --- a/crates/rpc-types-engine/src/payload.rs +++ b/crates/rpc-types-engine/src/payload.rs @@ -1080,18 +1080,29 @@ pub struct ExecutionPayloadBodyV1 { } impl ExecutionPayloadBodyV1 { - /// Converts a [`alloy_consensus::Block`] into an execution payload body. - pub fn from_block<T: Encodable2718, H>(block: Block<T, H>) -> Self { + /// Creates an [`ExecutionPayloadBodyV1`] from the given withdrawals and transactions + pub fn new<'a, T>( + withdrawals: Option<Withdrawals>, + transactions: impl IntoIterator<Item = &'a T>, + ) -> Self + where + T: Encodable2718 + 'a, + { Self { - transactions: block.body.transactions().map(|tx| tx.encoded_2718().into()).collect(), - withdrawals: block.body.withdrawals.map(Withdrawals::into_inner), + transactions: transactions.into_iter().map(|tx| tx.encoded_2718().into()).collect(), + withdrawals: withdrawals.map(Withdrawals::into_inner), } } + + /// Converts a [`alloy_consensus::Block`] into an execution payload body. + pub fn from_block<T: Encodable2718, H>(block: &Block<T, H>) -> Self { + Self::new(block.body.withdrawals.clone(), block.body.transactions()) + } } impl<T: Encodable2718, H> From<Block<T, H>> for ExecutionPayloadBodyV1 { fn from(value: Block<T, H>) -> Self { - Self::from_block(value) + Self::from_block(&value) } }