fix(perps): navigation issue when you tap "add funds" in order screen#43367
fix(perps): navigation issue when you tap "add funds" in order screen#43367abretonc7s wants to merge 4 commits into
Conversation
Hyperliquid deposits settle USDC on Arbitrum, so PerpsController.depositWithConfirmation resolves the deposit transaction against the Arbitrum network client and throws "Invalid chain ID" when that network is not added to the wallet. The order-entry deposit hook swallowed that error, so tapping the "Available to trade" + icon did nothing. Port mobile's usePerpsNetworkManagement.ensureArbitrumNetworkExists: add the Arbitrum network (from the featured network list) before creating the deposit transaction, and call it from usePerpsDepositConfirmation.
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (2 files, +19 -5)
👨🔧 @MetaMask/perps (4 files, +165 -0)
|
Worker reportTAT-3131 — Navigation issue when tapping "Add Funds" on the Perps order screenSummaryVisiting Add Funds from the Perps order-entry screen and pressing back left a phantom Root cause
Changes
Validation recipeIncluded sub-flows/artifacts:
Automated:
Manual:
TAT-3272 — Add Funds did nothingBundled into this branch as the same Add Funds flow. Root cause: Arbitrum was absent from a clean wallet, causing Fix:
Verification:
Commit statusCommitted as:
Branch:
|
Builds ready [2875c78]
⚡ Performance Benchmarks (Total: 🟢 20 pass · 🟡 5 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
farmslot run summary
Worker reportPR #43367 — Comments ReportPR: fix(perps): navigation issue when you tap "add funds" in order screen Triage
Summary
Actionable comments requiring a code fix: 0. No review-fix commit was made — there is nothing to fix. The branch was brought up to date with CI parity gate
Recipe re-validation — post-merge state
Merge-main statusClean — no conflicts. Final summary
|
Builds ready [628ded2]
⚡ Performance Benchmarks (Total: 🟢 19 pass · 🟡 6 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
Tapping Add Funds on the Perps order-entry screen (
/perps/trade/:symbol) and returning corrupted the navigation history: the deposit confirmation's back action pushed a new history entry while the entry navigation replaced one, leaving a phantomconfirm-transactionentry on the stack. As a result, back navigation from the order screen required two taps (Bug A) and, after visiting Add Funds, executing a trade left the user stuck on the order screen instead of returning to market detail (Bug B).The fix makes the wallet-initiated confirmation back action return with
{ replace: true }inuseConfirmActions, symmetric with the confirm-context auto-exit. The transient deposit/withdraw/musd-claim confirmation no longer lingers in history, so one tap of back from the order screen returns to the Perps market detail screen and post-tradenavigate(-1)reaches market detail.TAT-3272 — Add Funds did nothing when the Arbitrum network was not added. Hyperliquid deposits settle USDC on Arbitrum, so
PerpsController.depositWithConfirmationresolves the deposit transaction against the Arbitrum network client and throwsInvalid chain ID "0xa4b1"("add the network first") when that network is absent from the wallet. The order-entry deposit hook swallowed that error (console.erroronly), so tapping the Available to trade + icon appeared to do nothing. The extension never ported mobile'susePerpsNetworkManagement.ensureArbitrumNetworkExists, which adds the Arbitrum network before depositing. This PR adds the extension equivalent and calls it fromusePerpsDepositConfirmationbefore creating the deposit transaction, so tapping + adds Arbitrum (from the curated featured-network list) when missing and opens the deposit confirmation.Changelog
CHANGELOG entry: Fixed Perps order screen back navigation after visiting Add Funds (single back tap now returns to the market detail screen, and trades no longer leave the user on the order screen).
CHANGELOG entry: Fixed Perps "Add Funds" doing nothing when the Arbitrum network was not yet added to the wallet (the deposit network is now added automatically).
Related issues
Fixes: TAT-3131
Fixes: TAT-3272
Manual testing steps
/perps/market/ETH)./perps/trade/ETH).TAT-3272 (Add Funds with the Arbitrum network not yet added):
Screenshots/Recordings
End-to-end proof of the Add Funds flow: tapping the Available-to-trade + icon opens the deposit confirmation (TAT-3272, Arbitrum network added automatically), and after returning a single tap of the order-entry back button reaches the market detail screen (TAT-3131, no double-tap).
Tapping the + icon now adds the Arbitrum network and opens the deposit screen; previously nothing happened.
After visiting Add Funds and returning, a single tap of the back button reaches market detail (no phantom history entry, no double-tap).
Pre-merge author checklist
Pre-merge reviewer checklist
Validation Recipe
recipe.json
{ "schema_version": 1, "title": "TAT-3131 + TAT-3272 — Add Funds deposit opens and one back tap returns to market detail", "description": "End-to-end proof of the original bug: from the Perps order-entry screen, tapping the Available-to-trade Add Funds (+) icon opens the deposit confirmation (TAT-3272: the Arbitrum network is added automatically), and after returning from the deposit screen a SINGLE tap of the order-entry back button returns to the Perps market detail screen (TAT-3131: no phantom history entry, no double-tap). Reverting either fix makes this recipe FAIL: revert TAT-3272 and the deposit never opens (ac1-wait-deposit times out); revert TAT-3131 and one back tap lands on the phantom confirmation instead of market detail (ac1-wait-market-detail times out).", "pre_conditions": { "account": "any unlocked fixture account on a Perps-enabled wallet", "network": "Arbitrum may be absent; TAT-3272 adds it on Add Funds" }, "validate": { "workflow": { "entry": "setup-unlock", "nodes": { "setup-unlock": { "action": "metamask.wallet.ensure_unlocked", "next": "setup-nav-perps", "intent": "Ensure the wallet is unlocked", "flow": "setup" }, "setup-nav-perps": { "action": "ui.navigate", "hash": "#/?tab=perps", "next": "setup-nav-market", "intent": "Open the Perps tab (pushes a history entry)", "flow": "setup" }, "setup-nav-market": { "action": "ui.navigate", "hash": "#/perps/market/BTC", "next": "setup-wait-market", "intent": "Open the BTC market detail screen (pushes a history entry)", "flow": "setup" }, "setup-wait-market": { "action": "ui.wait_for", "selector": "[data-testid=perps-market-detail-page]", "visible": true, "timeout_ms": 15000, "next": "setup-nav-order", "intent": "Wait for market detail before opening order entry", "flow": "setup" }, "setup-nav-order": { "action": "ui.navigate", "hash": "#/perps/trade/BTC?direction=long&mode=new", "next": "ac1-wait-order-entry", "intent": "Open the order entry screen (pushes a history entry on top of market detail)", "flow": "setup" }, "ac1-wait-order-entry": { "action": "ui.wait_for", "selector": "[data-testid=perps-order-entry-page]", "visible": true, "timeout_ms": 15000, "next": "ac1-press-add-funds", "intent": "AC1: order entry screen is rendered with the Add Funds entry point", "flow": "ac1" }, "ac1-press-add-funds": { "action": "ui.press", "selector": "[data-testid=amount-input-add-funds]", "next": "ac1-wait-deposit", "intent": "AC1/TAT-3272: tap the Available-to-trade Add Funds (+) icon", "flow": "ac1" }, "ac1-wait-deposit": { "action": "ui.wait_for", "selector": "[data-testid=wallet-initiated-header-back-button]", "visible": true, "timeout_ms": 15000, "next": "ac1-screenshot-deposit", "intent": "TAT-3272: the deposit confirmation opens (Arbitrum network added automatically). Before the fix this never appeared.", "flow": "ac1" }, "ac1-screenshot-deposit": { "action": "ui.screenshot", "timeout_ms": 10000, "note": "TAT-3272: deposit confirmation screen opened after tapping Add Funds", "claims": { "must_show": ["deposit / Add Funds confirmation screen", "back arrow"], "must_not_show": ["unchanged order entry screen"] }, "next": "ac1-press-deposit-back", "intent": "Capture the opened deposit confirmation", "flow": "ac1" }, "ac1-press-deposit-back": { "action": "ui.press", "selector": "[data-testid=wallet-initiated-header-back-button]", "next": "ac1-wait-back-order-entry", "intent": "Return from the deposit screen to the order entry screen", "flow": "ac1" }, "ac1-wait-back-order-entry": { "action": "ui.wait_for", "selector": "[data-testid=perps-order-entry-page]", "visible": true, "timeout_ms": 15000, "next": "ac1-press-order-back", "intent": "Back on the order entry screen after the deposit round-trip", "flow": "ac1" }, "ac1-press-order-back": { "action": "ui.press", "selector": "[data-testid=perps-order-entry-back-button]", "next": "ac1-wait-market-detail", "intent": "AC1/TAT-3131: tap the order-entry back button ONCE", "flow": "ac1" }, "ac1-wait-market-detail": { "action": "ui.wait_for", "selector": "[data-testid=perps-market-detail-page]", "visible": true, "timeout_ms": 15000, "next": "ac1-assert-market-detail-control", "intent": "TAT-3131: a SINGLE back tap returns to the market detail screen (no phantom, no double-tap). Before the fix one tap landed on the phantom confirmation.", "flow": "ac1" }, "ac1-assert-market-detail-control": { "action": "ui.wait_for", "selector": "[data-testid=perps-market-detail-back-button]", "visible": true, "timeout_ms": 8000, "next": "ac1-screenshot-market-detail", "intent": "Confirm a market-detail-specific control is present after the single back tap", "flow": "ac1" }, "ac1-screenshot-market-detail": { "action": "ui.screenshot", "timeout_ms": 10000, "note": "TAT-3131: one tap of the order-entry back button (after visiting Add Funds) lands on the Perps market detail screen", "claims": { "must_show": ["perps market detail screen for BTC"], "must_not_show": ["order entry screen", "deposit / Add Funds confirmation"] }, "next": "done", "intent": "Capture market detail reached in a single back tap after the deposit round-trip", "flow": "ac1" }, "done": { "action": "end", "status": "pass", "intent": "Finish: Add Funds opens and one back tap returns to market detail" } } } } }Recipe Workflow
workflow.mmd
flowchart TD setup-unlock[setup-unlock: ensure wallet unlocked] --> setup-nav-perps[setup-nav-perps: open Perps tab] setup-nav-perps --> setup-nav-market[setup-nav-market: open BTC market detail] setup-nav-market --> setup-wait-market[setup-wait-market: wait perps-market-detail-page] setup-wait-market --> setup-nav-order[setup-nav-order: open order entry] setup-nav-order --> ac1-wait-order-entry[ac1-wait-order-entry: wait perps-order-entry-page] ac1-wait-order-entry --> ac1-press-add-funds[ac1-press-add-funds: tap amount-input-add-funds] ac1-press-add-funds --> ac1-wait-deposit[ac1-wait-deposit: wait wallet-initiated-header-back-button TAT-3272] ac1-wait-deposit --> ac1-screenshot-deposit[ac1-screenshot-deposit] ac1-screenshot-deposit --> ac1-press-deposit-back[ac1-press-deposit-back: tap deposit back] ac1-press-deposit-back --> ac1-wait-back-order-entry[ac1-wait-back-order-entry: wait perps-order-entry-page] ac1-wait-back-order-entry --> ac1-press-order-back[ac1-press-order-back: tap perps-order-entry-back-button ONCE] ac1-press-order-back --> ac1-wait-market-detail[ac1-wait-market-detail: wait perps-market-detail-page TAT-3131] ac1-wait-market-detail --> ac1-assert-market-detail-control[ac1-assert-market-detail-control: wait perps-market-detail-back-button] ac1-assert-market-detail-control --> ac1-screenshot-market-detail[ac1-screenshot-market-detail] ac1-screenshot-market-detail --> done([done: pass])Note
Medium Risk
Changes wallet network auto-add and confirmation cancel navigation for perps deposit/withdraw flows; limited to curated featured RPCs and replace-only back navigation when goBackTo is set.
Overview
Fixes Perps Add Funds and back navigation after visiting the deposit confirmation from the order screen.
History (TAT-3131): When canceling a wallet-initiated confirmation with
goBackTo,useConfirmActionsnow navigates with{ replace: true }instead of pushing. That removes the extraconfirm-transactionhistory entry so a single back from the order screen returns to market detail and post-trade navigation is not stuck.Deposit (TAT-3272): Adds
usePerpsNetworkManagementwithensureArbitrumNetworkExists, which dispatchesaddNetworkfromFEATURED_RPCSwhen Arbitrum (or testnet chain when configured) is missing.usePerpsDepositConfirmationawaits that step before creating the deposit transaction so the controller no longer fails with invalid chain ID when Arbitrum was never added.Tests cover replace navigation, network add/skip paths, and call order (ensure network before deposit tx).
Reviewed by Cursor Bugbot for commit 628ded2. Bugbot is set up for automated code reviews on this repo. Configure here.