Skip to content

feat(history): add get_history_page_with_meta pagination metadata (#380) - #397

Open
ebenezershadrack123-star wants to merge 1 commit into
ApexChainx:mainfrom
ebenezershadrack123-star:feature/history-page-metadata-380
Open

feat(history): add get_history_page_with_meta pagination metadata (#380)#397
ebenezershadrack123-star wants to merge 1 commit into
ApexChainx:mainfrom
ebenezershadrack123-star:feature/history-page-metadata-380

Conversation

@ebenezershadrack123-star

Copy link
Copy Markdown

Summary

Closes #380.

Adds a metadata-carrying companion get_history_page_with_meta that returns a
HistoryPage { items, total, has_more } so consumers can detect end-of-history
and the total size in a single read — without a separate get_history or
get_retention_limit call.

Changes

  • apexchainx_calculator/src/lib.rs — new #[contracttype] HistoryPage
    struct; new #[contractimpl] get_history_page_with_meta method; registered
    the method in get_public_api.
  • apexchainx_calculator/src/history.rs — mirrored delegated
    get_history_page_with_meta implementation (kept in lockstep with the
    contract entry point, per the existing pattern).
  • apexchainx_calculator/src/tests.rs — 6 tests covering total/has_more,
    empty history, offset-beyond-end, zero-limit, byte-for-byte parity with
    get_history_page, and saturating arithmetic; bumped the public-API method
    count 57 → 58.
  • Docs — CHANGELOG, README, HISTORY_PAGINATION_POLICY, API_STABILITY_SCORECARD,
    MODULE_OWNERSHIP, CONTRACT_MAINTENANCE_POLICY, PROJECT_CONTEXT.

Semantics

  • items is identical to get_history_page(offset, limit).
  • total is the full history length at read time.
  • has_more is true exactly when min(saturating_add(offset, limit), total) < total.
  • get_history_page is unchanged (backward compatible).
  • Read-only: no storage writes, no events, no auth.

Acceptance criteria

  • get_history_page_with_meta returns pagination metadata including total and has_more
  • Existing get_history_page behavior is unchanged
  • Tests verify correct metadata for various offset/limit combinations

Verification

cd apexchainx_calculator
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --lib          # 575 passed, 0 failed (1 pre-existing slow stress test skipped)
cargo check --target wasm32-unknown-unknown --lib

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update

Related Issue

Closes #380

ApexChainx#380)

Add a metadata-carrying companion to get_history_page so consumers can
detect end-of-history and total size in a single read without a separate
get_history call. Returns a HistoryPage { items, total, has_more } while
keeping the existing get_history_page behavior unchanged for backward
compatibility.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
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.

History pagination returns empty page for offset beyond length without error

1 participant