From 9aae0161d88d7093ec9901546ffffc6e4d80561b Mon Sep 17 00:00:00 2001 From: brunota20 Date: Mon, 15 Jun 2026 10:40:00 -0300 Subject: [PATCH] feat(ethflow-watcher): workspace + skeleton (BLEU-831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror of the twap-monitor skeleton (BLEU-825) for the EthFlow path. Adds modules/ethflow-watcher/ as a workspace member, with [lib] crate-type = ["cdylib"] for WASM Component output, and the same dep set (cowprotocol no-default-features, alloy-primitives, alloy-sol-types, wit-bindgen) pre-pulled so BLEU-832 (event decode) and BLEU-833 (EIP-1271 submit + retry) can layer in without churning Cargo.toml. src/lib.rs binds against shepherd:cow/shepherd, init logs once, on_event logs Event::Logs as a placeholder until BLEU-832 decodes the CoWSwapEthFlow OrderPlacement payload. cargo build --target wasm32-wasip2 --release -p ethflow-watcher emits a 67 KB .wasm (within ~3 KB of twap-monitor's skeleton — identical world + deps, identical link footprint). Engine load is gated on module.toml (BLEU-834). --- Cargo.toml | 1 + modules/ethflow-watcher/Cargo.toml | 15 +++++++++++++ modules/ethflow-watcher/src/lib.rs | 35 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 modules/ethflow-watcher/Cargo.toml create mode 100644 modules/ethflow-watcher/src/lib.rs 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);