Feature: Ticket 5 additions#82
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds two new Silver API endpoints backed by the unified DuckDB reader: one to fetch account-scoped transactions and one to fetch address balance history (classic assets or Soroban token contracts), along with a new DuckDB-based test suite validating hot/cold de-duplication and pagination behavior.
Changes:
- Added routes for
/api/v1/silver/accounts/{id}/transactionsand/api/v1/silver/addresses/{addr}/balances/history. - Implemented new handlers plus unified-reader query methods for account transactions and address balance history (with cursor pagination).
- Added DuckDB fixture-driven tests covering hot/cold de-duplication, pagination, and classic vs contract balance history modes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| obsrvr-lake/stellar-query-api/go/routes_silver.go | Registers the two new Silver API routes and logs them during startup. |
| obsrvr-lake/stellar-query-api/go/account_history.go | Adds handler implementations, cursor encoding/decoding, and unified DuckDB queries for transactions and balance history. |
| obsrvr-lake/stellar-query-api/go/account_history_test.go | Adds DuckDB-backed tests validating query behavior (dedup + pagination + history reconstruction). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| filters.StartTime = r.URL.Query().Get("start_time") | ||
| filters.EndTime = r.URL.Query().Get("end_time") |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b64bc96bd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if strings.TrimSpace(hotSchema) != "" { | ||
| parts = append(parts, oneClassic(hotSchema, 1)) | ||
| } |
There was a problem hiding this comment.
Skip hot balance_changes when it is not materialized
When classic history is requested in the normal unified-reader setup, hotSchema is non-empty, so this branch emits a query against hot_db...balance_changes. I searched the silver realtime hot schema/migrations and balance_changes is only produced by the cold history loader, not the hot schema, so DuckDB fails the entire UNION instead of returning cold history. Please skip the hot branch or add a table-existence fallback for classic balance history.
Useful? React with 👍 / 👎.
| if !validAccountAddress(addr) { | ||
| respondError(w, "addr must be a valid Stellar account (G...) address", http.StatusBadRequest) | ||
| return |
There was a problem hiding this comment.
Accept contract holders for token balance history
Use the account-or-contract validator here. For a Soroban token balance history where the holder is a contract address (C...) and contract_id is supplied, this returns 400 before reaching the token_transfers_raw query, even though /addresses/{addr}/balances accepts contract addresses and the query can match from_account/to_account for contracts. This prevents contract-held token balances from using the new history endpoint.
Useful? React with 👍 / 👎.
This pull request introduces new API endpoints for retrieving account transactions and address balance history in the Silver API, and adds comprehensive tests for these features. The main changes include the addition of two new routes and their corresponding handler registrations, as well as a new test file to validate the new functionality.
New API endpoints and routes:
/api/v1/silver/accounts/{id}/transactions(routes_silver.go)./api/v1/silver/addresses/{addr}/balances/history(routes_silver.go).Testing improvements:
account_history_test.gowith tests for account transaction pagination/deduplication and unified address balance history, including setup of DuckDB schemas, tables, and fixture data.