Skip to content

fix(sdk): full-size first page for hafah transactions, no initialData seed on notifications - #1427

Merged
feruzm merged 4 commits into
developfrom
bugfix/sdk-issue-bundle
Aug 11, 2026
Merged

fix(sdk): full-size first page for hafah transactions, no initialData seed on notifications#1427
feruzm merged 4 commits into
developfrom
bugfix/sdk-issue-bundle

Conversation

@feruzm

@feruzm feruzm commented Aug 11, 2026

Copy link
Copy Markdown
Member

Bundles the two open SDK issues.

#1409 - short first page on the hafah transactions query. hafah paginates oldest-first, so the first request (omitted page) returns the remainder bucket, between 1 and page-size rows, and requesting page=total_pages explicitly returns the same short bucket (verified live: good-karma, page-size 20 returns 17 rows either way). The queryFn now chains one fetch of total_pages - 1 when the first page comes back short and older pages exist, so the list opens at full size. A failed chained fetch keeps the short page with the cursor still at total_pages, so that page becomes the next load-more target instead of being skipped. Affects the profile transactions component, deck wallet column and transfer recent-recipient suggestions.

#1405 - notifications infinite query seeds an empty page set. initialData: { pages: [], pageParams: [] } counts as fresh for the whole staleTime, so a consumer that only reads data renders an empty list with no fetch. Removed; the three web consumers force-refetch on mount or only use refetch/isLoading, so nothing changes for them. New spec pins the absence of initialData on the notifications options and the HIVE/HBD/HP asset transaction options.

Verified: sdk vitest suite (733 tests), sdk lint, sdk + web typecheck all pass.

Closes #1409
Closes #1405

Summary by CodeRabbit

  • Improvements
    • Transaction history now fills short newest pages with older entries when available, providing smoother pagination.
    • Pagination remains reliable at page boundaries and preserves available results if an additional page cannot be loaded.
    • Explicit page requests continue to return only the requested page.
  • Bug Fixes
    • Notifications and wallet asset lists now load through the standard fetching flow instead of briefly starting with empty data.
    • Improved handling of interrupted transaction-history requests.

feruzm added 2 commits August 11, 2026 16:32
hafah paginates oldest-first, so an omitted page returns the remainder
bucket (total_operations mod page-size rows, as short as one row) and
requesting page=total_pages explicitly returns the same short bucket.
When the first page comes back short and older pages exist, chain one
fetch of page total_pages-1 into the first result so the list opens at
full size. If the chained fetch fails, the short page is kept and the
cursor stays at total_pages so the page is retried by load-more.
…nite query

An empty initialData page set counts as fresh for the whole staleTime,
so a consumer that only reads data renders an empty list with no fetch,
no loading state and no error. Existing web consumers force-refetch on
mount and are unaffected. The spec pins the absence of initialData for
the notifications options and the wallet asset transaction options,
which had the same seed removed earlier.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf8286fb-bd7e-4c7c-8c15-f7abfdd75d8c

📥 Commits

Reviewing files that changed from the base of the PR and between 685d107 and ad39570.

