Repository navigation
feat(rest)!: return the history coverage headers from account_history - #43
Merged
Merged
Conversation
`AccountRestClient.account_history` returns an `AccountHistoryPage` with `entries`, `cursor`, `indexed_from` and `oldest_block` instead of an `(entries, cursor)` tuple. `indexed_from` is read from `x-supra-history-indexed-from` and `oldest_block` from `x-supra-oldest-block`; each is `None` when the header is absent or not decimal digits. The header parsing of `ApiGoneError` moves into `parse_height_header`, which `account_history` also uses. `iter_account_history` still yields entries. BREAKING CHANGE: `account_history` returns `AccountHistoryPage` instead of `tuple[list[dict], str | None]`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
What
AccountRestClient.account_historyreturns the two response headers that describe what the history covers, assupra-ts-sdk 2.0.0 does (
AccountHistoryPage.indexedFrom/oldestBlock):indexed_from: the lowest block height the history covers (x-supra-history-indexed-from). The node sends itwhile blocks below that height remain unindexed; the transactions of those blocks are not listed.
Nonewhen thehistory covers every block the node holds.
oldest_block: the height of the oldest block the node holds (x-supra-oldest-block).Noneuntil the node'sarchive has indexed at least one block.
Before this change the docstring said the method did not return the header, so a caller could not tell whether the
history covered the older blocks.
Changes
account_historyreturns a frozen dataclassAccountHistoryPage(rest_types.py) withentries,cursor,indexed_fromandoldest_block, instead of an(entries, cursor)tuple. The cursor rules are unchanged.api_client.py:HISTORY_INDEXED_FROM_HEADER, andparse_height_header, whichApiGoneError.oldest_blocknowuses as well (same behaviour: decimal digits only, otherwise
None).iter_account_historystill yields the entries; its docstring points toaccount_historyfor the coverage.Breaking change
entries, cursor = await client.account_history(...)no longer unpacks.account_historywas added after v0.1.0,so no released version has the tuple form.
Checks
make fmt-check,make lint,make typecheck,make test-unit(397 tests, OK, 26 node-backed skipped),make test-spec(248 scenarios),make build: pass. New unit tests: both headers present, both absent, andnon-decimal values (
abc,-1,1.5, empty,0x10).🤖 Generated with Claude Code