Skip to content

core: build unified transaction service for build-sign-submit-poll #83

Description

@EmeditWeb

Problem

Transaction signing is duplicated and stubbed across the app instead of
living in one service. Vouch.tsx signs a fake placeholder XDR (#55),
Vouch.handleDecline simulates the call with setTimeout (#66), and sponsor
onboarding step 4 has no real deposit flow (#56). Every feature reinvents —
and fakes — the build → sign → submit → poll sequence, so no real contract
transaction is ever completed from the web app.

Before Starting

Read ALL of these before writing any code:

  • context/architecture-context.md
  • context/code-standards.md

What To Build

A single transaction service that owns the full lifecycle behind a wallet
adapter:

  1. Request the unsigned XDR from the API services layer (never build
    contract calls in components).
  2. Sign via a pluggable wallet adapter (Freighter / Albedo /
    StellarWalletsKit) resolved from wallet.store.
  3. Submit and poll transaction status to resolution, returning a typed
    result with discriminated error states (rejected, expired, failed,
    insufficient funds).
  4. Surface a shared useTransaction hook driving pending / signing /
    submitted / confirmed / error UI, and replace the fake flows in Vouch and
    Sponsors with it.

Files To Touch

  • src/services/transaction.service.ts (new)
  • src/hooks/useTransaction.ts (extend existing)
  • src/stores/wallet.store.ts
  • src/pages/Vouch.tsx, src/pages/Sponsors.tsx (replace stubs)

Acceptance Criteria

  • One service owns build → sign → submit → poll for all features
  • Wallet adapter is pluggable (at least Freighter) via wallet.store
  • Typed result with explicit rejected/expired/failed states
  • Vouch and Sponsors use the real flow; no setTimeout or fake XDR remain
  • Loading, error, and empty states handled; no API calls in page files
  • Unit tests cover success, rejection, and timeout paths

Mandatory Checks Before Opening PR

  • All context/ files read and understood
  • npm run lint passes with zero errors
  • npm run build passes with zero errors
  • npm test passes — test count not decreased
  • No hardcoded hex colors; icons from lucide-react only
  • No API calls in page files
  • Tested on 375px mobile viewport
  • PR references this issue number

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions