Skip to content

fix(tokens): correct non USD Phantom add-money flow - #1173

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/phantom-inr-add-money
Jul 29, 2026
Merged

fix(tokens): correct non USD Phantom add-money flow#1173
bmc08gt merged 1 commit into
code/cashfrom
fix/phantom-inr-add-money

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the Add money via Phantom flow, which was broken for non-USD (e.g. INR) users and mis-navigated on the buy-shortfall path. Found and verified on-device with the app set to INR.

Changes

  • Currency mislabel (the deposit failure). The Phantom confirm path forced exchange.rateForUsd(), so the entered amount (in the user's selected currency) was labelled USD — e.g. ₹500 treated as $500. compute() then skipped the FX conversion and produced an underlyingTokenAmount ~83× too large, so checkBalances rejected the deposit as InsufficientUsdc (surfacing at getTokenAccountBalance). Now uses exchange.preferredRate.

  • Unlocalized max hint. The "Enter up to X" / over-max hint used a USD-denominated max while the user typed in their local currency. maxAmountFlow now converts the token balance to the preferred currency, so the hint and the over-max comparison agree with the entry field.

  • Stranded on the connect prompt (buy-shortfall path). purchaseMethodController.selections is a hot flow with two collectors. The PhantomWallet branch lacked the amount-less-selection guard that CoinbaseOnRamp already had, so tapping Phantom in the deposit sheet double-fired PhantomSelected and navigated the buy flow to PhantomConnect — which reappeared after the nested add-money flow finished. Hoisted the purchaseAmount guard so amount-less deposit-sheet selections are ignored.

  • Returned one screen short. The buy-shortfall add-money route stacked on top of the buy flow, so completion popped back to the amount-to-buy step. The OpenScreen handler now replaces the buy flow, so finishing the top-up returns to the token screen (origin) — matching add-money launched directly from the token screen. Note: this abandons the in-progress buy (re-tap Buy with the new balance).

  • Processing is terminal. The two Phantom→Processing handlers use replaceStack(listOf(Processing)) so leaving Processing exits the flow rather than surfacing buried connect/confirm steps. Added InnerFlowNavigatorTest cases covering the back-stack behavior (the forward-slide animation is preserved — nav3 treats a root swap as a forward navigation).

Test plan

  • :ui:navigation:testDebugUnitTest --tests InnerFlowNavigatorTest — green (9/9).
  • On-device (device set to INR): buy hint shows ; buy Moony → over-hint amount → Add Money → Phantom → completes and returns to the Moony token-info screen (previously stranded on the connect prompt, then one screen short). Verified by the reporter.

The "Add money via Phantom" flow was broken for non-USD (e.g. INR) users
and mis-navigated on the buy-shortfall path.

- Interpret the Phantom add-money amount in the user's selected currency.
  The confirm path forced exchange.rateForUsd(), labelling e.g. ₹500 as
  $500, so compute() skipped the FX conversion and produced an
  underlyingTokenAmount ~83x too large — checkBalances then rejected the
  deposit as InsufficientUsdc. Now uses exchange.preferredRate.

- Localize the "Enter up to X" max-balance hint. The AddMoney max came
  from USD-denominated token balances; convert it to the preferred
  currency so the hint (and the over-max comparison) match what the user
  is typing.

- Guard purchaseMethodController.selections against the amount-less
  deposit-sheet selection (the CoinbaseOnRamp branch already did this).
  Without it, tapping Phantom in the buy-shortfall sheet double-navigated
  the buy flow to PhantomConnect, stranding the user on the connect prompt
  after the add-money flow finished.

- Replace the buy flow with the add-money route so finishing the top-up
  returns to the token screen (origin) instead of the abandoned
  amount-to-buy step.

- Make the Phantom Processing step terminal via replaceStack, with
  InnerFlowNavigator unit tests covering the back-stack behavior.
@github-actions github-actions Bot added area: ui Compose UI, theme, components, resources area: tokens Token accounts, balances, token info type: fix Bug fix labels Jul 29, 2026
@bmc08gt bmc08gt changed the title fix(tokens): correct INR Phantom add-money flow fix(tokens): correct non USD Phantom add-money flow Jul 29, 2026
@bmc08gt
bmc08gt merged commit 5c70306 into code/cash Jul 29, 2026
3 checks passed
@bmc08gt
bmc08gt deleted the fix/phantom-inr-add-money branch July 29, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tokens Token accounts, balances, token info area: ui Compose UI, theme, components, resources type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant