From 07ee347a377106c01a13c288e3e6e663eab8b9c8 Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Tue, 26 Nov 2024 20:59:51 +0800 Subject: [PATCH] feat: add log convert --- Cargo.toml | 2 +- src/evm.rs | 12 ++++++++++++ src/lib.rs | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/evm.rs diff --git a/Cargo.toml b/Cargo.toml index 3008f70..d5f892a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy = { version = "0.6.4", features = ["full", "node-bindings", "rlp", "rpc-types-engine"] } +alloy = { version = "0.6.4", features = ["full", "node-bindings", "rlp", "rpc-types-engine", "rpc-types-trace"] } ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "8fbd8a53dca0170bedeca40a92ee70fd48c4615b" } reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.1.2" } diff --git a/src/evm.rs b/src/evm.rs new file mode 100644 index 0000000..db7055c --- /dev/null +++ b/src/evm.rs @@ -0,0 +1,12 @@ +use alloy::{ + primitives::{Log, LogData}, + rpc::types::trace::geth::CallLogFrame, +}; + +pub fn call_log_frame_to_log(log_frame: CallLogFrame) -> Option { + let address = log_frame.address?; + let topics = log_frame.topics?; + let data = log_frame.data?; + + LogData::new(topics, data).map(|data| Log { address, data }) +} diff --git a/src/lib.rs b/src/lib.rs index b429453..b9ec767 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ pub mod block; +pub mod evm; pub mod time; pub mod transaction;