Skip to content

feat(staking): add pagination, date filtering, and historical fiat CS… - #997

Merged
k-deejah merged 1 commit into
Sorokit:mainfrom
Ariyagold:feat/reward-history-pagination-fiat-934
Oct 17, 2026
Merged

k-deejah merged 1 commit into
Sorokit:mainfrom
Ariyagold:feat/reward-history-pagination-fiat-934

Conversation

@Ariyagold

Copy link
Copy Markdown
Contributor

Summary

Closes #934

This PR adds client-side pagination, date-range filtering, and historical fiat (USD) value estimation with CSV export support to RewardHistory, along with comprehensive unit test coverage for empty states, date filtering, pagination, and CSV generation.


Why This Was Needed

  1. DOM Performance on Large Histories: RewardHistory previously rendered up to 50 rows directly into the DOM without pagination controls, and lacked pagination for accounts with hundreds of daily reward payouts.
  2. Missing Historical Fiat Values in Exports: Users exporting their staking reward history had no CSV export option or historical USD price/value estimates at the time of reward distribution for accounting and tax reporting.
  3. Test Coverage Gaps: RewardHistory.test.tsx lacked dedicated unit tests for date-range filtering, pagination controls, CSV exports with fiat columns, and filtered empty states.

What Changed & How It Was Implemented

1. Historical Fiat Value Estimation (src/lib/staking.ts)

  • Extended RewardEvent with optional priceUsd and usdValue fields.
  • Added DEFAULT_XLM_PRICE_USD, estimateHistoricalXlmPriceUsd(dateStr), and estimateRewardUsdValue(event) utilities to deterministically resolve or estimate historical XLM price and USD value at the time of distribution.
  • Updated generateMockRewardHistory() to populate priceUsd and usdValue on generated reward events.

2. Pagination, Date Filtering & CSV Export (src/components/RewardHistory.tsx)

  • Pagination: Added a configurable pageSize prop (defaulting to 10 rows per page) with Prev / Next controls and page status indicator (Page X of Y), ensuring only the current page's rows are mounted in the DOM.
  • Date Filtering: Added From (Start date) and To (End date) date inputs (plus a Clear action) that filter both the RewardBarChart daily buckets and the reward events table, automatically resetting pagination to page 1 when filters change.
  • Historical Fiat Column & CSV Export:
    • Added an Est. USD column to the reward events table.
    • Implemented generateRewardHistoryCsv() and an Export CSV button (supporting both DOM Blob download and an optional onExport callback) that outputs:
      Date,Validator,Amount (XLM),XLM Price (USD),Estimated Value (USD),Transaction Hash.

3. Public Exports (src/components/index.ts)

  • Exported generateRewardHistoryCsv, DEFAULT_XLM_PRICE_USD, estimateHistoricalXlmPriceUsd, and estimateRewardUsdValue.

4. Unit Tests (src/components/RewardHistory.test.tsx, src/lib/staking.test.ts, src/__tests__/exports.test.ts)

  • Added unit tests for:
    • Empty States: Empty dailyRewards and events, zero XLM summary state, hidden table/export controls, and empty filtered states when a date range excludes all events.
    • Date Filtering: Filtering by start date, end date, combined date range, clearing active filters, and resetting page index on filter change.
    • Pagination: Rendering large histories (e.g., 250 events) with only pageSize rows in the DOM, navigating forward/backward with Next and Prev, and hiding pagination when all events fit on one page.
    • CSV Export: Verifying XLM Price (USD) and Estimated Value (USD) headers and row values, onExport callback invocation, and DOM download fallback.

Acceptance Criteria Checklist

  • Reward list paginates long histories so only the active page is rendered in the DOM.
  • CSV export includes historical fiat estimates (XLM Price (USD) and\

Closes #934
Closes #933
Closes #932
Closes #931

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Ariyagold Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ariyagold

Copy link
Copy Markdown
Contributor Author

@k-deejah , pls review pr

@k-deejah
k-deejah merged commit f334886 into Sorokit:main Oct 17, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants