From a8cb0e1d7a33384e74edfd4f6c18b550a3d4d409 Mon Sep 17 00:00:00 2001 From: refcell Date: Thu, 6 Jun 2024 09:27:52 -0600 Subject: [PATCH] chore: use alloy withdrawal type (#213) --- crates/primitives/src/block.rs | 19 ++----------------- crates/primitives/src/lib.rs | 7 ++++++- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 71020c50..6d9fdd60 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -2,7 +2,8 @@ use alloc::vec::Vec; use alloy_consensus::{Header, TxEnvelope}; -use alloy_primitives::{Address, BlockHash, BlockNumber, B256}; +use alloy_eips::eip4895::Withdrawal; +use alloy_primitives::{BlockHash, BlockNumber, B256}; use alloy_rlp::{RlpDecodable, RlpEncodable}; use op_alloy_consensus::OpTxEnvelope; @@ -132,19 +133,3 @@ pub struct OpBlock { /// Block withdrawals. pub withdrawals: Option>, } - -/// Withdrawal represents a validator withdrawal from the consensus layer. -/// -/// Taken from [reth-primitives](https://github.com/paradigmxyz/reth) -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[derive(Debug, Clone, PartialEq, Eq, Default, Hash, RlpEncodable, RlpDecodable)] -pub struct Withdrawal { - /// Monotonically increasing identifier issued by consensus layer. - pub index: u64, - /// Index of validator associated with withdrawal. - pub validator_index: u64, - /// Target address for withdrawn ether. - pub address: Address, - /// Value of the withdrawal in gwei. - pub amount: u64, -} diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 0e2ee601..8f4619bd 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -6,8 +6,13 @@ extern crate alloc; +/// Re-export the [Withdrawal] type from the [alloy_eips] crate. +/// +/// [Withdrawal]: alloy_eips::eip4895::Withdrawal +pub use alloy_eips::eip4895::Withdrawal; + pub mod block; -pub use block::{Block, BlockID, BlockInfo, BlockKind, L2BlockInfo, OpBlock, Withdrawal}; +pub use block::{Block, BlockID, BlockInfo, BlockKind, L2BlockInfo, OpBlock}; pub mod block_info; pub use block_info::{L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx};