refactor(shared): remove dead MoneyAmount twins (USD/JMD/BTC) [ENG-518]#451
Conversation
The top-level src/domain/shared/MoneyAmount.ts defined USDAmount, JMDAmount, and BtcAmount that were dead: the @domain/shared barrel resolves those from ./money (export * from "./money") and takes only USDTAmount from this file. The duplicates shadowed the live ./money classes, which let the cashout JMD rate fix land on the wrong copy (#449 patched here; #450 fixed the real ./money one). Delete the three dead classes; scope this file and MoneyAmount.from() to the base + USDTAmount, its only live exports. Comment added so no currency-amount class is re-added here. Verified: tsc --noEmit clean project-wide; Money.spec.ts 22/22 (it imports JMDAmount from the barrel = the live ./money class, and exercises MoneyAmount.from(Usdt)/fromJSON via the trimmed factory). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous header claimed this file was "the canonical home of the base MoneyAmount". It is not: the @domain/shared barrel does `export * from "./money"`, so ./money/MoneyAmount.ts is the base the app resolves as `MoneyAmount`; this file only contributes `USDTAmount`. Since USDTAmount extends this file's (separate) base, `x instanceof MoneyAmount` (the barrel's) does not match it — the comment now states that and points at the OffersSerde `|| instanceof USDTAmount` guard, and flags the two-base consolidation as the real follow-up. Also notes in Money.spec.ts why it imports MoneyAmount from the file path rather than the barrel. Comment-only; no behavioral change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review —
|
…518] Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review dispositions — all four findings resolvedThanks for the review. Closing out the loop so this is merge-ready:
This PR satisfies ENG-518's second acceptance path ("keep the top-level file solely for base |
Why
Follow-up to the cashout #449 → #450 saga.
src/domain/shared/MoneyAmount.tscarried duplicateUSDAmount/JMDAmount/BtcAmountclasses that were dead — the@domain/sharedbarrel serves those from./money(export * from "./money") and takes onlyUSDTAmountfrom this file. That shadow twin is exactly what let #449's JMD-rate fix land on the wrong copy while cashout stayed broken; #450 fixed the live./money/JMDAmount.ts.Change
Strip the file to its only live exports — the base
MoneyAmount+USDTAmount— and delete the deadUSDAmount/JMDAmount/BtcAmount.MoneyAmount.from()/fromJSON()(used only by tests, only with USDT; the sole prod reference is commented out) are trimmed to the USDT branch. A header comment documents the split so no currency-amount class gets re-added here.Verification
tsc -p tsconfig.json --noEmit: clean project-wide — nothing referenced the deleted classes.Money.spec.ts: 22/22 — including the barrel-resolvedJMDAmountfractional-rate regression (fix(cashout): decimal-safe JMD rate on the ACTUAL JMDAmount used by cashout #450), theUSDAmount → JMDAmountconversion, and the baseMoneyAmount.from(Usdt)/fromJSONround-trip that exercise the trimmed factory.Closes ENG-518.
🤖 Generated with Claude Code