Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
feat: add cancun fields to Block (#2655)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Oct 30, 2023
1 parent 506e522 commit efdc8d4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ethers-core/src/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ pub struct Block<TX> {
/// Base fee per unit of gas (if past London)
#[serde(rename = "baseFeePerGas")]
pub base_fee_per_gas: Option<U256>,
/// Blob gas used (if past Cancun)
#[serde(default, skip_serializing_if = "Option::is_none", rename = "blobGasUsed")]
#[cfg(not(feature = "celo"))]
pub blob_gas_used: Option<U256>,
/// Excess blob gas (if past Cancun)
#[serde(default, skip_serializing_if = "Option::is_none", rename = "excessBlobGas")]
#[cfg(not(feature = "celo"))]
pub excess_blob_gas: Option<U256>,
/// Withdrawals root hash (if past Shanghai)
#[serde(default, skip_serializing_if = "Option::is_none", rename = "withdrawalsRoot")]
#[cfg(not(feature = "celo"))]
Expand All @@ -94,6 +102,10 @@ pub struct Block<TX> {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[cfg(not(feature = "celo"))]
pub withdrawals: Option<Vec<Withdrawal>>,
/// Parent beacon block root (if past Cancun)
#[serde(default, skip_serializing_if = "Option::is_none", rename = "parentBeaconBlockRoot")]
#[cfg(not(feature = "celo"))]
pub parent_beacon_block_root: Option<H256>,

#[cfg(feature = "celo")]
#[cfg_attr(docsrs, doc(cfg(feature = "celo")))]
Expand Down Expand Up @@ -230,6 +242,9 @@ impl Block<TxHash> {
base_fee_per_gas,
withdrawals_root,
withdrawals,
blob_gas_used,
excess_blob_gas,
parent_beacon_block_root,
other,
..
} = self;
Expand Down Expand Up @@ -258,6 +273,9 @@ impl Block<TxHash> {
withdrawals_root,
withdrawals,
transactions,
blob_gas_used,
excess_blob_gas,
parent_beacon_block_root,
other,
}
}
Expand Down Expand Up @@ -338,6 +356,9 @@ impl From<Block<Transaction>> for Block<TxHash> {
base_fee_per_gas,
withdrawals_root,
withdrawals,
excess_blob_gas,
blob_gas_used,
parent_beacon_block_root,
other,
} = full;
Block {
Expand All @@ -364,6 +385,9 @@ impl From<Block<Transaction>> for Block<TxHash> {
base_fee_per_gas,
withdrawals_root,
withdrawals,
excess_blob_gas,
blob_gas_used,
parent_beacon_block_root,
transactions: transactions.iter().map(|tx| tx.hash).collect(),
other,
}
Expand Down

0 comments on commit efdc8d4

Please sign in to comment.