…etaMask#46498)
## **Description**
`link.metamask.io/buy` deep links now route into the in-app Buy flow
instead of redirecting to Portfolio, so the link's token is preselected
and buyers get the same eligibility checks as the in-app Buy button.
Mobile already does this
([TRAM-3853](https://consensyssoftware.atlassian.net/browse/TRAM-3853)).
`/buy` lands on a new entry page (`/ramps/buy-deeplink-entry`) that maps
the link params (`assetId`, or `address` + `chainId`) to a CAIP-19 asset
and hands off to the existing `goToBuy`. Users who have connected to
Portfolio before are still redirected there with the link params
unchanged, but now via the extension (a locked wallet must be unlocked
first).
The same routing applies to `/buy` links in the carousel and
notifications. `DeepLinkUsed` now fires for `/buy` links that route
in-app.
**Interstitial:** unchanged. The destination is resolved outside the
interstitial decision, which is untouched, so the interstitial shows
exactly as often as before.
> [!NOTE]
> Stacked on MetaMask#47459, which removes the `rampsEnabled` flag. This PR is
rebased on that branch; the diff is the deep-link routing only.
## **Changelog**
CHANGELOG entry: Routed Buy deep links into the in-app Buy flow with the
token preselected.
## **Related issues**
Fixes:
[TRAM-3853](https://consensyssoftware.atlassian.net/browse/TRAM-3853)
Stacked on: MetaMask#47459
## **Manual testing steps**
**Setup:**
1. Run `yarn build:test`, then Chrome → `chrome://extensions` → **Load
unpacked** → `dist/chrome`; create/import a wallet and unlock it.
2. If a "Basic functionality is off" page appears, enable it once — it
persists for the session.
3. Every scenario below works the same way: paste the URL into any tab's
address bar. The pasted tab may error or stay blank — **expected**. The
interstitial opens in a **new tab** ("Proceed with caution…") → click
**Continue** → observe the result.
4. Between scenarios, close the extension tab(s) that opened.
#### Happy paths
**A1. Plain `/buy`** → in-app **token selection**
(`#/ramps/token-selection`); the wallet stays in the extension tab, no
Portfolio tab.
```
https://link.metamask.io/buy
```
**A2. DAI via EVM params** → build-quote with **"Buy DAI / on
Ethereum"** preselected.
```
https://link.metamask.io/buy?address=0x6b175474e89094c44da98b954eedeac495271d0f&chainId=1
```
**A3. Zero address (native token)** → **"Buy ETH / on Ethereum"**
preselected.
```
https://link.metamask.io/buy?address=0x0000000000000000000000000000000000000000&chainId=1
```
**A4. CAIP-19 `assetId`** → **"Buy DAI"** preselected (same as A2,
different param style).
```
https://link.metamask.io/buy?assetId=eip155:1/erc20:0x6B175474E89094C44Da98b954EedeAC495271d0F
```
**A5. `assetId` precedence** → **"Buy DAI"**: `assetId` wins, the
conflicting native-token params are ignored.
```
https://link.metamask.io/buy?assetId=eip155:1/erc20:0x6B175474E89094C44Da98b954EedeAC495271d0F&address=0x0000000000000000000000000000000000000000&chainId=1
```
#### Error & invalid-input handling
**B1. Token not in the catalog** → "Buying crypto isn't supported…"
modal; dismiss → back on **wallet home**, not a spinner.
```
https://link.metamask.io/buy?address=0x1111111111111111111111111111111111111111&chainId=1
```
**B2. Garbage `assetId`** → **Token selection**; the invalid param is
silently dropped, no crash.
```
https://link.metamask.io/buy?assetId=garbage
```
**B3. Garbage `chainId` + invalid address** → **Token selection**, no
crash.
```
https://link.metamask.io/buy?chainId=abc&address=0xzz
```
**B4. Well-formed non-Mainnet link (USDC on Polygon)** → **"Buy USDC /
on Polygon"** if it's in the live catalog, else the unsupported modal →
home.
```
https://link.metamask.io/buy?address=0x3c499c542cef5e901a0079a8bb6c6e4e07c8db10&chainId=137
```
#### Security & invariants
**C1. Interstitial is always shown** → interstitial with *"You'll open
the buy page if you continue."* Nothing auto-navigates.
```
https://link.metamask.io/buy
```
**C2. Invalid signature does not bypass** → **still the interstitial** —
no 404, no auto-entry; then Continue → "Buy DAI" normally.
```
https://link.metamask.io/buy?address=0x6b175474e89094c44da98b954eedeac495271d0f&chainId=1&sig_params=address%2CchainId&sig=AAAAinvalidsignatureAAAA
```
**C3. Locked wallet** → lock the wallet, then paste. Interstitial →
Continue → unlock prompt → **"Buy DAI"** (the link is not lost).
```
https://link.metamask.io/buy?address=0x6b175474e89094c44da98b954eedeac495271d0f&chainId=1
```
**C4. Back button does not bounce** → run A2, then press the browser
**Back** button. You land on the interstitial page and it **stays** — no
bounce back, no re-run, no duplicate history entries.
#### Cold start (quit Chrome fully with ⌘Q, relaunch, unlock, wait ~5s —
the tokens catalog is empty on arrival)
**D1. Token link after restart** → **"Buy DAI" build-quote** after a
brief spinner while the catalog is fetched on demand. Must **never**
show the "Buying crypto isn't supported / not available" modal.
```
https://link.metamask.io/buy?address=0x6b175474e89094c44da98b954eedeac495271d0f&chainId=1
```
**D2. Param-less link after restart** → **Token selection** — not
stranded on the spinner, not the unsupported modal.
```
https://link.metamask.io/buy
```
## **Screenshots/Recordings**
### **After**
#### Happy paths
https://github.com/user-attachments/assets/1b1f1d7a-4c1e-4efb-96c1-e75346f00b86
https://github.com/user-attachments/assets/62ec7ef3-ecd7-4517-96aa-5fcef3234cfe
https://github.com/user-attachments/assets/fcab5ef9-909a-49f3-aaad-5d959735555b
https://github.com/user-attachments/assets/c9ce4ad9-d25f-417a-9c11-17c6e3049c4a
https://github.com/user-attachments/assets/a7ec78d5-3272-40d3-b042-45cda425f56f
#### Error & invalid-input handling
https://github.com/user-attachments/assets/2fa693a3-85cd-40d7-8995-16e63d82482e
https://github.com/user-attachments/assets/3250deaf-2ca8-4c8f-8eea-6a2e4a3e3835
https://github.com/user-attachments/assets/39adfa13-0cca-42ab-b5ae-669e243a2698
https://github.com/user-attachments/assets/dc594e21-6c51-48a6-8a59-ce6146ca84a4
#### Security & invariants
https://github.com/user-attachments/assets/f36b5535-3f2e-4ccc-a8a1-161c12bc0089
https://github.com/user-attachments/assets/694cf384-0e61-4eb2-b79d-3ac1db76b3d1
https://github.com/user-attachments/assets/6822b5b2-01c7-4842-aa45-befb698acc23
https://github.com/user-attachments/assets/6ca25462-8b80-45fd-b76f-d0d6e895dca5
#### Cold start
https://github.com/user-attachments/assets/f42024f9-27e5-4a72-a8f2-c18ee1f3f313
https://github.com/user-attachments/assets/0aedfd2b-1bf1-4cc7-b9c7-33543bb36222
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
[TRAM-3853]:
https://consensyssoftware.atlassian.net/browse/TRAM-3853?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[TRAM-3853]:
https://consensyssoftware.atlassian.net/browse/TRAM-3853?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches deep-link routing, buy eligibility gates, and cold-start
catalog/region resolution; regressions could mis-route users or block
valid buys, though coverage is extensive.
>
> **Overview**
> **`/buy` deep links now open the in-app unified Buy flow** instead of
redirecting to Portfolio. The shared deep-link handler routes to a new
**`/ramps/buy-interstitial`** entry that parses link params into a buy
intent, preserves query params for any Portfolio fallback URL, and
delegates to the existing **`goToBuy`** gate (token selection vs
build-quote with pre-selection).
>
> **`goToBuy` is extended** for this entry path: optional **`replace`**
history, **`portfolioRedirectUrl`** for migration users, on-demand
**countries/tokens** fetch on cold start before pre-select, and
**`resolveRampControllerToken`** for CAIP-19 casing and native
**`slip44:.`** placeholders. Background exposes **`getRampsCountries`**
through the ramps controller API.
>
> Supporting changes include a new route constant, router wiring,
unit/e2e coverage for deep links and interstitial behavior, CODEOWNERS
for buy routes, and test fixtures that no longer treat **`/buy`** as an
external redirect (redirect examples moved to **`card-onboarding`**).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a02cfb8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Description
Removes the fully rolled-out
rampsEnabledremote feature flag. Its production default is already{ enabled: true, minimumVersion: '13.48.0' }, so this deletes the off-path rather than changing behavior for supported versions.This is a prerequisite for the
/buydeep-link work in #46498, which currently has to thread the flag through the deep-link router. Landing the removal first keeps that PR free of rollout-gate plumbing.Changes:
getIsRampsEnabledfromui/selectors/ramps-feature-flags.tsand its selector tests.!isEnabled → open Portfoliobranch fromuseRampsNavigation.useRampsAnalyticsand the flag check fromuseRampsScreenViewed.rampsEnabledfrom the e2e feature-flag registry.rampsServiceDisruptionas the service kill switch.Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
ramps-*events still fire in the Segment debugger.rampsServiceDisruptionremote flag (or override it locally) and verify the service-disruption modal is still shown./buydeep link from a dapp and verify its routing is unchanged by this PR (the routing change is in feat(ramps): route /buy deep links into the in-app unified buy flow #46498).Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes default Buy routing for any client that still had
rampsEnabledoff, and removes analytics silencing tied to that flag;rampsServiceDisruptionbehavior is unchanged.Overview
Removes the fully rolled-out
rampsEnabledremote flag so the in-app ramps buy path is always used instead of treating “flag off” as “open Portfolio.”getIsRampsEnabledand its selector tests are deleted;rampsEnabledis dropped from the E2E feature-flag registry.rampsServiceDisruptionstays as the kill switch.useRampsNavigation.goToBuyno longer short-circuits toopenBuyCryptoInPdappwhen the rollout flag was false—Portfolio migration, geo, disruption, and native routing behave as they did when the flag was on.useRampsAnalyticsanduseRampsScreenViewedno longer skipramps-*events when the flag was off.Tests drop flag-gating cases and align Buy entry assertions with
goToBuy(wallet overviews, asset page); ramps UI tests stub analytics where the background connection is not initialized.Reviewed by Cursor Bugbot for commit 6cc38b5. Bugbot is set up for automated code reviews on this repo. Configure here.