Skip to content

feat: pass explicit params to RampsController:getQuotes and persist rampsQuote on fiatPayment#8628

Merged
OGPoyraz merged 8 commits intomainfrom
ogp/mmpay-fiatquote-modifications
May 4, 2026
Merged

feat: pass explicit params to RampsController:getQuotes and persist rampsQuote on fiatPayment#8628
OGPoyraz merged 8 commits intomainfrom
ogp/mmpay-fiatquote-modifications

Conversation

@OGPoyraz
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz commented Apr 29, 2026

Explanation

The fiat quote flow in transaction-pay-controller was calling RampsController:getQuotes without specifying the asset, provider, or currency - relying on defaults or a hardcoded pickBestFiatQuote helper that filtered for a specific staging provider.

This PR:

  1. Passes explicit parameters to RampsController:getQuotes: assetId (from fiatAsset.caipAssetId), providers (from RampsControllerState.providers.selected.id), and fiat: 'USD'.
  2. Picks the first quote from quotes.success[0] instead of searching by hardcoded provider name via pickBestFiatQuote.
  3. Persists the ramps quote on TransactionFiatPayment.rampsQuote via TransactionPayController:updateFiatPayment so downstream consumers can access it.
  4. Extracts getRampsQuote helper to isolate ramps state reading and quote fetching for readability.
  5. Removes pickBestFiatQuote and the unused FiatQuotesResponse type alias since they are no longer needed.
  6. Adds RampsControllerGetStateAction to allowed actions so the messenger can read ramps controller state.

References

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
Moderate risk: changes the fiat quoting path by selecting providers via RampsController:getState and altering how a ramps quote is chosen/persisted, which could affect quote availability and downstream consumers of fiatPayment state.

Overview
Improves the fiat quote flow to call RampsController:getQuotes with explicit assetId, fiat (defaulting to USD), and an optional providers filter derived from RampsController:getState (instead of relying on implicit defaults and a hardcoded provider filter).

Persists the selected ramps quote onto per-transaction state (TransactionFiatPayment.rampsQuote) via TransactionPayController:updateFiatPayment, removes the now-unused pickBestFiatQuote helper/types, and updates tests to cover provider-selection behavior and persistence.

Reviewed by Cursor Bugbot for commit 9e4c29b. Bugbot is set up for automated code reviews on this repo. Configure here.

@OGPoyraz OGPoyraz requested a review from a team as a code owner April 29, 2026 09:06
@OGPoyraz OGPoyraz requested a review from a team as a code owner April 29, 2026 09:07
@OGPoyraz OGPoyraz force-pushed the ogp/mmpay-fiatquote-modifications branch from 9da8fdd to 0d43e4a Compare April 29, 2026 09:08
Comment on lines +168 to +169
const rampsState = messenger.call('RampsController:getState');
const selectedProviderId = rampsState.providers.selected?.id;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There will always be a selected provider as Ramps team mentioned. Even though this is undefined we will pick first quote.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Although there's going to be a selected provider already this function restricts the current abilities of RampsController:getQuotes, so in case there is a need to set a specific provider this function would not allow it. I'm ok approving as is if this can be refactored later.

