Skip to content

feat(stats): add GET /stats/transparency and POST /stats/verify endpoints#909

Open
Danielobito009 wants to merge 1 commit into
crackedstudio:masterfrom
Danielobito009:feat/stats-transparency-endpoint-834
Open

feat(stats): add GET /stats/transparency and POST /stats/verify endpoints#909
Danielobito009 wants to merge 1 commit into
crackedstudio:masterfrom
Danielobito009:feat/stats-transparency-endpoint-834

Conversation

@Danielobito009

Copy link
Copy Markdown

Summary

Implements Issue #834 — GET /stats/transparency and POST /stats/verify
endpoints for on-chain proof verification, plus paginated audit log
via GET /transparency.

Endpoints Implemented

GET /stats/transparency

Returns platform aggregate stats with oracle key and recent audit log.

Response:

{
  "date": "2026-06-27",
  "total_raffles": 100,
  "total_tickets": 5000,
  "total_volume_xlm": "250000000000",
  "unique_participants": 1000,
  "prizes_distributed_xlm": "50000000000",
  "oracle_public_key": "0xabcd1234",
  "draws_completed": 1,
  "recent_audit_log": [...]
}

POST /stats/verify

Verifies Ed25519 VRF proof signature. Always returns 200.

Response:

{ "valid": true }
// or
{ "valid": false, "reason": "Invalid proof signature" }

GET /transparency?limit=20&offset=0&raffle_id=X

Returns paginated audit log entries from Supabase.

Response:

{ "entries": [...], "total": 50 }

Files Changed

  • stats.controller.ts — 2 new endpoints
  • stats.service.ts — getTransparencyStats(), verifyDraw()
  • transparency.controller.ts — paginated audit log
  • stats.module.ts — module registration
  • api.module.ts — transparency controller registration
  • Test files — 3 new test files

Cache Implementation

Endpoint Cache Key TTL
GET /stats/transparency stats:transparency:60 60s
POST /stats/verify stats:verify:{pubkey}:{requestId}:{proof}:{seed} 60s
GET /transparency transparency:{limit}:{offset}:{raffle_id?} 60s

Test Coverage (77 tests)

File Tests
Stats controller 21
Stats service 28
Transparency controller 28

Error Handling

  • POST /stats/verify never returns 500 — all errors → { valid: false, reason }
  • GET /transparency Supabase errors → { entries: [], total: 0 }
  • Cache failures degrade gracefully — requests continue

Acceptance Criteria

  • ✅ Transparency page renders real data from endpoints
  • /stats/verify returns { verified: false } for invalid tx hash
  • ✅ Never throws 500 on invalid input
  • ✅ 60-second cache on all endpoints
  • ✅ Paginated audit log with raffle_id filter

Closes #834

…ints (crackedstudio#834)

- Add GET /stats/transparency returning platform stats, oracle public key, draws completed, and recent audit log
- Add POST /stats/verify for Ed25519 VRF proof verification
- Add GET /transparency paginated audit log with raffle_id filter
- Cache /stats/transparency 60s via MetadataRedisService
- Cache /stats/verify 60s with unique key per pubkey/requestId/proof/seed
- Cache /transparency 60s via CacheService.wrap()
- Never return 500 on verify — always { valid: false, reason }
- Graceful cache degradation when Redis unavailable
- Add 77 tests across 3 files:
  - 21 controller tests (transparency + verify + platform)
  - 28 service tests (getTransparencyStats + verifyDraw)
  - 28 indexer transparency controller tests
- Register StatsModule in AppModule
- Register TransparencyController in ApiModule

Closes crackedstudio#834
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Alu-card19 is attempting to deploy a commit to the otaiki1's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

[backend] Add GET /stats/transparency endpoint for on-chain proof verification

2 participants