Skip to content

Consolidate amount utils; harden Stats/HowItWorks/NotificationDropdown - #1131

Merged
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
nonso7:feat/issues-1122-1123-1124-1125
Jul 29, 2026
Merged

Consolidate amount utils; harden Stats/HowItWorks/NotificationDropdown#1131
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
nonso7:feat/issues-1122-1123-1124-1125

Conversation

@nonso7

@nonso7 nonso7 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

#1124 — Consolidate the two parallel amount implementations
utils/amount.ts is now the single source of truth. Behavioural
differences resolved:
* parseAmount: keeps utils' input validation (returns 0n for "abc", "1.2.3") instead of lib's version, which threw from BigInt().
* formatRate(0n): keeps utils' "0 USDC/sec" / "0/sec" instead of lib's bare "0", so the zero case matches the non-zero format.
* toStroops/fromStroops: decimals now defaults to 7, so lib's one-arg XLM call sites and utils' explicit-decimals ones both work. Ported truncateAmount and formatCompactAmount over from lib, removed frontend/src/lib/amount.ts, and repointed its four importers (activity-content, ActivityHistory, StreamCreationWizard, ScheduleStep). lib.amount.test.ts was almost entirely duplicated by utils.test.ts; its unique coverage was folded in and the file removed.

#1125 — Stats fallback coverage
Every value now renders through formatStatValue, which maps null,
undefined, NaN, Infinity and blank strings to "--" while keeping 0 as
"0". Stats accepts an optional stats prop so a null/empty response
keeps the labels and three-column layout instead of collapsing.
Replacing the static copy with real data stays out of scope.

#1122 — NotificationDropdown empty state
Replaced the bare "No new notifications" line with an icon, a
"No notifications yet" heading and explanatory subtext, keeping the
disconnected variant distinct. Added tests for the empty render.

#1123 — HowItWorks content extraction
Step copy moved into a typed STEPS constant (plus SECTION_COPY for the
heading) with a comment noting the i18n/content-edit rationale. No
visual or behavioural change; a test locks the rendered output.

Pre-existing on main and left untouched: dashboard.test.ts and useIncomingStreams.test.ts fail to transform (JSX in .ts files), and src/lib/dashboard.ts has a syntax error that breaks next build.

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #

Changes Made

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

Breaking Changes

Breaking Changes:

Migration Guide:

Screenshots/Demo

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked for breaking changes and documented them if applicable

Closes #1122
Closes #1123
Closes #1124
Closes #1125

Closes LabsCrypt#1125, LabsCrypt#1124, LabsCrypt#1123, LabsCrypt#1122.

LabsCrypt#1124 — Consolidate the two parallel amount implementations
  utils/amount.ts is now the single source of truth. Behavioural
  differences resolved:
    * parseAmount: keeps utils' input validation (returns 0n for "abc",
      "1.2.3") instead of lib's version, which threw from BigInt().
    * formatRate(0n): keeps utils' "0 USDC/sec" / "0/sec" instead of
      lib's bare "0", so the zero case matches the non-zero format.
    * toStroops/fromStroops: decimals now defaults to 7, so lib's
      one-arg XLM call sites and utils' explicit-decimals ones both work.
  Ported truncateAmount and formatCompactAmount over from lib, removed
  frontend/src/lib/amount.ts, and repointed its four importers
  (activity-content, ActivityHistory, StreamCreationWizard, ScheduleStep).
  lib.amount.test.ts was almost entirely duplicated by utils.test.ts; its
  unique coverage was folded in and the file removed.

LabsCrypt#1125 — Stats fallback coverage
  Every value now renders through formatStatValue, which maps null,
  undefined, NaN, Infinity and blank strings to "--" while keeping 0 as
  "0". Stats accepts an optional stats prop so a null/empty response
  keeps the labels and three-column layout instead of collapsing.
  Replacing the static copy with real data stays out of scope.

LabsCrypt#1122 — NotificationDropdown empty state
  Replaced the bare "No new notifications" line with an icon, a
  "No notifications yet" heading and explanatory subtext, keeping the
  disconnected variant distinct. Added tests for the empty render.

LabsCrypt#1123 — HowItWorks content extraction
  Step copy moved into a typed STEPS constant (plus SECTION_COPY for the
  heading) with a comment noting the i18n/content-edit rationale. No
  visual or behavioural change; a test locks the rendered output.

Pre-existing on main and left untouched: dashboard.test.ts and
useIncomingStreams.test.ts fail to transform (JSX in .ts files), and
src/lib/dashboard.ts has a syntax error that breaks `next build`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ogazboiz
ogazboiz merged commit ade6062 into LabsCrypt:main Jul 29, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment