Skip to content
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

chore: bump @metamask/providers to ^17.2.0 #27049

Closed
wants to merge 25 commits into from
Closed

Conversation

jiexi
Copy link
Contributor

@jiexi jiexi commented Sep 10, 2024

Description

Open in GitHub Codespaces

Related issues

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

socket-security bot commented Sep 10, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/extension-port-stream@3.0.0 None 0 10.5 kB lgbot

🚮 Removed packages: npm/@metamask/providers@17.2.0, npm/detect-browser@5.2.0, npm/extension-port-stream@4.2.0, npm/json-rpc-middleware-stream@5.0.1

View full report↗︎

@jiexi
Copy link
Contributor Author

jiexi commented Sep 10, 2024

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@jiexi jiexi changed the title bump @metamask/providers to ^17.2.0 chore: bump @metamask/providers to ^17.2.0 Sep 10, 2024
},
additionalProperties: false,
required: ['syntax'],
},
],
},
experimental: {
description: 'TODO',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes probably should be moved into a separate PR

importAssertions: {
default: false,
type: 'boolean',
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY this importAssertions property somehow

@jiexi
Copy link
Contributor Author

jiexi commented Sep 11, 2024

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

Copy link

sonarcloud bot commented Sep 11, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [1c0282a]
Page Load Metrics (1683 ± 88 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30722951499508244
domContentLoaded14752256165817886
load14792288168318388
domInteractive21107392612
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -24 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: -64 Bytes (-0.00%)

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.06%. Comparing base (a61b938) to head (1c0282a).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #27049      +/-   ##
===========================================
- Coverage    70.11%   70.06%   -0.05%     
===========================================
  Files         1426     1410      -16     
  Lines        49689    49589     -100     
  Branches     13902    13861      -41     
===========================================
- Hits         34835    34740      -95     
+ Misses       14854    14849       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 226 to 230
importAssertions: true,
},
experimental: {
keepImportAttributes: true,
emitAssertForImportAttributes: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if all three or only some are needed, but definitely something needs to be set to deal with the import assertion

Copy link
Contributor Author

@jiexi jiexi Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are all false, I get the following from yarn webpack

ERROR in ../node_modules/@metamask/providers/dist/extension-provider/createExternalExtensionProvider.mjs
Module build failed (from ../development/webpack/utils/loaders/swcLoader.ts):
Error: 
  × Expected ';', got 'assert'
   ╭─[/Users/jiexi/Projects/metamask-extension/node_modules/@metamask/providers/dist/extension-provider/createExternalExtensionProvider.mjs:1:1]
 1 │ import { detect } from "detect-browser";
 2 │ import $extensionportstream from "extension-port-stream";
 3 │ const { PortDuplexStream: PortStream } = $extensionportstream;
 4 │ import config from "./external-extension-config.json" assert { type: "json" };
   ·                                                       ──────
 5 │ import { MetaMaskInpageProviderStreamName } from "../MetaMaskInpageProvider.mjs";
 6 │ import { StreamProvider } from "../StreamProvider.mjs";
 7 │ import { getDefaultExternalMiddleware } from "../utils.mjs";
   ╰────

@jiexi
Copy link
Contributor Author

jiexi commented Sep 11, 2024

// node_modules/@metamask/providers/dist/extension-provider/createExternalExtensionProvider.mjs
import { detect } from "detect-browser";
import $extensionportstream from "extension-port-stream";
const { PortDuplexStream: PortStream } = $extensionportstream;
import config from "./external-extension-config.json" assert { type: "json" };
import { MetaMaskInpageProviderStreamName } from "../MetaMaskInpageProvider.mjs";
import { StreamProvider } from "../StreamProvider.mjs";
import { getDefaultExternalMiddleware } from "../utils.mjs";
const browser = detect();
/**
 * Creates an external extension provider for the given extension type or ID.
 *
 * @param typeOrId - The extension type or ID.
 * @returns The external extension provider.
 */
export function createExternalExtensionProvider(typeOrId = 'stable') {
    let provider;
    try {
        const extensionId = getExtensionId(typeOrId);
        const metamaskPort = chrome.runtime.connect(extensionId);
        const pluginStream = new PortStream(metamaskPort);
        provider = new StreamProvider(pluginStream, {
            jsonRpcStreamName: MetaMaskInpageProviderStreamName,
            logger: console,
            rpcMiddleware: getDefaultExternalMiddleware(console),
        });
        // This is asynchronous but merely logs an error and does not throw upon
        // failure. Previously this just happened as a side-effect in the
        // constructor.
        // eslint-disable-next-line @typescript-eslint/no-floating-promises
        provider.initialize();
    }
    catch (error) {
        console.dir(`MetaMask connect error.`, error);
        throw error;
    }
    return provider;
}
/**
 * Gets the extension ID for the given extension type or ID.
 *
 * @param typeOrId - The extension type or ID.
 * @returns The extension ID.
 */
function getExtensionId(typeOrId) {
    const ids = browser?.name === 'firefox' ? config.firefoxIds : config.chromeIds;
    return ids[typeOrId] ?? typeOrId;
}
//# sourceMappingURL=createExternalExtensionProvider.mjs.map

Comment on lines +1 to +11
diff --git a/dist/extension-provider/createExternalExtensionProvider.mjs b/dist/extension-provider/createExternalExtensionProvider.mjs
index f2aa9285d84cd5e25c20f5202437c476cdacc326..121a9099e456d3444d8aae79574ba9c53e7f2699 100644
--- a/dist/extension-provider/createExternalExtensionProvider.mjs
+++ b/dist/extension-provider/createExternalExtensionProvider.mjs
@@ -1,5 +1,4 @@
-import $detectbrowser from "detect-browser";
-const { detect } = $detectbrowser;
+import { detect } from "detect-browser";
import $extensionportstream from "extension-port-stream";
const { PortDuplexStream: PortStream } = $extensionportstream;
import config from "./external-extension-config.json" assert { type: "json" };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this patch, I get the following from the inpage provider in the dapp web console

createExternalExtensionProvider.mjs:2 Uncaught TypeError: Cannot destructure property 'detect' of 'detect_browser__WEBPACK_IMPORTED_MODULE_0__.default' as it is undefined.
    at 193000 (createExternalExtensionProvider.mjs:2:9)
    at __webpack_require__ (bootstrap:19:1)
    at 701043 (createExternalExtensionProvider.mjs:49:61)
    at __webpack_require__ (bootstrap:19:1)
    at make namespace object:7:1
    at inpage.js:70:1
    at inpage.js:70:1

@@ -34,7 +34,7 @@ cleanContextForImports();
import log from 'loglevel';
import { v4 as uuid } from 'uuid';
import { WindowPostMessageStream } from '@metamask/post-message-stream';
import { initializeProvider } from '@metamask/providers/dist/initializeInpageProvider';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app/scripts/inpage.js Outdated Show resolved Hide resolved
package.json Outdated
"@trezor/connect-web@npm:^9.1.11": "patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch"
"@trezor/connect-web@npm:^9.1.11": "patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch",
"@metamask/providers@npm:^17.1.2": "patch:@metamask/providers@npm%3A17.2.0#~/.yarn/patches/@metamask-providers-npm-17.2.0-cb0cfcdadc.patch",
"@metamask/providers@npm:^15.0.0": "patch:@metamask/providers@npm%3A17.2.0#~/.yarn/patches/@metamask-providers-npm-17.2.0-cb0cfcdadc.patch"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to force usage expecting v15 to use v17 instead?

Copy link

socket-security bot commented Oct 24, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/extension-port-stream@3.0.0

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

@legobeat
Copy link
Contributor

@SocketSecurity ignore npm/extension-port-stream@3.0.0

github-merge-queue bot pushed a commit that referenced this pull request Oct 25, 2024
<!--
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**

- Bump `@babel/core` and `@babel/runtime` to latest
- Fix: replace previous usage of unpatched `@babel/runtime` with
consistent usage of patched version
- The unpatched version was inadvertently used by
`@metamask/smart-transactions-controller`

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28068?quickstart=1)

## **Related issues**

- #27049 
- #27923

## **Manual testing steps**


## **Screenshots/Recordings**

### **Before**

### **After**

## **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/develop/.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/develop/.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.
github-merge-queue bot pushed a commit that referenced this pull request Oct 25, 2024
…tream@^8 (#28060)

## **Description**

- Replace legacy `json-rpc-middleware-stream@^5` (2023-09-27) with
`@metamask/json-rpc-middleware-stream@^8` (2024-10-16)

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28060?quickstart=1)

## **Related issues**

- Fully removing usage of old version and aligning versions depends on
updating `@metamask/providers`, done in either/both of:
  - #27049
  - #27923 

## **Manual testing steps**

## **Screenshots/Recordings**

### **Before**

### **After**

## **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/develop/.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/develop/.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.
@jiexi
Copy link
Contributor Author

jiexi commented Oct 29, 2024

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@Gudahtt
Copy link
Member

Gudahtt commented Nov 27, 2024

Replaced by #28757

@Gudahtt Gudahtt closed this Nov 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants