Skip to content

refactor(modules): consume shepherd-sdk helpers (BLEU-843)#14

Open
brunota20 wants to merge 1 commit into
feat/shepherd-sdk-helpers-bleu-840from
feat/m2-modules-on-sdk-bleu-843
Open

refactor(modules): consume shepherd-sdk helpers (BLEU-843)#14
brunota20 wants to merge 1 commit into
feat/shepherd-sdk-helpers-bleu-840from
feat/m2-modules-on-sdk-bleu-843

Conversation

@brunota20

Copy link
Copy Markdown
Collaborator

Summary

Collapses the duplication BLEU-840 introduced `shepherd-sdk` for. `modules/twap-monitor` and `modules/ethflow-watcher` now consume the helpers from `shepherd_sdk::cow` / `shepherd_sdk::chain` instead of carrying their own copies.

Replaced with SDK paths

  • `gpv2_to_order_data` — was duplicated verbatim
  • `RetryAction` + `classify_api_error` + `try_decode_api_error`
  • `PollOutcome` enum (Ready boxed)
  • `IConditionalOrder` sol! errors + `decode_revert`
  • `eth_call_params` + `parse_eth_call_result` + `decode_revert_hex`

Kept module-side

  • TWAP: `abi::Params` + `getTradeableOrderWithSignatureCall` (selector source — TWAP-specific, EthFlow does not poll); `decode_conditional_order_created`; `watch:` / `next_block:` / `next_epoch:` key conventions; `WatchUpdate` lifecycle.
  • EthFlow: `decode_order_placement`; `to_signature` (OnchainSignature → Signature); `submitted:` / `backoff:` / `dropped:` markers; `PriorOutcome` idempotency.

Numbers

Before After Δ
twap-monitor LOC 1058 671 −387
ethflow-watcher LOC 537 436 −101
twap-monitor tests 34 13 −21 (moved to SDK)
ethflow-watcher tests 10 7 −3
twap-monitor `.wasm` 300 KB 305 KB +5 KB
ethflow-watcher `.wasm` 272 KB 275 KB +3 KB

Wasm grows slightly because the SDK re-exports add link-table entries; alloy + cowprotocol are deduped by the linker so the optimised size stays close. Pure refactor — no new dispatch paths, no new key conventions, same wire behaviour.

Stacks on #13 (BLEU-840 SDK extraction).

Linear: BLEU-843.

Test plan

  • `cargo test -p twap-monitor` — 13 tests (the 21 covered by SDK now live in shepherd-sdk).
  • `cargo test -p ethflow-watcher` — 7 tests.
  • `cargo clippy --target wasm32-wasip2 -p twap-monitor -p ethflow-watcher -p shepherd-sdk -- -Dwarnings` clean.
  • `cargo clippy --workspace --tests -- -Dwarnings` (host) clean.
  • `cargo build --target wasm32-wasip2 --release` — both modules build clean.

Drops the duplicated helpers in `modules/twap-monitor` and
`modules/ethflow-watcher` in favour of `shepherd_sdk::cow` /
`shepherd_sdk::chain`:

- `gpv2_to_order_data` (was duplicated verbatim)
- `RetryAction` + `classify_api_error` + `try_decode_api_error`
- `PollOutcome` enum (was duplicated verbatim — Ready boxed,
  TryAtEpoch / TryOnBlock / TryNextBlock / DontTryAgain)
- `IConditionalOrder` sol! errors + `decode_revert`
- `eth_call_params` + `parse_eth_call_result` + `decode_revert_hex`

Kept module-side:
- `abi::Params` + `getTradeableOrderWithSignatureCall` in
  twap-monitor (TWAP-specific selector source — EthFlow does
  not poll).
- `decode_conditional_order_created` / `decode_order_placement`
  in their respective modules (each is bound to a specific
  event signature on a specific contract).
- `watch:` / `next_block:` / `next_epoch:` key conventions in
  twap-monitor and `submitted:` / `backoff:` / `dropped:` in
  ethflow-watcher (per-module persistence policies, not shared).
- `to_signature` (OnchainSignature → Signature) in ethflow-
  watcher (single consumer; will move to SDK if a second emerges).
- `BuildError` / `WatchUpdate` / lifecycle plumbing in their
  modules (strategy-specific).

LOC: -387 in twap-monitor (1058 → 671), -101 in ethflow-watcher
(537 → 436). Tests: 13 host tests stay in twap-monitor (was 34
— the 21 that moved live in shepherd-sdk now), 7 stay in
ethflow-watcher (was 10).

.wasm size delta:
- twap-monitor: 300 K → 305 K (+5 K — SDK re-exports + slight
  link-table growth; alloy + cowprotocol deduped).
- ethflow-watcher: 272 K → 275 K (+3 K).

Same wire behaviour — the SDK migration is a pure refactor; no
new dispatch paths, no new key conventions.
@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

BLEU-843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant