Skip to content

[FEAT] Backend: Implement Soroban Event Indexer #200#206

Merged
ogazboiz merged 2 commits intoLabsCrypt:mainfrom
CMI-James-OD:codex/issue-200-soroban-indexer-flowfi
Feb 26, 2026
Merged

[FEAT] Backend: Implement Soroban Event Indexer #200#206
ogazboiz merged 2 commits intoLabsCrypt:mainfrom
CMI-James-OD:codex/issue-200-soroban-indexer-flowfi

Conversation

@CMI-James
Copy link
Copy Markdown
Contributor

Description

Implement a Soroban polling indexer service in the backend to sync stream lifecycle events into Postgres for fast dashboard reads.

Closes #200

Changes proposed

What were you told to do?

I was asked to:

  • set up polling with Stellar RPC,
  • index StreamCreatedEvent into database records,
  • update stream status/data for StreamCancelledEvent and TokensWithdrawnEvent.

What did I do?

Added Soroban event polling indexer service

Created backend/src/services/soroban-indexer.service.ts:

  • polls Soroban RPC getEvents on interval,
  • filters by configured stream contract (STREAM_CONTRACT_ID),
  • tracks last indexed ledger in memory for incremental polling,
  • parses stream events from contract topics/payload.

Stream + event database synchronization logic

Implemented handlers for:

  • stream_created -> upsert users and create/update Stream row,
  • stream_cancelled -> mark Stream.isActive = false,
  • tokens_withdrawn -> increment withdrawnAmount and update active status.

All indexed events are persisted to StreamEvent, with duplicate guard by (streamId, eventType, transactionHash, ledgerSequence) lookup.

Startup wiring

Updated backend/src/index.ts to start the indexer after DB connection succeeds.

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • This PR does not contain plagiarized content.
  • The title and description of the PR is clear and explains the approach.
  • My commit messages styles matches our requested structure.
  • My code additions will fail neither code linting checks nor unit test.
  • I am only making changes to files I was requested to.

Screenshots / Testing Evidence

Attempted validation:

npm run build --workspace=backend

Build fails on pre-existing backend TypeScript issues unrelated to this PR (existing type/config errors in multiple backend files).

@ogazboiz ogazboiz merged commit f224f0a into LabsCrypt:main Feb 26, 2026
0 of 3 checks 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

Development

Successfully merging this pull request may close these issues.

[FEAT] Backend: Implement Soroban Event Indexer

2 participants