Repository navigation
fix: make VWAP route network-aware and sync openapi.json (#235) - #605
Conversation
|
Merged to This is a better catch than the title suggests. Resolving Conflicts, all additive against work that landed today: #542 added decimal-format handling in the same query schema and handler blocks you're adding Two things I regenerated rather than merged by hand, worth knowing for next time:
I also took Lens: 116 files, 1,426 tests passing, typecheck clean. |
listPairs returned bare strings, so a client wanting the assets, the network or a price had to parse the pair key and then ask again. `pairs` returns the structured form, and listPairs stays — deprecated with a reason rather than removed, which is the right call for a published API. The resolver is good: one query per request using a LATERAL join to pull the latest price for each active pair, rather than a query per pair, and scoped by `network = $1` so it cannot blend chains — the bug #584 and #605 both had to fix elsewhere today. Conflicts, resolved by keeping main's richer side and adding this PR's: - imports: kept main's (NetworkName, the oracle adapter and comparison) and added getActivePairs - the schema declaration: kept main's `export const schema`, which the SDL artifact generator depends on, and added the Asset and Pair types - the Query block: kept main's documented getPriceHistory with its from/to range and the oracle query, and added `pairs` plus the @deprecated marker on listPairs Regenerated schema.graphql afterwards. src/__tests__/graphqlSchemaDrift.test.ts compares the committed SDL against the code-defined schema, so adding types without regenerating fails it — the same generated-artifact guard as openapi.json and the TypeScript client. Lens: 118 files, 1,432 tests passing, typecheck clean. Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
Description
Resolves #235 by ensuring the VWAP pricing route respects and enforces network scoping throughout the request cycle.
Summary of Changes
src/routes/price.tsto extract network (req.network ?? activeNetwork), pass it tocomputeVWAP, and echo it in the response payload.src/aggregator/vwap.tsapplies a strictWHERE network = $1 AND source = $2logical conjunction to leverage the leading(network, pairKey, timestamp)index onprice_points.src/__tests__/vwapRoute.test.tsverifying cross-network isolation and default network fallback.openapi.yamland synchronizedopenapi.jsonto keep API schema validation passing.Verification
tests/openapi.test.tspasses cleanly against regeneratedopenapi.json.