Skip to content

feat: implement WebSocket endpoint for real-time sale notifications #2

Description

@brightpixel-dev

Overview

Producers should receive real-time notifications when their beats are purchased. The backend already streams Horizon contract transactions via SSE — wrap this in a WebSocket endpoint so the frontend and mobile can subscribe to events.

Acceptance Criteria

  • GET /ws upgrades to WebSocket connection
  • Server broadcasts sale events: { type: 'sale', sampleId, tier, buyer, amountXlm, timestamp }
  • Producers can subscribe to events for their address specifically
  • Auto-reconnect logic on the client side (exponential backoff)
  • Graceful connection cleanup on disconnect

Implementation

Use the ws package. Integrate with the existing streamContractTransactions service in stellar.ts. Parse Soroban event data to extract the sale details from the contract event topics.

// Suggested event shape
interface SaleEvent {
  type: 'sale';
  sampleId: number;
  tier: 0 | 1 | 2;
  buyer: string;
  producer: string;
  amountXlm: string;
  timestamp: string;
}

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignenhancementNew feature or request

Type

No type

Fields

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