const quotes = await messenger.call('RampsController:getQuotes', {
amount: adjustedAmount,
assetId: fiatAsset.caipAssetId,
fiat: 'USD',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

'USD' will be hard lock for MMPay confirmations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure if fiat has any effect here as the currency is determined by the region. @saustrie-consensys @pkowalski can check and confirm

Comment on lines +127 to +130
messenger.call('TransactionPayController:updateFiatPayment', {
callback: (fiatPayment) => {
fiatPayment.rampsQuote = fiatQuote;
},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exact fiatPayment.rampsQuote will be required to start headless ramps operation in client, hence we will hold this in the fiatPayment state.

@OGPoyraz OGPoyraz changed the title feat: pass explicit params to RampsController:getQuotes and persist rampsQuote on fiat payment feat: pass explicit params to RampsController:getQuotes and persist rampsQuote on fiatPayment Apr 29, 2026
wachunei
wachunei previously approved these changes Apr 30, 2026
matthewwalsh0
matthewwalsh0 previously approved these changes May 1, 2026
const quotes = await messenger.call('RampsController:getQuotes', {
amount: adjustedAmount,
assetId: fiatAsset.caipAssetId,
fiat: 'USD',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To clarify, this insists the provider deal in USD? Do all the providers respect that? Or are the values / quotes converted in the RampsController?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And worth a constant?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

assetId: fiatAsset.caipAssetId,
fiat: 'USD',
paymentMethods: [fiatPaymentMethod],
providers: selectedProviderId ? [selectedProviderId] : undefined,
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 May 1, 2026

Choose a reason for hiding this comment

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

Why do we need to retrieve state from the RampsController only to give it back?

Can this not be the default providers value if not set?

Or we use an optional property such as useSelectedProvider: true?

Not a blocker, but would help encapsulation and decoupling.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree, there are multiple ways to adjust the request in better shape, we should even consider having an explicit API to return single quote for MMPay use-case as we care just the best quote.

These are all mentioned and alignments may follow in future.

selectedProviderId,
});

const quote = quotes.success?.[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just clarifying the obvious for audit sake that success is ordered by preference so first entry is best?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes that's right, but I believe we most probably never going to get more than one quote as limited to one provider while calling getQuotes.

@OGPoyraz OGPoyraz force-pushed the ogp/mmpay-fiatquote-modifications branch from 984a392 to 73e119e Compare May 4, 2026 05:54
@OGPoyraz OGPoyraz requested a review from matthewwalsh0 May 4, 2026 06:03
@OGPoyraz OGPoyraz enabled auto-merge May 4, 2026 07:50
OGPoyraz and others added 7 commits May 4, 2026 11:13
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ler:getState

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…tes and persist rampsQuote

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…fications

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@OGPoyraz OGPoyraz force-pushed the ogp/mmpay-fiatquote-modifications branch from 73e119e to f0a595c Compare May 4, 2026 09:14
matthewwalsh0
matthewwalsh0 previously approved these changes May 4, 2026
@OGPoyraz OGPoyraz added this pull request to the merge queue May 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 4, 2026
@OGPoyraz OGPoyraz added this pull request to the merge queue May 4, 2026
Merged via the queue into main with commit a6edb24 May 4, 2026
366 checks passed
@OGPoyraz OGPoyraz deleted the ogp/mmpay-fiatquote-modifications branch May 4, 2026 10:08
@OGPoyraz OGPoyraz mentioned this pull request May 4, 2026
4 tasks
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 4, 2026
## Explanation

Release `955.0.0` with a major version bump for:

- **`@metamask/transaction-pay-controller`** `20.2.0` → `21.0.0`

### `@metamask/transaction-pay-controller@21.0.0`

**Breaking:** Narrow `AllowedActions` type to use individual action
types instead of compound controller action unions
(`BridgeControllerActions`, `BridgeStatusControllerActions`,
`CurrencyRateControllerActions`, `GasFeeControllerActions`)

Other changes:
- Add Gas Station support for Across source transactions when native
balance is insufficient
- Pass explicit `assetId`, `providers`, and `fiat` to
`RampsController:getQuotes` and persist the selected ramps quote on
`TransactionFiatPayment`

### Dependency updates

No packages depend on `@metamask/transaction-pay-controller`, so no
dependency range updates were needed.

## References

- [MetaMask#8670](MetaMask#8670) — Narrow
`AllowedActions` to individual action types (BREAKING)
- [MetaMask#8588](MetaMask#8588) — Add Gas Station
support for Across source transactions
- [MetaMask#8628](MetaMask#8628) — Pass explicit
params to `RampsController:getQuotes` and persist `rampsQuote`

## 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
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> This is primarily a release/versioning PR, but it publishes
`@metamask/transaction-pay-controller@21.0.0` which includes a
documented **breaking** `AllowedActions` type change that may require
consumer updates.
> 
> **Overview**
> Bumps the monorepo version to `955.0.0` and releases
`@metamask/transaction-pay-controller` from `20.2.0` to `21.0.0`.
> 
> Updates the `transaction-pay-controller` changelog with the `21.0.0`
release notes, including a **breaking** narrowing of the
`AllowedActions` type, plus Gas Station support for Across source
transactions and a ramps quoting fix.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3a003ea. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/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.

5 participants