Skip to content

Commit 90d8d4a

Browse files
committed
feat: bump @metamask/providers to ^21.0.0 (#31056)
<!-- 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. --> Bumps the `@metamask/providers` package to `^21.0.0` and adopts necessary changes to usage [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/31056?quickstart=1) See: MetaMask/providers#410 No user facing changes. Visit any dapp and use it as before. <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> <!-- [screenshots/recordings] --> <!-- [screenshots/recordings] --> - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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. - [ ] 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.
1 parent 4d2bd16 commit 90d8d4a

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

app/scripts/inpage.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import log from 'loglevel';
3535
import { v4 as uuid } from 'uuid';
3636
import { WindowPostMessageStream } from '@metamask/post-message-stream';
3737
import { initializeProvider } from '@metamask/providers/initializeInpageProvider';
38+
import ObjectMultiplex from '@metamask/object-multiplex';
39+
import { pipeline } from 'readable-stream';
3840

3941
// this is currently equivalent to process.env.MULTICHAIN_API
4042
// which can't be used for conditional imports
@@ -47,6 +49,7 @@ import { registerSolanaWalletStandard } from '@metamask/solana-wallet-standard';
4749
///: END:ONLY_INCLUDE_IF
4850

4951
import shouldInjectProvider from '../../shared/modules/provider-injection';
52+
import { METAMASK_EIP_1193_PROVIDER } from './constants/stream';
5053

5154
// contexts
5255
const CONTENT_SCRIPT = 'metamask-contentscript';
@@ -67,8 +70,17 @@ if (shouldInjectProvider()) {
6770
target: CONTENT_SCRIPT,
6871
});
6972

73+
const mux = new ObjectMultiplex();
74+
pipeline(metamaskStream, mux, metamaskStream, (error) => {
75+
let warningMsg = `Lost connection to "${METAMASK_EIP_1193_PROVIDER}".`;
76+
if (error?.stack) {
77+
warningMsg += `\n${error.stack}`;
78+
}
79+
console.warn(warningMsg);
80+
});
81+
7082
initializeProvider({
71-
connectionStream: metamaskStream,
83+
connectionStream: mux.createStream(METAMASK_EIP_1193_PROVIDER),
7284
logger: log,
7385
shouldShimWeb3: true,
7486
providerInfo: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
"@metamask/ppom-validator": "0.36.0",
311311
"@metamask/preinstalled-example-snap": "^0.3.0",
312312
"@metamask/profile-sync-controller": "^11.0.1",
313-
"@metamask/providers": "^20.0.0",
313+
"@metamask/providers": "^21.0.0",
314314
"@metamask/queued-request-controller": "^7.0.1",
315315
"@metamask/rate-limit-controller": "^6.0.3",
316316
"@metamask/remote-feature-flag-controller": "^1.6.0",

yarn.lock

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6205,27 +6205,6 @@ __metadata:
62056205
languageName: node
62066206
linkType: hard
62076207

6208-
"@metamask/providers@npm:^20.0.0":
6209-
version: 20.0.0
6210-
resolution: "@metamask/providers@npm:20.0.0"
6211-
dependencies:
6212-
"@metamask/json-rpc-engine": "npm:^10.0.2"
6213-
"@metamask/json-rpc-middleware-stream": "npm:^8.0.6"
6214-
"@metamask/object-multiplex": "npm:^2.0.0"
6215-
"@metamask/rpc-errors": "npm:^7.0.2"
6216-
"@metamask/safe-event-emitter": "npm:^3.1.1"
6217-
"@metamask/utils": "npm:^11.0.1"
6218-
detect-browser: "npm:^5.2.0"
6219-
extension-port-stream: "npm:^4.1.0"
6220-
fast-deep-equal: "npm:^3.1.3"
6221-
is-stream: "npm:^2.0.0"
6222-
readable-stream: "npm:^3.6.2"
6223-
peerDependencies:
6224-
webextension-polyfill: ^0.10.0 || ^0.11.0 || ^0.12.0
6225-
checksum: 10/b958d03a9380d86e605db239109a3debcc1ffde90371abe5beb82a5bed46c7718303a2bb92ec269eae16eff145b9ebbfcb3445a2b6bad4f297a590ee725a5bad
6226-
languageName: node
6227-
linkType: hard
6228-
62296208
"@metamask/providers@npm:^21.0.0":
62306209
version: 21.0.0
62316210
resolution: "@metamask/providers@npm:21.0.0"
@@ -27432,7 +27411,7 @@ __metadata:
2743227411
"@metamask/preferences-controller": "npm:^17.0.0"
2743327412
"@metamask/preinstalled-example-snap": "npm:^0.3.0"
2743427413
"@metamask/profile-sync-controller": "npm:^11.0.1"
27435-
"@metamask/providers": "npm:^20.0.0"
27414+
"@metamask/providers": "npm:^21.0.0"
2743627415
"@metamask/queued-request-controller": "npm:^7.0.1"
2743727416
"@metamask/rate-limit-controller": "npm:^6.0.3"
2743827417
"@metamask/remote-feature-flag-controller": "npm:^1.6.0"

0 commit comments

Comments
 (0)