feat(api): implement on-chain reputation signal endpoint with Redis caching (Closes #332) - #358
Merged
jotel-dev merged 1 commit intoJul 29, 2026
Conversation
Wire GET /reputation/:address to trade history with validation, 60s Redis/memory cache, and integration tests (Closes Nullifier-Systems#332). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Implements the on-chain reputation signal API for Stellar accounts by computing trust metrics from trade history and caching results for improved performance.
What was implemented
Added GET /api/v1/reputation/:address endpoint to generate on-chain reputation metrics for a Stellar account.
Computes the following metrics from stored trade history:
total_trades
successful_claims
completion_rate
trusted status (requires 5+ trades and ≥90% successful releases)
Added validation for 56-character Stellar G-addresses, returning HTTP 400 for invalid addresses.
Preserved the existing requirePayment(..., "0.0005") middleware to maintain endpoint access requirements.
Implemented 60-second Redis caching with an automatic in-memory fallback when Redis is unavailable.
Included a cached field in the response to indicate whether the result was served from cache.
Updated the OpenAPI specification to document the new endpoint and response schema.
Testing
Added integration tests covering:
Reputation metric calculation
Trusted threshold logic
Address validation
Cache behavior
API response contract
Tests Passed:
reputation.test.ts – 6 passing
openapi.test.ts – 5 passing
Total: 11 passing
Closes #332