Skip to content

feat: Portfolio Performance API Endpoints (#327)#127

Open
Ebenezer199914 wants to merge 1 commit into
Open-audit-foundation:mainfrom
Ebenezer199914:feat/portfolio-performance-api-327
Open

feat: Portfolio Performance API Endpoints (#327)#127
Ebenezer199914 wants to merge 1 commit into
Open-audit-foundation:mainfrom
Ebenezer199914:feat/portfolio-performance-api-327

Conversation

@Ebenezer199914

Copy link
Copy Markdown

Summary

Implements issue #327 — Portfolio Performance API Endpoints.

New Endpoints

Method Path Description
GET /api/portfolio/performance Aggregated metrics: total events, unique contracts, top contracts, time window
GET /api/portfolio/[address]/performance Per-address metrics: events involving the address, unique contracts, recent activity

Both endpoints accept optional from / to Unix timestamp query params (default: last 24 hours) and return 400 on invalid windows.

Pre-existing Test Failures Fixed

Fix File
Added missing exports: interpolateTemplate, isValidHex, sanitizeHex, escapeHtml, detectScValType, decodeMap, decodeVec, decodeEnum, decodeScVal lib/translator/decode.ts
Added missing imports for all decode helpers, matchesEventCriteria, TranslationBlueprint lib/translator/decode.test.ts
Cryptic events now return a placeholder description + console.warn lib/translator/registry.ts
extractContractId handles SDK Contract objects lib/stellar/events.ts
paginationCursor persisted on cursor update lib/stellar/indexer.ts
Removed duplicate steps: key .github/workflows/validate-registry.yml
Added @/* path alias + ioredis mock alias vitest.config.ts
In-memory Redis mock so tests run without Redis __mocks__/ioredis.ts

Test Results

Test Files  7 passed (7)
Tests       56 passed (56)

Closes #327

- Add GET /api/portfolio/performance — aggregated metrics
- Add GET /api/portfolio/[address]/performance — per-address metrics
- Add tests for both endpoints (6 tests)

Fix pre-existing test failures:
- decode.ts: add missing exports (interpolateTemplate, isValidHex,
  sanitizeHex, escapeHtml, detectScValType, decodeMap, decodeVec,
  decodeEnum, decodeScVal)
- decode.test.ts: add missing imports (matchesEventCriteria,
  TranslationBlueprint and all decode helpers)
- registry.ts: return placeholder description + console.warn for
  cryptic events (fixes registry.fallback.test.ts)
- events.ts: handle SDK Contract objects in extractContractId
  (fixes client.integration.test.ts)
- indexer.ts: persist paginationCursor on cursor update
  (fixes indexer.test.ts)
- vitest.config.ts: add @/* path alias and ioredis mock alias
- __mocks__/ioredis.ts: in-memory Redis mock for tests
- .github/workflows/validate-registry.yml: remove duplicate 'steps' key

All 56 tests pass.
@Osuochasam

Copy link
Copy Markdown
Collaborator

@Ebenezer199914 Resolve conflicts

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.

2 participants