Skip to content

feat: Soroban RPC client, idempotent DB writes, and Prometheus metrics (#349, #357, #356) - #380

Merged
cypriannwokolo2-creator merged 3 commits into
cocor-tech:masterfrom
linesofcodes0-cloud:feat/issues-349-357-356
Aug 31, 2026
Merged

feat: Soroban RPC client, idempotent DB writes, and Prometheus metrics (#349, #357, #356)#380
cypriannwokolo2-creator merged 3 commits into
cocor-tech:masterfrom
linesofcodes0-cloud:feat/issues-349-357-356

Conversation

@linesofcodes0-cloud

Copy link
Copy Markdown

Closes #349
Closes #357
Closes #356

Fixes #349
Fixes #357
Fixes #356

Resolves #349
Resolves #357
Resolves #356

#349
#357
#356

Linked Issues

Summary

This PR resolves three frontend features/issues on cocor-tech/moistello-frontend:

1. Soroban RPC client with retry logic (Closes #349)

  • Feature: Created SorobanRpcClient in src/lib/soroban/rpc-client.ts.
  • Implementation:
    • Added exponential backoff retry logic with jitter.
    • Implemented request timeout handling using AbortController (30s default timeout).
    • Categorized Soroban RPC errors into domain error classes (SorobanNetworkError, SorobanTimeoutError, SorobanRPCError, SorobanContractError).
    • Added domain convenience helpers (getHealth, getAccount, getTransaction, sendTransaction, simulateTransaction).
    • Added full test suite in src/lib/soroban/__tests__/rpc-client.test.ts.

2. Idempotent DB writes for event processing (Closes #357)

  • Feature: Created IdempotentEventStore in src/lib/events/idempotent-event-store.ts.
  • Implementation:
    • Implemented SQL INSERT ON CONFLICT (idempotency_key) DO NOTHING query builder.
    • Added transaction hash and event idempotency key deduplication (tx_hash:log_index).
    • Gracefully handles duplicate event replays without side effects or errors.
    • Added full test suite in src/lib/events/__tests__/idempotent-event-store.test.ts.

3. Prometheus metrics for indexer and API (Closes #356)

  • Feature: Created PrometheusRegistry in src/lib/metrics/prometheus-registry.ts and exposed GET /api/metrics in src/app/api/metrics/route.ts.
  • Implementation:
    • Implemented events_processed counter (event_type, status).
    • Implemented events_failed counter (error_type).
    • Implemented cursor_lag gauge.
    • Implemented db_write_latency histogram with configurable buckets.
    • Implemented reconciler_runs counter (status).
    • Created GET /api/metrics returning Prometheus text exposition format (text/plain; version=0.0.4; charset=utf-8).
    • Added full test suites in src/lib/metrics/__tests__/prometheus-registry.test.ts and src/app/api/metrics/__tests__/route.test.ts.

Verification

  • Unit tests: 18/18 passed across all newly added modules.

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Nzubechukwu 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@linesofcodes0-cloud 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

@linesofcodes0-cloud

Copy link
Copy Markdown
Author

Closes #349
Closes #357
Closes #356

Fixes #349
Fixes #357
Fixes #356

Resolves #349
Resolves #357
Resolves #356

#349
#357
#356

@cypriannwokolo2-creator
cypriannwokolo2-creator merged commit 3e1a2a8 into cocor-tech:master Aug 31, 2026
1 check failed
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