feat: build indexer, project/portfolio endpoints, and admin tests#135
Closed
0x860 wants to merge 4 commits into
Closed
feat: build indexer, project/portfolio endpoints, and admin tests#1350x860 wants to merge 4 commits into
0x860 wants to merge 4 commits into
Conversation
Resolves #1 - Add event indexer at src/lib/indexer.ts with VaultEvent and IndexerStore types - Implement poll() to fetch contract events from RPC starting from saved cursor - Make ingestion idempotent by checking for duplicate txHash - Support resetCursor() for replayability - Add event filtering by address for portfolio queries - Wire indexer polling into cron job to run every 5 minutes
Resolves #2 - Create GET /projects with pagination (limit, cursor) - Create GET /projects/:id with detailed project info - Aggregate indexed data with registry reads for scores and funding - Return full project data including solar, satellite, and computed scores - Validate project ID on detail endpoint
Resolves #3 - Create GET /portfolio/:address endpoint for user positions - Compute current_shares by replaying deposit/withdraw events chronologically - Calculate current_value using price_per_share from vault state - Return full event history sorted by timestamp descending - Validate address parameter
Resolves #4 - Test happy path: authenticated request with valid payload submits scores - Test happy path: handle specific project_ids in request body - Test unauthorized rejection: missing authorization header returns 401 - Test unauthorized rejection: wrong or malformed token returns 401 - Test bad input handling: invalid project_ids type defaults to all projects - Test bad input handling: empty project_ids array defaults to all projects - Test bad input handling: partial failures return results and errors separately - Test optional auth: allow unauthenticated requests when ADMIN_API_KEY not set - Mock RPC layer with jest mocks for isolated, deterministic tests
|
@0x860 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Complete implementation of the Heliobond backend event indexer, REST API endpoints for project and portfolio data, and comprehensive integration tests for the admin oracle-score endpoint.
Issues Resolved
Closes #1
Closes #2
Closes #3
Closes #4
Changes
#1 - Build the event indexer: ingest contract events into a queryable store
Implemented event indexer that polls Stellar RPC for contract events, stores them idempotently, and tracks cursor position for replay capability. Added 5-minute cron job to keep events current.
#2 - Add REST endpoints for project list and project detail
Created GET /projects (paginated) and GET /projects/:id endpoints that aggregate indexed data with registry reads. Returns full project metadata including scores, funding, and sensor readings.
#3 - Add a portfolio endpoint: positions and history for an address
Implemented GET /portfolio/:address endpoint that reconstructs user positions by replaying deposit/withdraw events chronologically, computes current share balance and valuation, and returns complete event history.
#4 - Add integration tests for the admin oracle-score endpoint
Added comprehensive test suite covering happy path authentication and score submission, unauthorized rejection scenarios, bad input handling, and partial failure recovery. All RPC calls are mocked for fast, deterministic testing.