Repository navigation
feat(frontend): add locale-aware currency formatting for NGN and Stellar assets - #1565
Open
AlphaMaleBaDI wants to merge 1 commit into
Open
AlphaMaleBaDI wants to merge 1 commit into
AlphaMaleBaDI wants to merge 1 commit into
Conversation
|
@AlphaMaleBaDI 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! 🚀 |
…lar assets Adds formatCurrency, formatAsset and formatStroops with locale-aware output for NGN, USD, EUR, XLM, USDC and EURC, plus 46 tests and a developer reference. Docs are Prettier-clean. Closes Split-Naira#1503
AlphaMaleBaDI
force-pushed
the
feat/1503-locale-currency-tests
branch
from
October 27, 2026 07:28
93c711e to
b7ca8aa
Compare
This branch has not been deployed
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.
Summary
Adds locale-aware currency formatting for Nigerian naira and the Stellar assets
this app supports, with a test suite covering success, failure and boundary
cases.
Amounts reach the frontend as bare integers and decimal strings, but what a user
reads is locale-dependent. The same balance renders three different ways:
en-NG₦1,234.56enNGN 1,234.56de1.234,56 NGNfr1 234,56 NGNCloses #1503
Changes
frontend/src/lib/formatCurrency.ts(new)formatCurrency(amount, locale, currency)for fiat (NGN,USD,EUR)formatAsset(amount, locale, code)for assets (XLM,USDC,EURC)formatStroops(stroops, locale, code)for on-chain stroop integersfrontend/src/lib/__tests__/formatCurrency.test.ts(new) - 46 testsdocs/currency-formatting.md(new) - developer referencedocs/contributors/frontend-testing-guide.md- corrected stale stackDesign decisions worth reviewing
The module never guesses.
NaN,Infinity, unsupported currencies andstructurally invalid locale tags throw instead of returning something
plausible.
Intlwill happily renderNaNand∞; a balance readingNaN ₦is a confident lie in an app that moves money. Error messages name the offending
value so the fault is findable in a stack trace.
₦only appears inen-NG. Other locales render the ISO codeNGN. Thatis correct rather than a gap - a naira symbol shown to a German reader is a bug.
XLM allows 7 fraction digits but does not pad to them. The smallest
transferable amount is one stroop (
0.0000001 XLM); padding a whole unit toseven digits would render
1 XLMas1.0000000 XLM. USDC and EURC use exactly 2digits, matching exchange convention.
Custom tokens are excluded. Their codes are user-supplied contract metadata
and cannot be validated against a closed list.
Tests
46 tests across
en,en-NG,fr,deandja:digits stay identical
Number.MAX_SAFE_INTEGERNaN,±Infinity, non-number,null, unsupported currency,unsupported asset code, invalid locale, empty locale, non-string locale
Assertions normalise U+00A0 / U+202F and U+2212 before comparing. Asserting raw
output makes a suite fail on an ICU upgrade for reasons unrelated to the code
under test - a failure mode this repo has already hit.
Accessibility
These are pure string formatters with no DOM output, so they add no keyboard or
screen-reader surface of their own; nothing about a component's accessibility
changes when it starts calling them.
Negatives keep a real minus sign rather than relying on a localised glyph, so
they are announced as negative rather than read as positive. The docs note that
grouping separators are decorative and that a control whose accessible name
would otherwise be uninformative should carry an explicit
aria-label.Documentation
docs/currency-formatting.mdcovers the API, failure behaviour, the ICU caveat,the accessibility position, and the fact that the module is not yet wired into
any component. The testing guide's "Jest /
apps/web" references were stale -the stack is Vitest under
frontend/- and it gained a section on testinglocalised output with the locale-blind mock.
Validation
npm run lint -w frontend- exit 0npm run check:i18n -w frontend- OK, 38 keys, all locales matchnpm test -w frontend- 553/553 pass, 55/55 filesnpm run build -w frontend- compiles, TypeScript cleanTest count reconciles: the pre-existing 511 included a 4-test stub at this path,
so 511 - 4 + 46 = 553.
Out of scope
Components still format amounts with a bare
.toLocaleString(), which uses thehost default locale rather than the route's
[locale]- so numberformatting currently ignores the user's selected language. Wiring this module
into those call sites is follow-up work and is deliberately not in this PR.
Known issue in this repo (pre-existing, not introduced here)
DashboardView.perf.test.tsxandsplit-app.test.tsxfail intermittently underparallel load and pass in isolation.