Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(firehose-protos): reorganize ethereum v1 module #27

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!(),
}
}
}
Loading