Skip to content

feat: implement #217-220 – audit log, composite indexes, token resolu… - #336

Open
Blak-Codes wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
Blak-Codes:feat/217-220-audit-indexes-token-routing
Open

feat: implement #217-220 – audit log, composite indexes, token resolu…#336
Blak-Codes wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
Blak-Codes:feat/217-220-audit-indexes-token-routing

Conversation

@Blak-Codes

Copy link
Copy Markdown

…tion, routing

closes #217 – Persist intent audit trail to intent_audit_log table

  • Add IntentAuditLog model to prisma/schema.prisma (FK → intents.intent_id, audit_log_intent_idx composite index on (intent_id, timestamp ASC))
  • Migration: 20260828000002_intent_audit_log
  • IntentsService.appendAuditEntry() writes to DB via PrismaService (fire-and-forget; failure logs loudly but never blocks the caller)
  • IntentsService.getAuditLog() reads from in-memory log (fast path)
  • New endpoint: GET /api/v1/intents/:id/audit → full trail oldest-first
  • New endpoint: GET /api/v1/intents/:id/quote → persisted quotedDstAmount
  • Unit tests: append/read round-trip, DB write, DB failure resilience
  • e2e tests: cancel, expire, slash paths via audit-trail.e2e-spec.ts
  • DATABASE_INDEXES.md section 3 marked ✅ implemented

closes #218 – Add composite and partial Postgres indexes

  • Migration: 20260828000001_composite_partial_indexes
  • intents_user_created_idx ON intents (user, created_at DESC)
  • intents_state_created_idx ON intents (state, created_at DESC)
  • intents_open_partial_idx ON intents (created_at DESC) WHERE state = 'open'

closes #219 – Extract duplicated token-resolution logic out of IntentsController

  • TokensService.resolveSrcToken(chain, address) → ResolvedSrcToken | undefined
  • TokensService.resolveDstToken(contract) → ResolvedDstToken | undefined
  • Both methods fully typed (no any); discriminated kind: 'src' | 'dst'
  • IntentsController.create() and quote() now call the shared methods
  • Fixed pre-existing duplicate minDstAmount/deadline fragment in create() (was a merge artifact that caused object-literal drift between create/quote)
  • Unit tests: stellar, each EVM chain, not-found, empty-string cases
  • e2e tests extended for create with known/unknown token address

closes #220 – Wire RoutingService into quote flow

  • RoutingService.buildRoute() selects direct vs two-hop strategy
  • Direct route (1 step, type=transfer) when src/dst share same symbol (USDC→USDC)
  • Two-hop route (2 steps, swap+bridge via USDC intermediate) for non-stable pairs
  • RouteOptions interface keeps RoutingService stateless/pure (no cross-module calls)
  • QuoteResponseDto updated: QuoteDto.route: RouteDto with RouteStepDto[]
  • e2e tests: USDC→USDC direct (1 step), WETH→XLM two-hop (2 steps), step shape
  • Unit tests: createDirectRoute, createTwoHopRoute, buildRoute strategy selection

Also: fix pre-existing syntax errors in test/intents.e2e-spec.ts (missing closing braces, undefined USER_KP/ALPHA_KP/BETA_KP/sign/build* imports) and add PrismaService mock to intents.gateway.spec.ts / intents-sweeper.service.spec.ts

Summary

Related issue

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • CI / tooling

Component

  • Contract (vortex-contract)
  • Backend (vortex-backend)
  • Frontend (vortex-frontend)

Checklist

  • My code follows the project's style and conventions
  • I ran lint / type-check / build locally and they pass
  • I added or updated tests where appropriate
  • I updated documentation where appropriate
  • My commits follow Conventional Commits

Screenshots / notes

…e indexes, token resolution, routing

stellar-vortex-protocol#217 – Persist intent audit trail to intent_audit_log table
- Add IntentAuditLog model to prisma/schema.prisma (FK → intents.intent_id,
  audit_log_intent_idx composite index on (intent_id, timestamp ASC))
- Migration: 20260828000002_intent_audit_log
- IntentsService.appendAuditEntry() writes to DB via PrismaService
  (fire-and-forget; failure logs loudly but never blocks the caller)
- IntentsService.getAuditLog() reads from in-memory log (fast path)
- New endpoint: GET /api/v1/intents/:id/audit → full trail oldest-first
- New endpoint: GET /api/v1/intents/:id/quote → persisted quotedDstAmount
- Unit tests: append/read round-trip, DB write, DB failure resilience
- e2e tests: cancel, expire, slash paths via audit-trail.e2e-spec.ts
- DATABASE_INDEXES.md section 3 marked ✅ implemented

stellar-vortex-protocol#218 – Add composite and partial Postgres indexes
- Migration: 20260828000001_composite_partial_indexes
- intents_user_created_idx  ON intents (user, created_at DESC)
- intents_state_created_idx ON intents (state, created_at DESC)
- intents_open_partial_idx  ON intents (created_at DESC) WHERE state = 'open'

stellar-vortex-protocol#219 – Extract duplicated token-resolution logic out of IntentsController
- TokensService.resolveSrcToken(chain, address) → ResolvedSrcToken | undefined
- TokensService.resolveDstToken(contract) → ResolvedDstToken | undefined
- Both methods fully typed (no any); discriminated kind: 'src' | 'dst'
- IntentsController.create() and quote() now call the shared methods
- Fixed pre-existing duplicate minDstAmount/deadline fragment in create()
  (was a merge artifact that caused object-literal drift between create/quote)
- Unit tests: stellar, each EVM chain, not-found, empty-string cases
- e2e tests extended for create with known/unknown token address

stellar-vortex-protocol#220 – Wire RoutingService into quote flow
- RoutingService.buildRoute() selects direct vs two-hop strategy
- Direct route (1 step, type=transfer) when src/dst share same symbol (USDC→USDC)
- Two-hop route (2 steps, swap+bridge via USDC intermediate) for non-stable pairs
- RouteOptions interface keeps RoutingService stateless/pure (no cross-module calls)
- QuoteResponseDto updated: QuoteDto.route: RouteDto with RouteStepDto[]
- e2e tests: USDC→USDC direct (1 step), WETH→XLM two-hop (2 steps), step shape
- Unit tests: createDirectRoute, createTwoHopRoute, buildRoute strategy selection

Also: fix pre-existing syntax errors in test/intents.e2e-spec.ts (missing
closing braces, undefined USER_KP/ALPHA_KP/BETA_KP/sign/build* imports)
and add PrismaService mock to intents.gateway.spec.ts / intents-sweeper.service.spec.ts
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Blak-Codes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Labels

None yet

Projects

None yet

1 participant