diff --git a/Cargo.toml b/Cargo.toml index ed79b10..9346ac7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "crates/nexum-engine", + "modules/ethflow-watcher", "modules/example", ] resolver = "2" diff --git a/modules/ethflow-watcher/Cargo.toml b/modules/ethflow-watcher/Cargo.toml new file mode 100644 index 0000000..5d9fa3d --- /dev/null +++ b/modules/ethflow-watcher/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "ethflow-watcher" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +cowprotocol = { version = "1.0.0-alpha.3", default-features = false } +alloy-primitives = { version = "1.5", default-features = false, features = ["std"] } +alloy-sol-types = { version = "1.5", default-features = false, features = ["std"] } +wit-bindgen = { version = "0.57", default-features = false, features = ["macros", "realloc"] } diff --git a/modules/ethflow-watcher/src/lib.rs b/modules/ethflow-watcher/src/lib.rs new file mode 100644 index 0000000..4442708 --- /dev/null +++ b/modules/ethflow-watcher/src/lib.rs @@ -0,0 +1,35 @@ +// wit_bindgen::generate! expands to host-import shims whose arity matches +// the WIT signatures, which can exceed clippy's too-many-arguments threshold. +#![allow(clippy::too_many_arguments)] + +wit_bindgen::generate!({ + path: ["../../wit/nexum-host", "../../wit/shepherd-cow"], + world: "shepherd:cow/shepherd", + generate_all, +}); + +use nexum::host::{logging, types}; + +struct EthFlowWatcher; + +impl Guest for EthFlowWatcher { + fn init(_config: Vec<(String, String)>) -> Result<(), HostError> { + logging::log(logging::Level::Info, "ethflow-watcher init"); + Ok(()) + } + + fn on_event(event: types::Event) -> Result<(), HostError> { + // CoWSwapEthFlow `OrderPlacement` decode lands in BLEU-832; the + // EIP-1271 submission path lands in BLEU-833. Block / Tick / + // Message are not used by this module. + if let types::Event::Logs(logs) = event { + logging::log( + logging::Level::Info, + &format!("ethflow received {} logs (decode in BLEU-832)", logs.len()), + ); + } + Ok(()) + } +} + +export!(EthFlowWatcher);