Skip to content

Add shared formatting utility hooks for XLM amounts and relative timestamps #547

Description

@Chucks1093

Summary

XLM amounts and transaction timestamps are formatted inline across multiple components, each with slightly different precision or locale handling. Two shared hooks should centralise these concerns so every surface renders consistent output.

Scope

  • Add useFormatXlm(amount: bigint | number, decimals?: number): string — defaults to 2 decimal places, uses Intl.NumberFormat for locale-aware thousands separators, allows decimal override
  • Add useRelativeTime(timestamp: number): string — returns human-readable relative strings like 2 minutes ago, 3 days ago, using Intl.RelativeTimeFormat; updates every 60 seconds while the component is mounted
  • Replace existing inline format calls in holdings, trade panel, and activity feed with the two hooks

Acceptance Criteria

  • useFormatXlm returns correct value with locale separators and configurable decimals
  • useRelativeTime returns correct relative string and refreshes every 60 seconds
  • Holdings, trade panel, and activity feed use the hooks instead of inline formatting
  • Both hooks are co-located in a hooks/formatting module

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions