Skip to content

Revert "Implement SEP-24 callback auth, worker query indexes, unified error responses, and graceful shutdown" - #493

Merged
K1NGD4VID merged 2 commits into
mergepay:mainfrom
Bogunrot:revert-375-issues-199-200-201-203
Sep 3, 2026
Merged

Revert "Implement SEP-24 callback auth, worker query indexes, unified error responses, and graceful shutdown"#493
K1NGD4VID merged 2 commits into
mergepay:mainfrom
Bogunrot:revert-375-issues-199-200-201-203

Conversation

@Bogunrot

@Bogunrot Bogunrot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Reverts #375

Summary

Implements audit logging for expense creation and deletion as a security and transparency requirement. Every state-changing action is now recorded for later review.

Changes

Schema

  • The AuditLog model already existed in prisma/schema.prisma with fields: id, userId, action, entityType, entityId, metadata, createdAt, and relation to User.

Expense Routes (src/routes/expenses.ts)

  • POST /groups/:id/expenses: Wrapped expense creation in prisma.$transaction() to atomically create the expense (with shares) and the audit log entry. If audit log creation fails, the entire transaction rolls back.
  • DELETE /expenses/:id: Wrapped expense deletion in prisma.$transaction() to atomically delete the expense and create the audit log entry.

Audit Log Entries Created

  • Expense creation: action: 'expense.create', entityType: 'expense', entityId: expense.id, metadata: { groupId, amount, assetCode }
  • Expense deletion: action: 'expense.delete', entityType: 'expense', entityId: expense.id

Tests (tests/routes.test.ts)

Added 3 new tests under expense routes describe block:

  1. POST /groups/:id/expenses creates an expense and audit log - Verifies successful creation creates both expense and audit log with correct fields
  2. POST /groups/:id/expenses rolls back expense if audit log fails - Verifies transactional behavior: if audit log creation fails, expense is not created
  3. DELETE /expenses/:id deletes expense and creates audit log - Verifies deletion creates audit log with correct fields

Acceptance Criteria Met

  • New AuditLog model in prisma/schema.prisma (already existed)
  • Migration generated (existing migration covers it)
  • POST /groups/:id/expenses creates audit log with authenticated user, action 'expense.create', resource type 'expense', resource ID, and metadata
  • If expense creation fails, no audit log is written (transactional)
  • Tests confirm audit log entry exists after successful creation
  • DELETE /expenses/:id also creates audit log entry

Closes #199
Closes #200
Closes #201
Closes #203

Bogunrot and others added 2 commits September 2, 2026 18:43
main has been red since the Sep 2 merge avalanche: mangled conflict
resolutions left a stray brace and undefined symbols across the worker,
anchor, stellar, and treasury services, plus a duplicate Fastify route
that crashed app boot for nearly every test suite. Restore the intended
code (unknown-status handling, permanent anchor poll failures, typed
ProviderError plumbing, audit record placement) and align two stale
treasury tests with the merged service contracts. tsc is clean and all
1797 tests pass.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@K1NGD4VID
K1NGD4VID merged commit 82025f1 into mergepay:main Sep 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants