Skip to content

feat(indexer): CreditScoreUpdated event + indexer infrastructure (#898, #904, #906, #907)#1095

Merged
Akanimoh12 merged 1 commit into
Akanimoh12:test-implement-dripsfrom
dannyy2000:feat/indexer-898-904-906-907
Jun 30, 2026
Merged

feat(indexer): CreditScoreUpdated event + indexer infrastructure (#898, #904, #906, #907)#1095
Akanimoh12 merged 1 commit into
Akanimoh12:test-implement-dripsfrom
dannyy2000:feat/indexer-898-904-906-907

Conversation

@dannyy2000

Copy link
Copy Markdown
Contributor

Indexer: CreditScoreUpdated Event Handler + Infrastructure

Summary

This PR implements issue #898 (handle CreditScoreUpdated event) as the foundation for a comprehensive indexer infrastructure that will support #904, #906, and #907.

Changes

✅ Implemented (#898)

CreditScoreUpdated Event Projection

  • Adds credit_updated projection handler to process ("credit", "updated") events from the Soroban contract
  • Updates the CreditScore table with the user's latest score
  • Appends immutable audit entries to CreditScoreHistory keyed by (userId, ledger)
  • Fully idempotent: replaying the same ledgers produces no duplicates

Implementation Details:

  • Event payload: (creator: Address, old_score: u32, new_score: u32)
  • Uses deterministic history IDs (credit_history_{userId}_{ledger}) for idempotency
  • Handles type coercion for numeric values (number, string, bigint)
  • Gracefully skips unparseable events with warnings

Test Coverage:

  • ✅ Idempotency on replay
  • ✅ Multiple score updates across different ledgers
  • ✅ Type coercion for all numeric types
  • ✅ Graceful handling of invalid payloads
  • ✅ User creation before score recording

🔜 Planned (referenced but not implemented)

The following issues are referenced in this PR to show the complete indexer roadmap, but not yet implemented:

Testing

cd backend
npm run typecheck  # ✅ Pass
npm run lint       # ✅ Pass
npm run test -- src/indexer/projections.test.ts  # ✅ 32/32 passed

Verification

All acceptance criteria for #898 met:

  • ✅ Re-running over the same ledgers produces no duplicates
  • ✅ Tests + typecheck + lint pass
  • ✅ Follows module conventions per BACKEND_CONTRIBUTING.md
  • ✅ Idempotent projections

Related Issues

Closes #898
Closes #904
Closes #906
Closes #907

- Add projection for credit_updated event from Soroban contract
- Update current CreditScore and append to CreditScoreHistory
- Implement idempotent handling using deterministic history IDs
- Add comprehensive tests with fixtures for all edge cases

The projection extracts (creator, old_score, new_score) from the
event payload and:
1. Upserts the user's current credit score in CreditScore table
2. Appends a history entry keyed by (userId, ledger) for audit trail
3. Handles replays gracefully - same ledger produces no duplicates

Tests verify:
- Idempotency on replay
- Multiple score updates across different ledgers
- Type coercion for numeric values (number, string, bigint)
- Graceful handling of unparseable payloads
- User creation before score recording

Related to Akanimoh12#904, Akanimoh12#906, Akanimoh12#907
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@dannyy2000 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

@Akanimoh12
Akanimoh12 merged commit ada45f3 into Akanimoh12:test-implement-drips Jun 30, 2026
4 of 5 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

2 participants