-
-
Notifications
You must be signed in to change notification settings - Fork 266
feat: update RampsController with selectedProvider and selectedToken #7734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@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. |
| state.selectedToken = token; | ||
| }); | ||
|
|
||
| this.triggerGetPaymentMethods(regionCode, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can use the following instead of writing wrapper functions to trigger it ?
| this.triggerGetPaymentMethods(regionCode, { | |
| this.getPaymentMethods(regionCode, { | |
| provider: provider.id, | |
| }).catch(() => { | |
| // ignore errors | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I will follow up with a refactor for all of the trigger methods.
There was a problem hiding this 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 1 potential issue.
amitabh94
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Explanation
This PR refactors the RampsController to improve naming consistency and add token selection support.
Breaking Changes
preferredProvidertoselectedProvider: Aligns naming with the newselectedTokenstate for consistency across selected entitiesgetPaymentMethodssignature: Changed fromgetPaymentMethods(options)togetPaymentMethods(region, options)to match the pattern used bygetTokensandgetProvidersNew Features
selectedTokenstate: Stores the user's selected token withsetSelectedToken()method. When a token is selected, payment methods are automatically fetched for that tokenRampsEnvironment.Local: New environment option for RampsService that points tolocalhost:3000for local developmentReferences
Mobile PR that adopts breaking changes: MetaMask/metamask-mobile#25296
Jira Ticket: https://consensyssoftware.atlassian.net/browse/TRAM-3232
Checklist
Note
Medium Risk
Medium risk due to breaking API changes (
preferredProvider→selectedProvider,getPaymentMethodssignature change) and new selection-driven side effects that auto-fetch/reset payment methods, which could affect client integrations and UI state transitions.Overview
Adds
selectedProviderandselectedTokentoRampsControllerwith newsetSelectedProvider(id)/setSelectedToken(assetId)APIs; changing either now clears payment methods/selection and triggers a freshgetPaymentMethodsfetch.Introduces breaking changes: renames
preferredProvider→selectedProvider(and setter), changesgetPaymentMethods/triggerGetPaymentMethodstogetPaymentMethods(region, options), and updatessetSelectedPaymentMethodto accept a payment-method ID (with validation).Updates payment-methods behavior to default
assetId/providerfrom controller state, auto-select the first returned payment method when the previous selection is invalid, and guard against stale updates when token/provider changes mid-request.Enhances
RampsServicewithRampsEnvironment.Local, optionalbaseUrlOverride, provider support metadata fields, and switches payment-methods API calls toGET /v2/regions/{region}/paymentsusingcryptoquery param (plus test updates).Written by Cursor Bugbot for commit 904405b. This will update automatically on new commits. Configure here.