Skip to content

Add STX amount formatting utility to prevent code duplication #95

@Mosas2000

Description

@Mosas2000

Description

The pattern (value / 1000000).toFixed(N) is repeated in TipHistory, PlatformStats, and RecentTips components with inconsistent decimal places (2 in some places, 4 in others). This should be a shared utility function.

Files Affected

  • frontend/src/components/TipHistory.jsx (toFixed(2))
  • frontend/src/components/PlatformStats.jsx (toFixed(2) and toFixed(4))
  • frontend/src/components/RecentTips.jsx (toFixed(4))

Suggested Fix

Create a utility function in frontend/src/utils/format.js:

  • formatSTX(microSTX, decimals = 2) that handles the division and formatting
  • formatAddress(address, startChars = 6, endChars = 4) for consistent address truncation
  • formatNumber(n) for locale-aware number formatting

Import and use these throughout all components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions