Commit 5f45182
chore: Bump network-controller to v27 (+ deps) (#37966)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
This PR bumps `@metamask/network-controller` to 27.0.0.
There are a few notable changes:
- JsonRpcEngine v2 is now being used internally by
`createWalletMiddleware`. In this PR we adjust to that and upgrade some
of the internal middleware to use it. One of the biggest changes is that
request objects cannot have arbitrary properties — that is now available
in _context_. You can read more about JsonRpcEngine v2 here:
https://github.com/MetaMask/core/blob/main/packages/json-rpc-engine/README.md#usage
- The provider type in `@metamask/eth-json-rpc-provider` changed and is
now called `InternalProvider` rather than `SafeEventEmitterProvider`.
- The connectivity/availability status of an RPC endpoint within
NetworkController state is now updated in a more live fashion, i.e., as
requests are made instead of being set when it becomes globally selected
or when `lookupNetwork` is manually called for the RPC endpoint. This
means that anything that is actively relying on network statuses will
have more up-to-date data to act on. In particular, this slightly
improves the banner shown when the user experiences issues connecting to
a network so that if a network becomes degraded or unavailable but then
recovers, the banner should disappear for that network more quickly.
Read the changelog for more:
https://github.com/MetaMask/core/blob/main/packages/network-controller/CHANGELOG.md
[](https://codespaces.new/MetaMask/metamask-extension/pull/37966?quickstart=1)
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Improve responsiveness of network connection banner to
connection issues
## **Related issues**
https://consensyssoftware.atlassian.net/browse/WPC-99
## **Manual testing steps**
1. Check out this branch, run `yarn`, run `yarn start`.
2. Load MetaMask, go through onboarding if necessary.
3. Start Ganache.
4. Add a Localhost network to MetaMask, and switch to it.
5. On the home screen, stop Ganache.
6. After about 10-20 seconds, you should see a "Still connecting" banner
appear.
7. Switch to Ethereum Mainnet.
8. After about a second, the banner should go away.
9. Switch back to Localhost.
10. Wait for the banner to appear.
11. Start Ganache.
12. After about 10-20 seconds, the banner should go away.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
In this video, we have Ganache running and the Localhost network added.
We stop Ganache, but a connection banner does not appear, and we have to
switch to another screen and back to get it to do so. Then we start
Ganache again, and the banner does not disappear — again, we have to
switch away and the back to get it to do so.
https://github.com/user-attachments/assets/cee15501-b824-46dc-97bb-eb77c31dbd2e
### **After**
In this video, we have Ganache running and the Localhost network added.
We stop Ganache, and a connection banner appears after 10-20 seconds. We
start Ganache again, and the banner disappears after 10-20 seconds.
https://github.com/user-attachments/assets/5532d9bb-6f37-4c08-a915-b76f352539df
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Upgrades network-controller and related deps, migrates MetaMask
middleware and pending/signature/tx flows to JsonRpcEngine v2 with
InternalProvider, and updates tests/policies accordingly.
>
> - **Middleware/Core (JsonRpcEngine v2 migration)**:
> - Rewrite `app/scripts/lib/createMetamaskMiddleware` in TypeScript
using `JsonRpcEngineV2`, returning `asLegacyMiddleware`.
> - Add v2 middlewares `createPendingNonceMiddleware` and
`createPendingTxMiddleware` in `app/scripts/lib/middleware/pending.ts`
with new TS tests; remove JS versions.
> - Update signature utils to use v2 `JsonRpcRequest` and
`MiddlewareContext` (`app/scripts/lib/signature/util.ts`) and adjust
tests.
> - Update transaction utils to accept `JsonRpcRequest` and
`MiddlewareContext`; plumb `requestContext` through
`metamask-controller` and `addDappTransaction`.
> - **Provider type changes**:
> - Replace `SafeEventEmitterProvider` with `InternalProvider` across
code/tests (e.g., swaps tests, test provider stub, bridge page tests).
> - **Controller/init adjustments**:
> - Remove legacy type-mismatch suppressions; minor messenger/registry
access tweaks where needed.
> - **UI/Bridge**:
> - Use `global.ethereumProvider` directly with new provider type.
> - **Policies/Configs/Tests**:
> - Update LavaMoat policies for new package paths and provider engine.
> - E2E metrics/state snapshots and helpers updated to handle
`networksMetadata` shape and ordering.
> - CODEOWNERS updated for TS middleware path.
> - **Dependencies**:
> - Bump `@metamask/network-controller` to `^27.0.0`,
`@metamask/eth-json-rpc-middleware` to `^22`,
`@metamask/eth-json-rpc-provider` to `^6`, `@metamask/json-rpc-engine`
to `^10.2.0`, and `@metamask/controller-utils` to `^11.16.0`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6e56977. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Erik Marks <[email protected]>
Co-authored-by: MetaMask Bot <[email protected]>
Co-authored-by: Salah-Eddine Saakoun <[email protected]>1 parent d1d78ac commit 5f45182
File tree
41 files changed
+511
-1084
lines changed- .github
- app/scripts
- controller-init
- assets
- confirmations
- controllers/swaps
- lib
- middleware
- signature
- transaction
- lavamoat
- browserify
- beta
- experimental
- flask
- main
- webpack
- mv2
- mv3
- test
- e2e/tests
- metrics
- state-snapshots
- settings
- stub
- ui
- ducks/bridge
- pages/bridge/prepare
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
41 files changed
+511
-1084
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
0 commit comments