Feature: On-Chain Bounty Status Sync and Event Listener
Overview
The Bounty Registry contract emits events for all state changes (BountyCreated, BountyApplied, BountyAssigned, WorkSubmitted, SubmissionApproved, BountyClaimed, BountyCancelled, etc.). The frontend needs to listen to these events for real-time status updates and data consistency between on-chain and off-chain state.
Depends on: #139 (TypeScript contract bindings)
Goals
- Sync frontend bounty state with on-chain contract state
- Listen to contract events for real-time updates
- Reconcile GraphQL data with on-chain truth
- Handle state conflicts gracefully
Contract Events
BountyCreated { bounty_id, creator }
BountyApplied { bounty_id, applicant }
BountyAssigned { bounty_id, assignee }
WorkSubmitted { bounty_id, submitter }
SubmissionApproved { bounty_id, winner }
BountyClaimed { bounty_id, claimer }
BountyCancelled { bounty_id, reason }
SplitApproved { bounty_id, amount }
ApplicationRejected { bounty_id, applicant }
Implementation Details
1. Contract Event Poller
Create: lib/contracts/event-listener.ts
- Poll Stellar RPC for contract events at interval
- Parse event topics and data
- Dispatch to relevant query cache invalidations
2. On-Chain Status Verification Hook
Create: hooks/use-onchain-bounty.ts
useOnChainBounty(bountyId) — reads directly from contract
- Compare with GraphQL data for consistency
- Show "verified on-chain" indicator
3. Transaction Confirmation Tracker
Create: hooks/use-transaction-status.ts
- After submitting a transaction, track confirmation
- Show pending → confirmed → finalized states
- Link to Stellar explorer for verification
Files Affected
Created
lib/contracts/event-listener.ts
hooks/use-onchain-bounty.ts
hooks/use-transaction-status.ts
components/bounty/onchain-status-badge.tsx
Acceptance Criteria
Feature: On-Chain Bounty Status Sync and Event Listener
Overview
The Bounty Registry contract emits events for all state changes (BountyCreated, BountyApplied, BountyAssigned, WorkSubmitted, SubmissionApproved, BountyClaimed, BountyCancelled, etc.). The frontend needs to listen to these events for real-time status updates and data consistency between on-chain and off-chain state.
Depends on: #139 (TypeScript contract bindings)
Goals
Contract Events
Implementation Details
1. Contract Event Poller
Create:
lib/contracts/event-listener.ts2. On-Chain Status Verification Hook
Create:
hooks/use-onchain-bounty.tsuseOnChainBounty(bountyId)— reads directly from contract3. Transaction Confirmation Tracker
Create:
hooks/use-transaction-status.tsFiles Affected
Created
lib/contracts/event-listener.tshooks/use-onchain-bounty.tshooks/use-transaction-status.tscomponents/bounty/onchain-status-badge.tsxAcceptance Criteria