From 3dbacee3b6d790af630e1b3c635ee4750fc2b66c Mon Sep 17 00:00:00 2001 From: brunota20 Date: Mon, 15 Jun 2026 09:25:25 -0300 Subject: [PATCH] feat(twap-monitor): workspace + skeleton (BLEU-825) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add modules/twap-monitor/ as a workspace member. Cargo.toml declares [lib] crate-type = ["cdylib"] for WASM Component output, and pulls the deps the TWAP module path needs: cowprotocol (default-features off — only typed primitives and OrderCreation surface needed), alloy-sol-types (event/return decoding lands in BLEU-826/827), and wit-bindgen. src/lib.rs binds against the shepherd:cow/shepherd world (event- module imports + cow-api). generate_all is required because the world include pulls nexum:host/types across packages — without it, wit-bindgen panics on the missing cross-package mapping. init and on_event are stubbed: init logs once; on_event is a no-op until the Event::Log / Event::Block dispatch lands in BLEU-826 / BLEU-827. Verification: cargo build --target wasm32-wasip2 --release -p twap-monitor emits a 65 KB .wasm. Engine load is gated on module.toml (BLEU-834). --- Cargo.toml | 1 + modules/twap-monitor/Cargo.toml | 14 ++++++++++++++ modules/twap-monitor/src/lib.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 modules/twap-monitor/Cargo.toml create mode 100644 modules/twap-monitor/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index b71581a..c83c061 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "crates/nexum-engine", "modules/example", + "modules/twap-monitor", ] resolver = "2" diff --git a/modules/twap-monitor/Cargo.toml b/modules/twap-monitor/Cargo.toml new file mode 100644 index 0000000..bafc696 --- /dev/null +++ b/modules/twap-monitor/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "twap-monitor" +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-sol-types = { version = "1.5", default-features = false } +wit-bindgen = { version = "0.57", default-features = false, features = ["macros", "realloc"] } diff --git a/modules/twap-monitor/src/lib.rs b/modules/twap-monitor/src/lib.rs new file mode 100644 index 0000000..72c0763 --- /dev/null +++ b/modules/twap-monitor/src/lib.rs @@ -0,0 +1,29 @@ +// 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; +use nexum::host::types; + +struct TwapMonitor; + +impl Guest for TwapMonitor { + fn init(_config: Vec<(String, String)>) -> Result<(), HostError> { + logging::log(logging::Level::Info, "twap-monitor init"); + Ok(()) + } + + fn on_event(_event: types::Event) -> Result<(), HostError> { + // Dispatch on Event::Log (ConditionalOrderCreated) and Event::Block + // (TWAP poll tick) lands in BLEU-826 / BLEU-827. + Ok(()) + } +} + +export!(TwapMonitor);