Skip to content

feat: build indexer, project/portfolio endpoints, and admin tests#135

Closed
0x860 wants to merge 4 commits into
Heliobond:mainfrom
0x860:implement-issues-1-2-3-4
Closed

feat: build indexer, project/portfolio endpoints, and admin tests#135
0x860 wants to merge 4 commits into
Heliobond:mainfrom
0x860:implement-issues-1-2-3-4

Conversation

@0x860

@0x860 0x860 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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.

gotethry added 4 commits June 26, 2026 20:42
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
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@0x860 0x860 closed this by deleting the head repository Jun 26, 2026
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