feat: add backend proxy for Horizon transaction history - #278
Merged
Conversation
|
@code-with-flex 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.
Description
Adds a backend proxy for Horizon transaction history scoped to a wallet address. The proxy keeps Horizon API keys server-side, filters the response to payment-relevant operation types only, applies per-wallet sliding-window rate limiting backed by Redis, and caches filtered results for 15 seconds to reduce Horizon load while staying within the finality lag window.
Related Issue
Closes #204
Changes Made
horizon/horizon.service.ts— Fetches from the configuredHORIZON_URL(resolved via existingNetworkConfig), strips_links, DEX fields, account-management fields, and all other internal Horizon metadata. Caches filtered responses for 15 seconds in Redis. Validates account address format before making any outbound request.horizon/filters/horizon-field.filter.ts— Pure function that filters topayment,path_payment_strict_receive,path_payment_strict_send, andcreate_accountoperation types, and allowlists only the fields required by the frontend. Includes inline documentation of every forwarded and stripped field.horizon/dto/horizon-transaction.dto.ts— Response shape with JSDoc explaining each forwarded field, why others are stripped, and the Horizon finality lag (~5–15 seconds ingestion delay after ledger close) with guidance for the frontend.horizon/horizon-rate-limit.service.ts— Sliding-window rate limiter using Redis sorted sets: 30 requests per 60-second window per wallet address. Fails open if Redis is unavailable.horizon/horizon.controller.ts—GET /api/horizon/transactions?account=<address>with optionalcursorandlimitparams. Returns 429 withRetry-Afterheader on rate limit breach. Never includes API keys in response headers or error bodies.horizon/horizon.module.ts— Module wiringCacheModule(forRedisService), controller, and providers.app.module.ts—HorizonModuleadded to imports.horizon/__tests__/horizon.integration.spec.ts— Integration tests using mockedfetchand a mockedRedisService. No real Horizon credentials needed.Acceptance Criteria