diff --git a/src/clients/blobscan/types.rs b/src/clients/blobscan/types.rs index 7b1d6cc..6df171f 100644 --- a/src/clients/blobscan/types.rs +++ b/src/clients/blobscan/types.rs @@ -9,11 +9,14 @@ use serde::{Deserialize, Serialize}; use crate::{clients::beacon::types::Blob as BeaconBlob, utils::web3::calculate_versioned_hash}; #[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "camelCase")] pub struct Block { pub number: U64, pub hash: H256, pub timestamp: U256, pub slot: u32, + pub blob_gas_used: U256, + pub excess_blob_gas: U256, } #[derive(Serialize, Deserialize, Debug)] @@ -24,6 +27,8 @@ pub struct Transaction { #[serde(default, skip_serializing_if = "Option::is_none")] pub to: Option
, pub block_number: U64, + pub gas_price: U256, + pub max_fee_per_blob_gas: U256, } #[derive(Serialize, Deserialize)] @@ -99,6 +104,36 @@ impl<'a> TryFrom<(&'a EthersBlock, u32)> for Block { .with_context(|| format!("Missing block hash field in execution block {number}"))?, timestamp: ethers_block.timestamp, slot, + blob_gas_used: match ethers_block.other.get("blobGasUsed") { + Some(blob_gas_used) => { + let blob_gas_used = blob_gas_used.as_str().with_context(|| { + format!("Failed to convert `blobGasUsed` field in execution block {number}") + })?; + + U256::from_str_radix(blob_gas_used, 16)? + } + None => { + return Err(anyhow::anyhow!( + "Missing `blobGasUsed` field in execution block {number}" + )) + } + }, + excess_blob_gas: match ethers_block.other.get("excessBlobGas") { + Some(excess_gas_gas) => { + let excess_blob_gas = excess_gas_gas.as_str().with_context(|| { + format!( + "Failed to convert excess blob gas field in execution block {number}" + ) + })?; + + U256::from_str_radix(excess_blob_gas, 16)? + } + None => { + return Err(anyhow::anyhow!( + "Missing `excessBlobGas` field in execution block {number}" + )) + } + }, }) } } @@ -118,6 +153,28 @@ impl<'a> TryFrom<(&'a EthersTransaction, &'a EthersBlock)> fo hash, from: ethers_tx.from, to: ethers_tx.to, + gas_price: ethers_tx.gas_price.with_context(|| { + format!("Missing gas price field in transaction {hash}", hash = hash) + })?, + max_fee_per_blob_gas: match ethers_tx.other.get("maxFeePerBlobGas") { + Some(max_fee_per_blob_gas) => { + let max_fee_per_blob_gas = + max_fee_per_blob_gas.as_str().with_context(|| { + format!( + "Failed to convert `maxFeePerBlobGas` field in transaction {hash}", + hash = hash + ) + })?; + + U256::from_str_radix(max_fee_per_blob_gas, 16)? + } + None => { + return Err(anyhow::anyhow!( + "Missing `maxFeePerBlobGas` field in transaction {hash}", + hash = hash + )) + } + }, }) } }