Skip to content

feat(rest)!: return the history coverage headers from account_history - #43

Merged
isaacdoidge merged 1 commit into
masterfrom
feat/history-coverage-headers
Nov 4, 2026
Merged

isaacdoidge merged 1 commit into
masterfrom
feat/history-coverage-headers

Conversation

@isaacdoidge

Copy link
Copy Markdown
Collaborator

What

AccountRestClient.account_history returns the two response headers that describe what the history covers, as
supra-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 it
    while blocks below that height remain unindexed; the transactions of those blocks are not listed. None when the
    history covers every block the node holds.
  • oldest_block: the height of the oldest block the node holds (x-supra-oldest-block). None until the node's
    archive 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_history returns a frozen dataclass AccountHistoryPage (rest_types.py) with entries, cursor,
    indexed_from and oldest_block, instead of an (entries, cursor) tuple. The cursor rules are unchanged.
  • api_client.py: HISTORY_INDEXED_FROM_HEADER, and parse_height_header, which ApiGoneError.oldest_block now
    uses as well (same behaviour: decimal digits only, otherwise None).
  • iter_account_history still yields the entries; its docstring points to account_history for the coverage.
  • README example updated.

Breaking change

entries, cursor = await client.account_history(...) no longer unpacks. account_history was 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, and
non-decimal values (abc, -1, 1.5, empty, 0x10).

🤖 Generated with Claude Code

`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>
@isaacdoidge
isaacdoidge merged commit e795c09 into master Nov 4, 2026
5 checks passed
@isaacdoidge
isaacdoidge deleted the feat/history-coverage-headers branch November 4, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant