Skip to content

feat: implement persistent event indexer with sqlite storage (#77) - #731

Merged
orunganiekan merged 3 commits into
SiLioLabs:masterfrom
Abdullahi-Code9:feat/event-indexer-sqlite
Jul 31, 2026
Merged

feat: implement persistent event indexer with sqlite storage (#77)#731
orunganiekan merged 3 commits into
SiLioLabs:masterfrom
Abdullahi-Code9:feat/event-indexer-sqlite

Conversation

@Abdullahi-Code9

Copy link
Copy Markdown
Contributor

Closes #583

📝 Description

This PR introduces a persistent event indexer (scripts/indexer.ts) and a CLI query tool (scripts/query-events.ts) backed by SQLite. It captures Soroban contract events, persists them locally for off-chain reconciliation and debugging, tracks progress across restarts, and provides instant CLI querying capabilities.

🚀 Changes Made

1. Persistent Event Indexer (scripts/indexer.ts)

  • SQLite Persistence: Stores contract events in data/events.db using Node's native node:sqlite (DatabaseSync).
  • Resumable Indexing: Stores the last indexed ledger sequence in indexer_meta. On service restart, indexing resumes seamlessly from the recorded checkpoint.
  • Idempotent Storage & Batch Processing: Leverages explicit SQL transactions (BEGIN / COMMIT / ROLLBACK) for batch inserts while handling duplicate events idempotently using composite keys.

2. Event Query CLI Utility (scripts/query-events.ts)

  • Implemented CLI query filters to query persisted events:
    • By account/address (--address)
    • By event type (--type)
    • By ledger range (--from-ledger, --to-ledger)

3. Type Safety & API Fixes

  • Handled node:sqlite SQLOutputValue[] return types safely with explicit row interfaces.
  • Maintained compatibility fixes for @stellar/stellar-sdk across helper scripts.

🧪 Verification & Testing

Type Safety Verification

Verified strict TypeScript types across all scripts:

npx tsc --noEmit

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Abdullahi-Code9 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

@Abdullahi-Code9
Abdullahi-Code9 force-pushed the feat/event-indexer-sqlite branch from 36fcc75 to b0539d3 Compare July 31, 2026 12:43
@orunganiekan
orunganiekan merged commit d2f5393 into SiLioLabs:master Jul 31, 2026
0 of 2 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.

## Issue #77: Build Persistent Event Indexer with SQLite Storage

2 participants