feat(wallet)!: Add NetworkController initialization#9001
Merged
Conversation
9ea9017 to
63e8c0e
Compare
Member
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
63e8c0e to
3bb0a08
Compare
Member
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
3bb0a08 to
45710f4
Compare
Member
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
45710f4 to
771074f
Compare
Member
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
771074f to
07a7eec
Compare
sirtimid
added a commit
that referenced
this pull request
Jun 23, 2026
Add `createWallet`, which constructs a `@metamask/wallet` `Wallet` backed by the SQLite `KeyValueStore`, hydrates it from persisted state, imports the secret recovery phrase on first run, and returns a resilient `dispose` teardown handle (unsubscribe → wallet.destroy → store.close). Add the daemon process entry point (`daemon-entry.ts`) that wires `createWallet` into the JSON-RPC socket server with PID-slot claiming and graceful shutdown. Adapted from Erik Marks's #8446 modules with these deviations: - Use the current `@metamask/wallet` `instanceOptions` API, populating the now-required `storageService` (in-memory adapter), `connectivityController` (`AlwaysOnlineAdapter`), and `remoteFeatureFlagController` slots. Drop the old flat `Wallet({...})` options. - Drop `infuraProjectId` from the `Wallet` call (NetworkController is not yet wired on `main`); keep the env guard with a TODO(#9001). - Return `{ wallet, dispose }` instead of `{ wallet, store }`. - Construct a short-lived metadata probe so `loadState` can filter persisted rows against the live controller metadata. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid
added a commit
that referenced
this pull request
Jun 23, 2026
Add `createWallet`, which constructs a `@metamask/wallet` `Wallet` backed by the SQLite `KeyValueStore`, hydrates it from persisted state, imports the secret recovery phrase on first run, and returns a resilient `dispose` teardown handle (unsubscribe → wallet.destroy → store.close). Add the daemon process entry point (`daemon-entry.ts`) that wires `createWallet` into the JSON-RPC socket server with PID-slot claiming and graceful shutdown. Adapted from Erik Marks's #8446 modules with these deviations: - Use the current `@metamask/wallet` `instanceOptions` API, populating the now-required `storageService` (in-memory adapter), `connectivityController` (`AlwaysOnlineAdapter`), and `remoteFeatureFlagController` slots. Drop the old flat `Wallet({...})` options. - Drop `infuraProjectId` from the `Wallet` call (NetworkController is not yet wired on `main`); keep the env guard with a TODO(#9001). - Return `{ wallet, dispose }` instead of `{ wallet, store }`. - Construct a short-lived metadata probe so `loadState` can filter persisted rows against the live controller metadata. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid
added a commit
that referenced
this pull request
Jun 23, 2026
Add `createWallet`, which constructs a `@metamask/wallet` `Wallet` backed by the SQLite `KeyValueStore`, hydrates it from persisted state, imports the secret recovery phrase on first run, and returns a resilient `dispose` teardown handle (unsubscribe → wallet.destroy → store.close). Add the daemon process entry point (`daemon-entry.ts`) that wires `createWallet` into the JSON-RPC socket server with PID-slot claiming and graceful shutdown. Adapted from Erik Marks's #8446 modules with these deviations: - Use the current `@metamask/wallet` `instanceOptions` API, populating the now-required `storageService` (in-memory adapter), `connectivityController` (`AlwaysOnlineAdapter`), and `remoteFeatureFlagController` slots. Drop the old flat `Wallet({...})` options. - Drop `infuraProjectId` from the `Wallet` call (NetworkController is not yet wired on `main`); keep the env guard with a TODO(#9001). - Return `{ wallet, dispose }` instead of `{ wallet, store }`. - Construct a short-lived metadata probe so `loadState` can filter persisted rows against the live controller metadata. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
NetworkController initializationNetworkController initialization
Member
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
ed00476 to
d608d40
Compare
d608d40 to
9b4a53b
Compare
Mrtenz
reviewed
Jun 24, 2026
| (instance): instance is Extract<typeof instance, { init: unknown }> => | ||
| // We do actually want to check the prototype here. | ||
| // eslint-disable-next-line no-restricted-syntax | ||
| 'init' in instance, |
Member
There was a problem hiding this comment.
Should we check that init is a function just in case?
Mrtenz
approved these changes
Jun 24, 2026
sirtimid
added a commit
that referenced
this pull request
Jun 25, 2026
Add `createWallet`, which constructs a `@metamask/wallet` `Wallet` backed by the SQLite `KeyValueStore`, hydrates it from persisted state, imports the secret recovery phrase on first run, and returns a resilient `dispose` teardown handle (unsubscribe → wallet.destroy → store.close). Add the daemon process entry point (`daemon-entry.ts`) that wires `createWallet` into the JSON-RPC socket server with PID-slot claiming and graceful shutdown. Adapted from Erik Marks's #8446 modules with these deviations: - Use the current `@metamask/wallet` `instanceOptions` API, populating the now-required `storageService` (in-memory adapter), `connectivityController` (`AlwaysOnlineAdapter`), and `remoteFeatureFlagController` slots. Drop the old flat `Wallet({...})` options. - Drop `infuraProjectId` from the `Wallet` call (NetworkController is not yet wired on `main`); keep the env guard with a TODO(#9001). - Return `{ wallet, dispose }` instead of `{ wallet, store }`. - Construct a short-lived metadata probe so `loadState` can filter persisted rows against the live controller metadata. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid
added a commit
that referenced
this pull request
Jun 25, 2026
…let factory `@metamask/wallet` 5.0.0 (#9001) makes `instanceOptions.networkController.infuraProjectId` a required option. Thread the daemon's already-validated `INFURA_PROJECT_ID` through `createWallet` and `buildInstanceOptions` (and the metadata probe) into the new `networkController` slot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid
added a commit
that referenced
this pull request
Jun 25, 2026
`@metamask/wallet` 5.0.0 (#9001) added `Wallet.init()`, which runs each instance's `init()` — notably `NetworkController.init()`, which applies the selected network so a provider proxy is available. Without it the daemon would serve RPC against a wallet that has no usable provider. Call `wallet.init()` after subscribing persistence (so init-driven state changes are written through) and before first-run SRP import. `init()` settles every step independently, so surface any rejected step via the logger rather than letting it pass silently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sirtimid
added a commit
that referenced
this pull request
Jun 25, 2026
#9001 (NetworkController) landed and wired on main, making `infuraProjectId` a required field of `CreateWalletConfig` and adding `wallet.init()` to the factory's startup path. Pass a dummy project ID so the e2e type-checks against the merged factory, and note in the comment that `init()` (NetworkController) is offline-safe too — it is synchronous and never calls `lookupNetwork`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 task
sirtimid
added a commit
that referenced
this pull request
Jun 29, 2026
#9001 (NetworkController) landed and wired on main, making `infuraProjectId` a required field of `CreateWalletConfig` and adding `wallet.init()` to the factory's startup path. Pass a dummy project ID so the e2e type-checks against the merged factory, and note in the comment that `init()` (NetworkController) is offline-safe too — it is synchronous and never calls `lookupNetwork`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
This PR adds
NetworkControllerinitialization to@metamask/walletalongside aninitfunction onWalletthan can be used to initialize controller and services after instantiation (e.g. if the controller/service needs to use the messenger to seed its initial state).instanceOptions.networkController.infuraProjectIdis now required.References
https://consensyssoftware.atlassian.net/browse/WPC-1023
Checklist
Note
High Risk
Breaking API change for all wallet consumers plus core network/RPC configuration (Infura project ID), which affects how chains and providers are initialized.
Overview
Breaking:
@metamask/walletnow boots a defaultNetworkControllerand requiresinstanceOptions.networkController.infuraProjectId(optionalfailoverUrls). The new initialization module wires the controller messenger toConnectivityControllerandRemoteFeatureFlagControllerstate/actions.Adds
Wallet.init(), which runsinit()on every registered instance that exposes it (viaPromise.allSettled) so controllers can finish setup after construction—for example seeding state through the messenger.Tests and docs/changelog/README dependency graph are updated for the new required options and dependency on
@metamask/network-controller.Reviewed by Cursor Bugbot for commit f882afd. Bugbot is set up for automated code reviews on this repo. Configure here.