Skip to content

StatCard duplicates formatCurrency's exact locale-formatting logic instead of calling the shared utils.ts helper #261

Closed

Description

@chonilius

src/lib/utils.ts#formatCurrency and src/components/ui/StatCard.tsx#formatValue's
"currency" case independently implement the same locale-formatted currency string:

// utils.ts
export function formatCurrency(amount: number, asset: "USDC" | "XLM" = "USDC") {
  if (!Number.isFinite(amount)) return `0 ${asset}`;
  return `${amount.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${asset}`;
}
// StatCard.tsx#formatValue
case "currency": {
  const formatted = value.toLocaleString("en-US", { maximumFractionDigits: 2 });
  const display = `${formatted} ${asset}`;
  const exact = `${value.toLocaleString("en-US", { maximumFractionDigits: 6 })} ${asset}`;
  return { display, exact };
}

formatCurrency's own doc comment even acknowledges this duplication is expected to be
kept manually in sync: "This behavior matches StatCard's internal currency formatter,
ensuring consistency across the app." That's two independent implementations of the same
formatting rule, correct only as long as every future change (locale, precision,
NaN/Infinity handling) is applied identically in both places by hand — exactly the kind
of drift-prone pattern that produced the precision inconsistency already tracked
elsewhere in this app's issue history for XLM's 7-decimal precision.

Suggested fix: have StatCard#formatValue's "currency" case call
formatCurrency(value, asset) directly for its display string (and a precision-widened
variant for exact), rather than reimplementing the same toLocaleString call
independently.

Activity

  1. added
    architecture
    documentation
    very hard
    help wanted
    on Aug 21, 2026
  2. added
    Stellar Wave
    on Aug 25, 2026
  3. NEA-DEV-coder commented on Aug 25, 2026

    @NEA-DEV-coder

    @NEA-DEV-coder has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi maintainer, I would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @NEA-DEV-coder to this issue.

  4. Oluwanifemi18-ux commented on Aug 25, 2026

    @Oluwanifemi18-ux

    @Oluwanifemi18-ux has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi maintainer I am interested in contributing to this task and can work toward preparing a clean solution on time kindly assign the issues to me

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Oluwanifemi18-ux to this issue.

  5. Horlarolowo123 commented on Aug 25, 2026

    @Horlarolowo123

    @Horlarolowo123 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi, I'd like to work on this issue. I've reviewed the requirements and understand what needs to be done. I'm confident I can complete it within the Wave timeframe and would appreciate the opportunity to work on it.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Horlarolowo123 to this issue.

  6. Levi-Ojukwu commented on Aug 25, 2026

    @Levi-Ojukwu
    Contributor

    @Levi-Ojukwu has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hello maintainer, I can habndle this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Levi-Ojukwu to this issue.

  7. drips-wave commented on Aug 25, 2026

    @drips-wave

    Congratulations, @Levi-Ojukwu! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @Levi-Ojukwu: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  8. yaegerbomb42 commented on Aug 28, 2026

    @yaegerbomb42

    /attempt

  9. drips-wave commented on Aug 30, 2026

    @drips-wave

    This issue has been completed by @Levi-Ojukwu as part of the Stellar Wave Program's 8th Wave 🥳

    😎 @Levi-Ojukwu: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  10. removed
    Stellar Wave
    on Oct 15, 2026
  11. added
    Stellar Wave
    on Oct 15, 2026
  12. removed
    Stellar Wave
    on Oct 15, 2026
  13. added
    Stellar Wave
    on Oct 15, 2026
  14. removed
    Stellar Wave
    on Oct 15, 2026
  15. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar Wavearchitecturedocumentationhelp wantedvery hard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions