docs(node): warn QueryNodes truncates without next_key + add isActiveStatus helper#94
Open
Sentinel-Bluebuilder wants to merge 1 commit into
Conversation
…ctiveStatus helper
Two consumer footguns from chain v3 that bite on day 1:
1. `QueryNodes` and `QueryNodesForPlan` return `pagination.next_key=null`
even when results are truncated. Consumers writing the obvious
`while (next_key) { ... }` loop silently drop nodes. Add JSDoc
warnings on the NodeExtension methods directing callers to use a
large `limit` or `offset`-based pagination.
2. Subscription / session status comes back as the string
`"STATUS_ACTIVE"` over LCD JSON, the numeric `1` over RPC, and the
typed `Status.STATUS_ACTIVE` enum after ts-proto decode. Add an
`isActiveStatus` helper in utils that accepts all three.
No behavior changes. JSDoc and one new exported helper.
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.
Summary
Two chain v3 footguns that bite consumers on day 1. This PR addresses both with the smallest possible surface area: JSDoc warnings + one tiny exported helper.
1.
QueryNodes/QueryNodesForPlanreturnnext_key=nullon truncationSentinel chain v3 does not emit
pagination.next_keyfor these queries even when results are truncated. Consumers writing the obvious `while (next_key)` loop silently drop nodes.Reproducible against mainnet:
```bash
curl 'https://lcd.sentinel.co/sentinel/node/v3/plans/36/nodes?pagination.limit=500'
| jq '{count: (.nodes | length), next: .pagination.next_key}'
=> { "count": 500, "next": null }
curl 'https://lcd.sentinel.co/sentinel/node/v3/plans/36/nodes?pagination.offset=500&pagination.limit=500'
| jq '.nodes | length'
=> 303 (so plan 36 actually has 803 nodes; the first call hid 303 of them)
```
The fix is pure JSDoc — direct callers to use a large `limit` or `offset`-based pagination instead of trusting `next_key`.
2. Status comes in three shapes — add an `isActiveStatus` helper
Subscription / session / node status is emitted as:
Consumers who pick one shape and forget the others get silent zero results when their data source changes (e.g., switching from LCD to RPC). 10-line helper in `utils.ts`:
```ts
export function isActiveStatus(s: string | number | Status): boolean {
return s === Status.STATUS_ACTIVE || s === "STATUS_ACTIVE" || s === 1;
}
```
Strictly opt-in. No existing call site changes. `statusFromJSON` from the generated proto already handles the same conversion, but it lives in `protobuf/` and consumers don't typically reach there — this exposes the equivalent check from the public utils surface.
Test plan