-
-
Notifications
You must be signed in to change notification settings - Fork 255
feat(ramps): adds ramps controller with geolocation state #7316
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
base: main
Are you sure you want to change the base?
Conversation
mcmire
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.
Had some suggestions below. Also, we have a relatively new package called core-backend and I'm curious if this service belongs there now or not.
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.
@Kriys94 What are your thoughts on this service? Do you think this ought to go in the core-backend package?
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.
Hey @mcmire, thanks for the review. This controller will be used for ramps client state, so I believe it makes sense to keep it here. I can see why core-backend might seem like a good fit though, since the controller currently only contains geolocation state.
Eventually, I'd like to extract the geolocation functionality into core-backend, but for now, I've included it here because it's a simple piece of state that requires an API service. This makes for a good initial boilerplate PR that establishes the pattern before we add the ramps state.
What do you think?
Explanation
This PR introduces a new
@metamask/ramps-controllerpackage that will provide functionality for managing cryptocurrency on/off ramps within MetaMask.What's Included
RampsController
A controller that manages ramps-related state, currently focused on user geolocation:
updateGeolocation()method that fetches and persists the user's geolocationOnRampService
A service class that handles API communication with the OnRamp backend:
createServicePolicyfrom@metamask/controller-utilsfor resilient HTTP requests with:getGeolocation()method via messenger patternAPI Endpoints
https://on-ramp.api.cx.metamask.iohttps://on-ramp.uat-api.cx.metamask.iohttp://localhost:3000Architecture
The package follows the established controller/service patterns in the monorepo:
@metamask/base-controllerfor state management@metamask/messengerfor inter-controller communicationRampsControllerconsumes theOnRampServicevia messenger actionsFiles Added
RampsController.tsOnRampService.tsOnRampService-method-action-types.tsindex.tsRampsController.test.tsOnRampService.test.tsReferences
N/A - New package
Changelog
@metamask/ramps-controllerAdded
RampsControllerfor managing on/off ramps stateOnRampServicefor interacting with the OnRamp APIChecklist
References
Checklist
Note
Adds a new @metamask/ramps-controller package with RampsController and OnRampService (geolocation via API) and wires it into the monorepo.
@metamask/ramps-controllerRampsController: Manages ramps state; persistsgeolocation; exposesupdateGeolocation().OnRampService: API client with environments (production/staging/development), resilient policy (retries, circuit breaker, degradation); exposes messenger actionOnRampService:getGeolocation.README.md(package list and dependency graph),tsconfig*.jsonreferences,yarn.lockworkspace..github/CODEOWNERS,teams.json.Written by Cursor Bugbot for commit 264d64a. This will update automatically on new commits. Configure here.