Skip to content

Conversation

@AxelGes
Copy link
Contributor

@AxelGes AxelGes commented Jan 28, 2026

Explanation

The RampsController needs the ability to fetch quotes from multiple providers. This PR adds quotes functionality to consume the new V2 orders API endpoint (GET /v2/orders/all/quotes).

Changes:

RampsService:

  • Added quote-related types: Quote, QuoteError, QuoteSortBy, QuoteSortOrder, QuoteCryptoTranslation, QuoteCustomAction, QuotesResponse, and GetQuotesParams
  • Added getQuotes() method that calls the V2 orders API endpoint with support for multiple payment methods, provider filtering, and redirect URLs

RampsController:

  • Added quotes state property to store fetched quotes
  • Added getQuotes() method with caching support that uses region/fiat/paymentMethods from state if not provided
  • Added getWidgetUrl(quote) helper method to extract the widget URL from a quote for redirect providers
  • Added triggerGetQuotes() fire-and-forget method for React effects

Exports:

  • Exported all new quote-related types from index.ts

This enables two key user stories:

  1. On the 'pay with' + provider modal, users can see quotes for available payment methods when an amount is entered
  2. On the amount input screen, users can initiate the webview flow for redirect providers by getting the widget URL from a quote

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Introduces a new external API integration and new state (quotes) with caching/normalization logic, which can affect UI behavior and request freshness if parameters or TTL are wrong. No authentication or sensitive data handling changes beyond sending wallet addresses as request params.

Overview
Adds multi-provider quotes support end-to-end: RampsService#getQuotes calls the new GET /v2/orders/all/quotes endpoint (supporting multiple payments, optional providers filter, optional redirectUrl, and buy/sell via action) and validates the response shape.

Updates RampsController to track quotes in state (cleared on region changes), adds getQuotes with parameter validation + short (15s) request caching, a triggerGetQuotes fire-and-forget helper, and a getWidgetUrl helper for redirect-provider quotes.

Wires the new messenger action type RampsService:getQuotes, exports the new quote-related types from index.ts, and adds comprehensive unit tests plus a changelog entry.

Written by Cursor Bugbot for commit 6288925. This will update automatically on new commits. Configure here.

@AxelGes AxelGes requested review from a team as code owners January 28, 2026 01:03
Add support for fetching quotes from multiple providers via the V2 orders API.

- Add `getQuotes()` method to RampsService to call GET /v2/orders/all/quotes
- Add `getQuotes()` method to RampsController with caching and state defaults
- Add `getWidgetUrl()` helper to extract widget URL from a quote
- Add `triggerGetQuotes()` fire-and-forget method for React effects
- Add `quotes` state property to store fetched quotes
- Add Quote, QuotesResponse, GetQuotesParams, and related types
- Export new types from index.ts
@AxelGes AxelGes force-pushed the feat/ramps-controller-quotes branch from bccee41 to 1b07732 Compare January 28, 2026 01:03
- Add redirectUrl to quotes cache key to prevent incorrect caching
- Fix array mutation by copying before sort in cache key
- Clear quotes state on region change in setUserRegion and cleanupState
- Rename err to error in QuoteError type (lint: restricted identifier)
- Fix prettier formatting
- Add redirectUrl parameter to quotes API request
- Add validation for amount, assetId, and walletAddress
- Set 15s default TTL for quotes (time-sensitive data)
- Simplify CHANGELOG entry per reviewer feedback
- Fix race condition in getQuotes by checking region matches before updating state
- Add complete response validation for all required QuotesResponse fields
- Add comprehensive tests for both fixes
Resolve merge conflicts from PR #7734 which renamed preferredProvider to selectedProvider and added selectedToken functionality.

Changes:
- Merge imports: Add RampsToken along with QuotesResponse, Quote, GetQuotesParams
- State already updated from main: selectedProvider and selectedToken
- All tests passing with 100% coverage
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@AxelGes AxelGes added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 05759fa Jan 29, 2026
306 checks passed
@AxelGes AxelGes deleted the feat/ramps-controller-quotes branch January 29, 2026 18:26
github-merge-queue bot pushed a commit that referenced this pull request Jan 30, 2026
…7793)

## Summary

Fixes a bug in `getQuotes()` where `assetId` and `walletAddress` were
validated to not be empty/whitespace but the untrimmed values were used
in the cache key and sent to the API. This could cause issues if values
with leading/trailing spaces were passed.

## Changes

- Normalize `assetId` and `walletAddress` by trimming them after
validation
- Use normalized values consistently in cache key and params sent to API
- Add test to verify trimming behavior works correctly

## Test plan

- All existing tests pass
- New test added to verify assetId and walletAddress are trimmed before
being sent to the service

## Related

Follow-up fix to #7747

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: small normalization change limited to `getQuotes` plus a
targeted unit test; main impact is cache key/param normalization which
could change caching behavior for inputs with whitespace.
> 
> **Overview**
> Fixes `RampsController.getQuotes` to **trim** `assetId` and
`walletAddress` after validation and then use the normalized values
consistently in the request `cacheKey` and service params.
> 
> Adds a unit test covering whitespace-trim behavior and records the fix
in `CHANGELOG.md`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d6ec3a2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants