Skip to content

Implement On-Chain Bounty Status Sync and Event Listener #147

@0xdevcollins

Description

@0xdevcollins

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

  • Contract events trigger UI updates
  • On-chain status readable for any bounty
  • Transaction confirmation tracked after submission
  • Status conflicts between GraphQL and on-chain detected

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions