Skip to content

starforge monitor Polls for Events Without Cursor Tracking or SSE Streaming #15

Description

@Nanle-code

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.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions