feat: adds support for custom actions#8100
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
The V2 API returns a different providerOrderId format (e.g. PayPal's numeric ID or null) than the ramps order code used as the lookup key. When getOrder merged the API response onto an existing order, the spread overwrote providerOrderId, breaking all subsequent lookups via getOrderById and causing blank Order Details screens. Always set providerOrderId to orderCode after the merge so the canonical lookup key is never lost. Made-with: Cursor
|
@cursoragent fix the linting issue |
|
Fixed the linting issue! The problem was a negated condition at line 1949 in Changed:
The linting now passes successfully, and I've committed and pushed the fix to the |
Co-authored-by: George Weiler <georgejweiler@gmail.com>
| if (!buyWidget?.url) { | ||
| return null; | ||
| } | ||
| return buyWidget; |
There was a problem hiding this comment.
breaking: we are now returning both the URL and the extra data such as the supported browser type and custom order ID.
PR #8100 was merged with a stale base, causing its changelog entry to land under the already-released [10.1.0] section instead of [Unreleased]. This moves it to the correct location so that the next release picks it up. Made-with: Cursor
) ## Explanation PR #8100 was merged with a stale base branch (two releases had happened since the last rebase). This caused its changelog entry to land under the already-released `[10.1.0]` section instead of `[Unreleased]`. This moves the entry to the correct location so the next release picks it up properly. ## References - Original PR: #8100 - Slack discussion: https://consensys.slack.com/archives/C094GV3E7SB/p1773162520956669 - Mark Stacey identified the issue: #8167 (comment) ## Changelog N/A — this only moves an existing changelog entry to the correct section. Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only change in `CHANGELOG.md` with no runtime or API behavior modifications. > > **Overview** > Moves the `ramps-controller` changelog entry for PR #8100 (a **BREAKING** API change replacing `getWidgetUrl` with `getBuyWidgetData` and adding `addPrecreatedOrder`) from the already-released `10.1.0` section into `[Unreleased]` so it is captured in the next release notes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ab81ce8. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…lows (#27364) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> 1. Integrates new ramps-controller API for custom-action flows (e.g., PayPal) removes Redux-based custom ID tracking. 2. Simplifies ramps-controller state hydration system into a single `init` call on app start up. **What changed:** - **BuildQuote** — Uses `getBuyWidgetData` instead of `getWidgetUrl`. For `isCustomAction` quotes, calls `addPrecreatedOrder` before opening external browser (InAppBrowser or `Linking.openURL`) and passes `orderId` to Checkout for WebView flows. - **Checkout** — Uses `addPrecreatedOrder` instead of Redux `addFiatCustomIdData`. Supports both `orderId` and `customOrderId` for backwards compatibility. - **Hooks** — `useRampsOrders` exposes `addPrecreatedOrder` and `AddPrecreatedOrderParams`; `useRampsQuotes` uses `getBuyWidgetData` returning `Promise<BuyWidget | null>`; `useRampsController` exposes both. - **Provider/payment filtering** — `PaymentSelectionModal` and `ProviderSelection` filter out `isCustomAction` quotes where appropriate. **What stays untouched:** Non-custom-action flows (standard WebView checkout) unchanged. Existing ramps navigation and token selection preserved. **Dependencies:** Requires MetaMask/core#8100 for the new controller API. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Adds support for ramps providers such as PayPal, Robinhood & Coinbase that use a different checkout browser ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] 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-mobile/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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the `BuildQuote` continue flow to support external-browser widget checkouts with precreated order tracking and post-auth callback handling, which can affect buy navigation and order state. Mostly scoped to ramps UI/controller integration with expanded test coverage, but touches user-facing purchase flow and deep-link/callback paths. > > **Overview** > Updates the ramps **BuildQuote** flow to use the new controller API `getBuyWidgetData` (replacing `getWidgetUrl`) and to support widget providers that require *external* checkout. When external browser checkout is used, it now pre-creates an order via `addPrecreatedOrder`, opens the widget via `InAppBrowser.openAuth` (or `Linking.openURL` fallback), parses the callback to fetch/add the resulting order, and resets navigation either back to `BuildQuote` or into `RAMPS_ORDER_DETAILS`. > > Refactors amount entry handling into a shared `updateAmount` path and consolidates user-facing errors under `rampsError` using `reportRampsError`. Bootstrap is adjusted to run `useRampsProviders` on mount (replacing `useHydrateRampsController`), and tests are heavily rewritten/updated to cover the new routing, error, and callback/order-handling behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 10e9092. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Amitabh Aggarwal <aggarwal.amitabh@gmail.com>


Explanation
Introduces controller API support for custom-action ramp flows (e.g., PayPal).
What changed:
getBuyWidgetData(quote)— ReplacesgetWidgetUrl. ReturnsBuyWidget | null(url, optionalbrowser, optionalorderId) instead ofstring | null. Returnsnullwhen fetch fails or no URL is available.addPrecreatedOrder(params)— New method accepting{ orderId, providerCode, walletAddress, chainId? }. Parses order IDs (including/orders/path format), normalizesproviderCode(strips/providers/prefix), and inserts a stubRampsOrderinPrecreatedstatus for existing polling to hydrate.What stays untouched: Existing controller state shape, polling behavior, and other order flows remain unchanged aside from the new API surface.
Dependencies: None in core; mobile and extension consume these changes.
References
Checklist
Note
Medium Risk
Medium risk due to a breaking public API change (
getWidgetUrl->getBuyWidgetData) and new order-state mutations (addPrecreatedOrder,getOrdernow inserts missing orders) that can affect ramp UI/polling behavior for consumers.Overview
BREAKING: Replaces
getWidgetUrlwithgetBuyWidgetData, returning aBuyWidget | null(includingbrowser/orderId) and now propagating service-call errors instead of swallowing them.Adds
addPrecreatedOrderto register a provider order ID (parsing/orders/IDs and normalizing provider codes) by inserting a stubRampsOrderinPrecreatedstatus so existing polling can hydrate it, and updatesgetOrderto push the order into state when it isn’t already present.Exports
normalizeProviderCode, updates tests to cover the new APIs/edge cases, and documents the breaking change in the changelog.Written by Cursor Bugbot for commit 64885db. This will update automatically on new commits. Configure here.