Telegram: https://t.me/+DOylgFv1jyJlNzM0
Why this matters
There are two parallel amount-formatting modules with overlapping function names but different signatures, and different parts of the app import from each. This is an active bug-magnet: a developer copying a call from one file to another can silently pass the wrong arguments.
Verified divergence
Both frontend/src/lib/amount.ts and frontend/src/utils/amount.ts export formatAmount, parseAmount, formatRate, hasValidPrecision, toStroops, fromStroops — but the signatures differ:
lib/amount.ts: fromStroops(stroops) (1 arg), toStroops(value) (1 arg, assumes 7 decimals).
utils/amount.ts: fromStroops(amount, decimals) (2 args), toStroops(amount, decimals) (2 args).
Import split (verified via grep):
- Import from
@/lib/amount: app/activity/page.tsx, components/IncomingStreams.tsx, components/stream-creation/{AmountStep,StreamCreationWizard,ScheduleStep}.tsx, components/dashboard/ActivityHistory.tsx.
- Import from
@/utils/amount: app/streams/[id]/page.tsx, app/streams/create/page.tsx, components/NotificationDropdown.tsx, components/stream-creation/TopUpModal.tsx.
utils/amount.ts is the richer one (token-decimals cache, async fetchTokenDecimals, validateAmountInput) and is the one covered by __tests__/utils.test.ts.
Acceptance criteria
Files to touch
frontend/src/lib/amount.ts
frontend/src/utils/amount.ts
- All importers listed above.
Out of scope
- Changing displayed precision/format behavior.
Telegram: https://t.me/+DOylgFv1jyJlNzM0
Why this matters
There are two parallel amount-formatting modules with overlapping function names but different signatures, and different parts of the app import from each. This is an active bug-magnet: a developer copying a call from one file to another can silently pass the wrong arguments.
Verified divergence
Both
frontend/src/lib/amount.tsandfrontend/src/utils/amount.tsexportformatAmount,parseAmount,formatRate,hasValidPrecision,toStroops,fromStroops— but the signatures differ:lib/amount.ts:fromStroops(stroops)(1 arg),toStroops(value)(1 arg, assumes 7 decimals).utils/amount.ts:fromStroops(amount, decimals)(2 args),toStroops(amount, decimals)(2 args).Import split (verified via grep):
@/lib/amount:app/activity/page.tsx,components/IncomingStreams.tsx,components/stream-creation/{AmountStep,StreamCreationWizard,ScheduleStep}.tsx,components/dashboard/ActivityHistory.tsx.@/utils/amount:app/streams/[id]/page.tsx,app/streams/create/page.tsx,components/NotificationDropdown.tsx,components/stream-creation/TopUpModal.tsx.utils/amount.tsis the richer one (token-decimals cache, asyncfetchTokenDecimals,validateAmountInput) and is the one covered by__tests__/utils.test.ts.Acceptance criteria
utils/amount.ts, since it's tested and fuller) and migrate all imports to it.fromStroops/toStroopsarities at call sites.Files to touch
frontend/src/lib/amount.tsfrontend/src/utils/amount.tsOut of scope