diff --git a/crates/rpc-types/src/eth/log.rs b/crates/rpc-types/src/eth/log.rs index 199af24976a..1776c0cac4e 100644 --- a/crates/rpc-types/src/eth/log.rs +++ b/crates/rpc-types/src/eth/log.rs @@ -26,6 +26,22 @@ pub struct Log { pub removed: bool, } +impl TryFrom for alloy_primitives::Log { + type Error = LogError; + + fn try_from(value: Log) -> Result { + alloy_primitives::Log::new(value.topics, value.data).ok_or(LogError::InvalidTopics) + } +} + +/// Error that can occur when converting other types to logs +#[derive(Debug, thiserror::Error)] +pub enum LogError { + /// The topics are invalid + #[error("invalid topics")] + InvalidTopics, +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/rpc-types/src/eth/mod.rs b/crates/rpc-types/src/eth/mod.rs index 569dde4ca41..1443102a0a1 100644 --- a/crates/rpc-types/src/eth/mod.rs +++ b/crates/rpc-types/src/eth/mod.rs @@ -20,7 +20,7 @@ pub use block::*; pub use call::{Bundle, CallInput, CallInputError, CallRequest, EthCallResponse, StateContext}; pub use fee::{FeeHistory, TxGasAndReward}; pub use filter::*; -pub use log::Log; +pub use log::*; pub use raw_log::{logs_bloom, Log as RawLog}; pub use syncing::*; pub use transaction::*;