feat(history): add get_history_page_with_meta pagination metadata (#380) - #397
Open
ebenezershadrack123-star wants to merge 1 commit into
Conversation
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>
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
Closes #380.
Adds a metadata-carrying companion
get_history_page_with_metathat returns aHistoryPage { items, total, has_more }so consumers can detect end-of-historyand the total size in a single read — without a separate
get_historyorget_retention_limitcall.Changes
apexchainx_calculator/src/lib.rs— new#[contracttype]HistoryPagestruct; new
#[contractimpl]get_history_page_with_metamethod; registeredthe method in
get_public_api.apexchainx_calculator/src/history.rs— mirrored delegatedget_history_page_with_metaimplementation (kept in lockstep with thecontract 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 methodcount 57 → 58.
MODULE_OWNERSHIP, CONTRACT_MAINTENANCE_POLICY, PROJECT_CONTEXT.
Semantics
itemsis identical toget_history_page(offset, limit).totalis the full history length at read time.has_moreistrueexactly whenmin(saturating_add(offset, limit), total) < total.get_history_pageis unchanged (backward compatible).Acceptance criteria
get_history_page_with_metareturns pagination metadata includingtotalandhas_moreget_history_pagebehavior is unchangedVerification
Type of Change
Related Issue
Closes #380