⛔ Files ignored due to path filters (7)
  • packages/sdk/dist/browser/index.d.ts is excluded by !**/dist/**
  • packages/sdk/dist/browser/index.js is excluded by !**/dist/**
  • packages/sdk/dist/browser/index.js.map is excluded by !**/dist/**, !**/*.map
  • packages/sdk/dist/node/index.cjs is excluded by !**/dist/**
  • packages/sdk/dist/node/index.cjs.map is excluded by !**/dist/**, !**/*.map
  • packages/sdk/dist/node/index.mjs is excluded by !**/dist/**
  • packages/sdk/dist/node/index.mjs.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (6)
  • packages/sdk/CHANGELOG.md
  • packages/sdk/package.json
  • packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.spec.ts
  • packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.ts
  • packages/wallets/CHANGELOG.md
  • packages/wallets/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.ts

📝 Walkthrough

Walkthrough

The SDK now tops up short initial transaction pages from the next older page and preserves cursors on failure. It also removes empty initialData from notification queries, adds query coverage, and publishes SDK and wallets patch versions.

Changes

SDK query behavior

Layer / File(s) Summary
Short-page transaction retrieval and validation
packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.ts, packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.spec.ts
The query fetches and maps pages through local helpers. A short initial page chains the next older page. Tests cover failures, aborts, explicit requests, page boundaries, and descending pagination.
Unseeded notification query options
packages/sdk/src/modules/notifications/queries/get-notifications-infinite-query-options.ts, packages/sdk/src/modules/notifications/queries/get-notifications-infinite-query-options.spec.ts
The notification query no longer defines empty initialData. Tests verify that notification and wallet asset query factories omit the property.

Release metadata

Layer / File(s) Summary
SDK and wallets patch release metadata
packages/sdk/package.json, packages/sdk/CHANGELOG.md, packages/wallets/package.json, packages/wallets/CHANGELOG.md
The SDK version changes to 2.3.83. The wallets version changes to 5.0.83. Changelogs record the fixes and package update.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QueryOptions as getTransactionsInfiniteQueryOptions
  participant PageHelper as page-fetch helper
  participant Hafah as hafah REST API
  QueryOptions->>PageHelper: Fetch initial transaction page
  PageHelper->>Hafah: Request newest page
  Hafah-->>PageHelper: Return short page and cursor
  QueryOptions->>PageHelper: Fetch next older page
  PageHelper->>Hafah: Request explicit older page
  Hafah-->>PageHelper: Return older entries
  PageHelper-->>QueryOptions: Return combined transaction entries
Loading

Poem

I’m a rabbit with pages to hop,
Filling short lists before they stop.
Cursors stay when fetches fail,
Empty seeds leave the query trail.
Tests watch each page descend—
Carrots approved from start to end.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both primary SDK fixes: full-size HAFah transaction pages and removal of notification initialData.
Linked Issues check ✅ Passed The changes satisfy issues #1409 and #1405, including chained pagination, abort handling, initialData removal, and required tests.
Out of Scope Changes check ✅ Passed The changes remain within the linked issue scope, including focused tests, changelogs, and package version updates for the SDK release.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/sdk-issue-bundle

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.spec.ts (1)

51-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that the initial request omits page.

The test checks page: 145 only on the chained request. Add an assertion for the first request. This guards the required omitted-page behavior.

Proposed test addition
     expect(page.currentPage).toBe(145);
     expect(mockCallREST).toHaveBeenCalledTimes(2);
+    expect(mockCallREST.mock.calls[0][2]).not.toHaveProperty("page");
     // The chained call must ask for the page BELOW the remainder bucket —
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.spec.ts`
around lines 51 - 64, The test case “chains the next older page when the newest
bucket is short” must also assert that the initial mockCallREST invocation omits
the page option. Add an assertion for the first call’s request options before
retaining the existing page: 145 assertion for the chained call.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.ts`:
- Around line 215-235: Update the catch block in the initial-page chaining logic
around fetchPage so it re-throws the caught error when signal?.aborted is true,
while retaining the short-page fallback only for non-abort failures.

---

Nitpick comments:
In
`@packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.spec.ts`:
- Around line 51-64: The test case “chains the next older page when the newest
bucket is short” must also assert that the initial mockCallREST invocation omits
the page option. Add an assertion for the first call’s request options before
retaining the existing page: 145 assertion for the chained call.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 121da9b5-0e3b-44d1-9994-55e682ebceb6

📥 Commits

Reviewing files that changed from the base of the PR and between 82758d9 and 685d107.

📒 Files selected for processing (4)
  • packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.spec.ts
  • packages/sdk/src/modules/accounts/queries/get-transactions-infinite-query-options.ts
  • packages/sdk/src/modules/notifications/queries/get-notifications-infinite-query-options.spec.ts
  • packages/sdk/src/modules/notifications/queries/get-notifications-infinite-query-options.ts

Swallowing an abort resolved the query with a partial page after the
caller had already cancelled. Non-abort failures still fall back to the
short remainder page with the cursor kept at total_pages.
@feruzm feruzm added the patch Bug fixes and patches (1.0.0 → 1.0.1) label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bug fixes and patches (1.0.0 → 1.0.1)

Projects

None yet

1 participant