Consolidate amount utils; harden Stats/HowItWorks/NotificationDropdown - #1131
Merged
Merged
Conversation
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>
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.
#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
Related Issues
Closes #
Changes Made
Testing
Test Coverage
Test Steps
Breaking Changes
Breaking Changes:
Migration Guide:
Screenshots/Demo
Checklist
Closes #1122
Closes #1123
Closes #1124
Closes #1125