Skip to content

Commit

Permalink
refactor(firehose-protos): reorganize ethereum v1 module
Browse files Browse the repository at this point in the history
  • Loading branch information
suchapalaver committed Oct 25, 2024
1 parent 5523285 commit 3851398
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
//! Firehose Ethereum-related data structures and operations.
//! See the protobuffer definitions section of the README for more information.
//!
use super::Block;
use alloy_primitives::{Address, Bloom, FixedBytes, Uint};
use ethportal_api::types::execution::header::Header;
use prost::Message;
use prost_wkt_types::Any;
use reth_primitives::TxType;
use transaction_trace::Type;

use crate::{
error::ProtosError,
firehose::v2::{Response, SingleBlockResponse},
};

tonic::include_proto!("sf.ethereum.r#type.v2");

impl TryFrom<&Block> for Header {
type Error = ProtosError;

Expand Down Expand Up @@ -94,28 +88,6 @@ impl TryFrom<&Block> for Header {
}
}

impl From<Type> for TxType {
fn from(tx_type: Type) -> Self {
use TxType::*;
use Type::*;

match tx_type {
TrxTypeLegacy => Legacy,
TrxTypeAccessList => Eip2930,
TrxTypeDynamicFee => Eip1559,
TrxTypeBlob => Eip4844,
TrxTypeArbitrumDeposit => unimplemented!(),
TrxTypeArbitrumUnsigned => unimplemented!(),
TrxTypeArbitrumContract => unimplemented!(),
TrxTypeArbitrumRetry => unimplemented!(),
TrxTypeArbitrumSubmitRetryable => unimplemented!(),
TrxTypeArbitrumInternal => unimplemented!(),
TrxTypeArbitrumLegacy => unimplemented!(),
TrxTypeOptimismDeposit => unimplemented!(),
}
}
}

fn decode_block<M>(response: M) -> Result<Block, ProtosError>
where
M: MessageWithBlock,
Expand Down Expand Up @@ -159,6 +131,10 @@ impl TryFrom<Response> for Block {

#[cfg(test)]
mod tests {
use ethportal_api::Header;

use crate::ethereum_v2::BlockHeader;

use super::*;

#[test]
Expand Down
8 changes: 8 additions & 0 deletions crates/firehose-protos/src/ethereum_v2/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Firehose Ethereum-related data structures and operations.
//! See the protobuffer definitions section of the README for more information.
//!
pub mod eth_block;
pub mod transaction;

tonic::include_proto!("sf.ethereum.r#type.v2");
25 changes: 25 additions & 0 deletions crates/firehose-protos/src/ethereum_v2/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use reth_primitives::TxType;

use super::transaction_trace::Type;

impl From<Type> for TxType {
fn from(tx_type: Type) -> Self {
use TxType::*;
use Type::*;

match tx_type {
TrxTypeLegacy => Legacy,
TrxTypeAccessList => Eip2930,
TrxTypeDynamicFee => Eip1559,
TrxTypeBlob => Eip4844,
TrxTypeArbitrumDeposit => unimplemented!(),
TrxTypeArbitrumUnsigned => unimplemented!(),
TrxTypeArbitrumContract => unimplemented!(),
TrxTypeArbitrumRetry => unimplemented!(),
TrxTypeArbitrumSubmitRetryable => unimplemented!(),
TrxTypeArbitrumInternal => unimplemented!(),
TrxTypeArbitrumLegacy => unimplemented!(),
TrxTypeOptimismDeposit => unimplemented!(),
}
}
}

0 comments on commit 3851398

Please sign in to comment.