Repository navigation
feat(wallet)!: wire GeolocationController into default initialization - #11058
Merged
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in initialization, messenger wiring, or migration guidance; tests were inspected but not executed.
No open issues 🎉
What changed in this PR
Adds wallet-owned geolocation initialization so Analytics and Subscription controllers no longer depend on hosts registering geolocation separately, addressing the initialization race.
Changes:
- Registers
GeolocationControllerandGeolocationApiServiceby default, with messenger delegation and optional service settings. - Adds tests for registration, initialization, environment selection, and geolocation requests.
- Updates dependencies, TypeScript references, and breaking-change guidance requiring hosts to remove duplicate registrations.
| File | Description |
|---|---|
yarn.lock |
Records the wallet’s geolocation dependency. |
packages/wallet/tsconfig.lint.json |
Adds the geolocation lint project reference. |
packages/wallet/tsconfig.json |
Adds the geolocation development project reference. |
packages/wallet/tsconfig.build.json |
Adds the geolocation build project reference. |
packages/wallet/src/types.ts |
Exposes optional geolocation service settings. |
packages/wallet/src/initialization/instances/index.ts |
Exports both default geolocation configurations. |
packages/wallet/src/initialization/instances/geolocation-controller/geolocation-controller.ts |
Initializes the controller and delegates API access. |
packages/wallet/src/initialization/instances/geolocation-controller/geolocation-controller.test.ts |
Tests registration, state, delegation, and service integration. |
packages/wallet/src/initialization/instances/geolocation-api-service/types.ts |
Defines optional environment, fetch, cache, and policy settings. |
packages/wallet/src/initialization/instances/geolocation-api-service/geolocation-api-service.ts |
Initializes the service with configurable options. |
packages/wallet/src/initialization/instances/geolocation-api-service/geolocation-api-service.test.ts |
Tests registration, construction, and environment selection. |
packages/wallet/src/initialization/instances/analytics-controller/types.ts |
Updates documentation to describe wallet-owned geolocation. |
packages/wallet/package.json |
Declares the geolocation package dependency. |
packages/wallet/CHANGELOG.md |
Documents default initialization and migration requirements. |
Review effort: Balanced
gauthierpetetin
marked this pull request as ready for review
October 26, 2026 05:37
gauthierpetetin
temporarily deployed
to
default-branch
October 26, 2026 05:37 — with
GitHub Actions
Inactive
4 tasks done
gauthierpetetin
enabled auto-merge
October 26, 2026 05:39
FrederikBolding
approved these changes
Oct 26, 2026
Merged
1 of 4 tasks
gaohan1994
pushed a commit
to gaohan1994/core
that referenced
this pull request
Oct 27, 2026
## Explanation Major release of `@metamask/wallet` (`19.1.0` → `20.0.0`). - **Breaking:** Add `GeolocationController` and `GeolocationApiService` to the default initialization configurations. Optional `instanceOptions.geolocationApiService` accepts `env`, `fetch`, `ttlMs`, and `policyOptions` (defaults to production and `globalThis.fetch`). Hosts that already register these on the wallet root messenger must remove them before upgrading, or messenger registration will collide. Hosts no longer need to register `GeolocationController` when `AnalyticsController` `isGeolocationEnabled` is `true`. ([MetaMask#11058](MetaMask#11058)) - Add `@metamask/geolocation-controller` as a dependency. ([MetaMask#11058](MetaMask#11058)) Minor release of `@metamask/analytics-controller` (`4.0.0` → `4.1.0`). - Add support for Node.js 26. ([MetaMask#10981](MetaMask#10981)) - Accept partial initial `state` as long as `analyticsId` is provided. ([MetaMask#10901](MetaMask#10901)) - Bump `@metamask/base-controller` from `^10.0.0` to `^10.1.0`. ([MetaMask#10864](MetaMask#10864)) Dependent packages (`@metamask/marketing-consent-controller`, `@metamask/network-controller`, `@metamask/notification-services-controller`, `@metamask/seedless-onboarding-controller`, `@metamask/wallet`) now depend on `@metamask/analytics-controller` `^4.1.0`. ## References - [MetaMask#11058](MetaMask#11058) - [MetaMask#10981](MetaMask#10981) - [MetaMask#10901](MetaMask#10901) - [MetaMask#10864](MetaMask#10864) ## 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 Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **High Risk** > Wallet 20.0.0 carries a documented breaking change to default controller registration (geolocation), so consumers upgrading from this release can hit messenger collisions or required migration steps even though this PR only versions and documents prior work. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 16059ef. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
AnalyticsControllerandSubscriptionControlleralready callGeolocationController:getGeolocationDatathrough the wallet root messenger, but hosts still had to construct and registerGeolocationController(andGeolocationApiService) themselves. That left a race when hosts calledwallet.init()before registering geolocation on a later init path.This PR adds
GeolocationControllerandGeolocationApiServiceto the default@metamask/walletinitialization configurations, matching other migrated controllers. OptionalinstanceOptions.geolocationApiServiceacceptsenv,fetch,ttlMs, andpolicyOptions(defaults to production andglobalThis.fetch).GeolocationControllerdelegatesGeolocationApiService:fetchGeolocationData. Hosts that enable Analytics geolocation enrichment no longer need to registerGeolocationControllerthemselves.References
Checklist
GeolocationControllerorGeolocationApiServiceon the wallet root messenger must remove them before upgrading, or messenger registration will collide.Note
Medium Risk
Breaking messenger registration change for existing hosts; default init also enables outbound geolocation API fetches when those code paths run.
Overview
Breaking:
@metamask/walletnow constructsGeolocationControllerandGeolocationApiServiceas part of default initialization, so analytics/subscription flows can callGeolocationController:getGeolocationDatawithout hosts wiring geolocation first.Hosts may tune the API client via optional
instanceOptions.geolocationApiService(env,fetch,ttlMs,policyOptions; defaults are production +globalThis.fetch). The controller’s messenger delegatesGeolocationApiService:fetchGeolocationData. Documentation foranalyticsController.isGeolocationEnablednow states wallet supplies geolocation instead of requiring host registration.Upgrade note: remove any existing
GeolocationController/GeolocationApiServiceregistrations on the wallet root messenger before upgrading, or initialization will collide.Reviewed by Cursor Bugbot for commit 852175b. Bugbot is set up for automated code reviews on this repo. Configure here.