Skip to content

core: implement transaction-status tracking and reconciliation for payments #46

Description

@EmeditWeb

Problem

After a learner signs and submits a transaction there is no reliable tracking
of its on-chain resolution. loans.store.ts has no persistence (#38), so
simulatedAmount, cached loans, and any pending payment are lost on restart.
If a repayment is submitted while the app is backgrounded or killed, it
disappears from the UI with no way to recover its status. There is no pending
-transaction queue, no status polling, and no reconciliation on resume.

Before Starting

Read ALL of these before writing any code:

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

What To Build

A durable transaction-tracking layer:

  1. A persisted pending-transaction queue (Zustand persist / secure storage)
    recording each submitted tx hash, type, and target loan.
  2. Background/foreground status polling against the API until each tx reaches
    a terminal state (confirmed / failed / expired), with exponential backoff.
  3. Reconciliation on app resume: re-check any still-pending tx and update loan
    state accordingly, surfacing success/failure to the user.
  4. Idempotent updates so a tx confirmed while offline is not double-counted.

Files To Touch

  • stores/loans.store.ts (persistence)
  • src/transactions/* (pending queue + poller)
  • services/transactions.service.ts
  • relevant screens (pending/confirmed/failed UI)

Acceptance Criteria

  • Submitted transactions persist across restart and background/kill
  • Status polled to a terminal state with backoff
  • Pending txs reconciled on app resume and reflected in loan state
  • Updates idempotent; no double-counting on reconnect
  • Success/failure surfaced to the user; tests cover queue + reconciliation

Mandatory Checks Before Opening PR

  • All context/ files read and understood
  • npx expo export --platform web passes
  • No TypeScript errors
  • No hardcoded hex colors (constants/colors.ts only)
  • Icons from lucide-react-native only
  • Loading, error, and empty states handled
  • PR references this issue number

Metadata

Metadata

Assignees

No one assigned

    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