Skip to content

Commit

Permalink
chore: use alloy withdrawal type (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell authored Jun 6, 2024
1 parent 6932f76 commit a8cb0e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
19 changes: 2 additions & 17 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,19 +133,3 @@ pub struct OpBlock {
/// Block withdrawals.
pub withdrawals: Option<Vec<Withdrawal>>,
}

/// 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,
}
7 changes: 6 additions & 1 deletion crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit a8cb0e1

Please sign in to comment.