Skip to content

feat(frontend): add balance dust filter module (#376) - #475

Open
jdjioe5-cpu wants to merge 1 commit into
Kitewell-lab:mainfrom
jdjioe5-cpu:feat/issue-376-balance-dust-filter
Open

jdjioe5-cpu wants to merge 1 commit into
Kitewell-lab:mainfrom
jdjioe5-cpu:feat/issue-376-balance-dust-filter

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Summary

Implements the Horizon balance dust filter in frontend/src/balanceDustFilter.js to filter balance lines below a configurable minimum display threshold in stroops while always keeping native XLM per #376.

Changes

  • Add frontend/src/balanceDustFilter.js exporting filterDustBalances (and balanceDustFilter alias) and balanceToStroops
  • Always retain native XLM balance lines (asset_type === "native") regardless of balance amount
  • Filter non-native balances strictly below configurable threshold (defaults to 1n stroop = 0.0000001)
  • Support integer stroops, numbers, BigInts, and options objects ({ minThresholdStroops }) without mutating the input array
  • Export constants in frontend/src/balanceDustFilterConstants.js (STROOPS_PER_UNIT, DEFAULT_DUST_THRESHOLD_STROOPS, DUST_FILTER_ERROR)
  • Add 10 single-behavior Vitest test files in frontend/src/:
    • balanceDustFilter-happy.test.js (filters zero and keeps positive balances)
    • balanceDustFilter-native-always-kept.test.js (native XLM kept even when zero or dust)
    • balanceDustFilter-empty.test.js (empty array handling)
    • balanceDustFilter-boundary.test.js (threshold boundary tests at exact 1 stroop)
    • balanceDustFilter-custom-threshold.test.js (custom stroop threshold values)
    • balanceDustFilter-does-not-mutate.test.js (immutability of input array)
    • balanceDustFilter-invalid-balances.test.js (non-array input rejection)
    • balanceDustFilter-invalid-entry.test.js (non-object entry rejection)
    • balanceDustFilter-invalid-threshold.test.js (negative threshold rejection)
    • balanceDustFilter-constants.test.js (constant immutability verification)
  • Add documentation in docs/features/balanceDustFilter.md
  • No existing files modified

Verification

  • npm test -- --run run from frontend/ passes 191/191 test files and 432/432 tests clean

Closes #376

- Implement frontend/src/balanceDustFilter.js to filter Horizon balance lines
- Retain native XLM balance line regardless of balance amount
- Filter out non-native credit balances below configurable stroop threshold (defaults to 1 stroop)
- Export constants STROOPS_PER_UNIT, DEFAULT_DUST_THRESHOLD_STROOPS, and DUST_FILTER_ERROR
- Support integer stroops, numbers, BigInts, and options objects without mutating input array
- Add 10 Vitest single-behavior test files covering empty, happy path, boundary, native retention, immutability, constants, and invalid inputs
- Add feature documentation under docs/features/balanceDustFilter.md

Closes Kitewell-lab#376
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.

New frontend module: frontend/src/balanceDustFilter.js — Dust balance filter

1 participant