Skip to content

feat(api): add user earnings ledger - #633

Open
lukevio wants to merge 1 commit into
privexlabs:mainfrom
lukevio:feature/user-earnings
Open

feat(api): add user earnings ledger#633
lukevio wants to merge 1 commit into
privexlabs:mainfrom
lukevio:feature/user-earnings

Conversation

@lukevio

@lukevio lukevio commented Jun 28, 2026

Copy link
Copy Markdown

What

Adds authenticated GET /users/me/earnings for #454.

Why

Players need an in-app payout ledger so they can audit pending and settled USDC earnings with Stellar transaction references.

How

  • Adds /users/me/earnings protected by authenticate and requireActiveUser.
  • Scopes payout records to the authenticated user.
  • Supports status=pending|settled|failed|all with all as the default.
  • Implements cursor pagination using created_at + id, with default limit=25 and max 100.
  • Normalizes payout statuses into ledger statuses: pending, settled, or failed.
  • Returns stellar_tx_hash: null for records without a submitted transaction hash.
  • Adds totals for lifetime_earned_usdc and pending_usdc.
  • Adds focused route tests for status filtering, cursor pagination, normalized response shape, and totals aggregation.

Test plan

  • ./node_modules/.bin/vitest run apps/api/src/routes/users.earnings.test.ts
  • ./node_modules/.bin/prettier --check apps/api/src/routes/users.ts apps/api/src/routes/users.earnings.test.ts
  • git diff --cached --no-color | node scripts/gitleaks.mjs detect --pipe --redact --config .gitleaks.toml --verbose
  • ./node_modules/.bin/tsc -p apps/api/tsconfig.json --noEmit currently blocked by existing unrelated apps/api/src/routes/leaderboard.ts(196,1): error TS1128.

Note: the local Husky hook invokes pnpm gitleaks:pre-commit, but pnpm exits first due ignored build-script approvals for @fingerprintjs/fingerprintjs-pro-react and @sentry/cli. I ran the underlying staged-diff gitleaks command directly and it passed.

Closes #454

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.

Implement GET /api/users/me/earnings — paginated USDC payout history

1 participant