Skip to content

feat: durable transaction-tracking layer (closes #52)#52

Open
aojomo wants to merge 1 commit into
StepFi-app:mainfrom
aojomo:feat/durable-tx-tracking-46
Open

feat: durable transaction-tracking layer (closes #52)#52
aojomo wants to merge 1 commit into
StepFi-app:mainfrom
aojomo:feat/durable-tx-tracking-46

Conversation

@aojomo

@aojomo aojomo commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Implements a durable transaction-tracking layer for reliable on-chain resolution tracking after a learner signs and submits a transaction. Fixes the issue where loans.store.ts had no persistence, losing simulatedAmount, cached loans, and pending payments on restart.

Changes

Data Layer

  • types/transaction.types.ts — Added pending transaction types
  • services/transactions.service.ts — Added getTxStatus(txHash) for polling on-chain resolution

Persisted Queue

  • src/transactions/pending-queue.ts — Full CRUD persisted queue using AsyncStorage
  • Records: tx hash, type, target loan, installment index, amount, status, retry count

Background Poller

  • src/transactions/transaction-poller.ts — Exponential backoff (2s→60s, 15 retries max)
  • Per-tx concurrency locks to prevent race conditions
  • On terminal status: idempotent loan state reconciliation

Loan Store Persistence

  • stores/loans.store.ts — Zustand persist middleware with AsyncStorage
  • markInstallmentPaid() with idempotency guard via processedTxHashes
  • Bounded processed list (200 max), auto-transition to paid status
  • clearLoans() resets all persisted state

Reconciliation

  • app/_layout.tsx — Triggers on AppState→active via reconcilePendingTxs()
  • Poller lifecycle starts when authenticated

UI Indicators

  • app/(tabs)/index.tsx — Pending banner + recent activity section
  • app/(tabs)/loans.tsx — Per-loan PendingTxBadge + full status sections

Tests

  • src/transactions/tests/pending-queue.test.ts — 10 tests covering CRUD and edge cases
  • stores/tests/loans.store.test.ts — 5 tests covering idempotency, auto-transition, persistence

Closes #46

@aojomo
aojomo requested a review from EmeditWeb as a code owner July 22, 2026 15:44
@aojomo aojomo changed the title feat: durable transaction-tracking layer (closes #46) feat: durable transaction-tracking layer (closes #52) Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: implement transaction-status tracking and reconciliation for payments

1 participant