-
Notifications
You must be signed in to change notification settings - Fork 1
Add STX amount formatting utility to prevent code duplication #95
Copy link
Copy link
Closed
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels