Skip to content

[Backend] Hardcoded 'singleton' INDEXER_STATE_ID duplicated across files — extract to one constant #641

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

The string 'singleton' is used as the IndexerState row's primary key from at least four places — if anyone ever changes it, they have to find them all:

  • backend/src/workers/soroban-event-worker.ts:8const INDEXER_STATE_ID = 'singleton';
  • backend/src/services/indexerService.ts:5const INDEXER_STATE_ID = 'singleton';
  • backend/src/routes/health.routes.ts:65prisma.indexerState.findUnique({ where: { id: 'singleton' } }) (inline)
  • backend/src/routes/v1/admin.routes.ts:59prisma.indexerState.findUnique({ where: { id: 'singleton' } }) (inline)
  • backend/src/routes/adminRoutes.ts:106 — same inline (this file is also a duplicate addressed in [Backend] Reconcile duplicate admin metrics endpoints with divergent auth #542)

Acceptance criteria

  • Move the constant to a shared module (e.g. backend/src/lib/indexer-state.ts or extend indexerService.ts to export it)
  • All four other call sites import it
  • No behavior change

Files to touch

Out of scope

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomersrefactorRefactoring existing code

Type

No type
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