Skip to content

[Frontend] Real-time escrow updates via Stellar event streaming #9

@Gbangbolaoluwagbemiga

Description

@Gbangbolaoluwagbemiga

Problem

The UI polls for contract state every 15 seconds. This means ~15s lag between a blockchain event and the UI reflecting it. Polling is also wasteful.

Solution

Subscribe to Horizon's Server-Sent Events for contract events (once issue #5 lands).

What needs to be done

  1. `src/hooks/useEscrowEvents.ts` — subscribe to Horizon SSE stream, parse XDR events, return via callback
  2. Wire into pages:
    • `DashboardPage` — refresh on `EscrowCreated` / `MilestoneApproved`
    • `ApprovalsPage` — refresh on `MilestoneSubmitted`
    • `MessagesPage` — replace `setInterval` with event stream
  3. Reconnect with exponential backoff
  4. Fallback to polling if Horizon SSE unavailable

Acceptance criteria

  • Milestone approval reflects in UI within 2s of on-chain confirmation
  • No `setInterval` polling for contract state
  • Reconnect logic with backoff
  • Works on local, testnet, mainnet Horizon

Depends on issue #5 (contract events)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvementfrontendReact / TypeScript UI workperformanceSpeed or gas/cost optimization

    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