Overview
src/commands/monitor.rs and src/utils/stream.rs implement contract event monitoring. Soroban RPC's getEvents requires polling with cursor-based pagination. Without proper cursor tracking, every poll re-fetches the same events, emitting duplicates, and there is no support for Horizon's native Server-Sent Events streaming for wallet activity.
Resolution
Implement proper cursor-based event polling in stream.rs: call getEvents with startLedger set to current ledger, get back a cursor in the response, store it, and use cursor as the start of the next poll. Handle the case where cursor advances past the retention window (Soroban only keeps ~7 days of events) by resetting to current ledger with a warning. Implement getEvents filter by contractIds: [...] and topics (Stellar event topics are ScVal arrays — encode them from CLI args). For monitor --wallet, use Horizon's Server-Sent Events (SSE) stream at /accounts/{id}/payments and /accounts/{id}/transactions which is truly streaming — parse the text/event-stream response using a streaming HTTP reader. Add --format json to output events as newline-delimited JSON for piping to jq. Implement --until-event <topic> that exits when a specific event is observed — useful in scripts and CI.
Overview
src/commands/monitor.rsandsrc/utils/stream.rsimplement contract event monitoring. Soroban RPC'sgetEventsrequires polling with cursor-based pagination. Without proper cursor tracking, every poll re-fetches the same events, emitting duplicates, and there is no support for Horizon's native Server-Sent Events streaming for wallet activity.Resolution
Implement proper cursor-based event polling in
stream.rs: callgetEventswithstartLedgerset to current ledger, get back acursorin the response, store it, and usecursoras the start of the next poll. Handle the case wherecursoradvances past the retention window (Soroban only keeps ~7 days of events) by resetting to current ledger with a warning. ImplementgetEventsfilter bycontractIds: [...]andtopics(Stellar event topics areScValarrays — encode them from CLI args). Formonitor --wallet, use Horizon's Server-Sent Events (SSE) stream at/accounts/{id}/paymentsand/accounts/{id}/transactionswhich is truly streaming — parse thetext/event-streamresponse using a streaming HTTP reader. Add--format jsonto output events as newline-delimited JSON for piping tojq. Implement--until-event <topic>that exits when a specific event is observed — useful in scripts and CI.