feat: Install perps-controller v1, remove local mocked alias#40767
feat: Install perps-controller v1, remove local mocked alias#40767
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
|
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (1 files, +2 -0)
🕵️ @MetaMask/extension-privacy-reviewers (1 files, +1 -1)
👨🔧 @MetaMask/perps (21 files, +44 -44)
|
Builds ready [2278e59]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [f637c4f]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| test: /\.mjs$/u, | ||
| include: /node_modules[\\/]@myx-trade[\\/]sdk/u, | ||
| resolve: { | ||
| fullySpecified: false, |
There was a problem hiding this comment.
Going to need an explanation for this :-) I recently removed the last of the code that needed to allow for broken JS like this.
But I'm also concerned with @myx-trade/sdk itself.
It only has unknown authors on npm, and before this perps integration, has very few weekly downloads. It has zero documentation and no README.MD, and no links back to its repo on npm.
It ships @types/ws as a regular dependency, and ships invalid mjs as well (if fullySpecified is actually required). Quality, absent of a reputation, might be questionable.
Its about as sketchy as can be, especially with the initial attempt at landing this being over 12000 lines of of changes.
There was a problem hiding this comment.
I did some digging myself, and it looks like their SDK imports from crypto-js, which is not even maintained anymore (and hasn't been for a while).
If the @myx-trade/sdk is required here, which I'm sure it is, perhaps we should patch @myx-trade/sdk to do things The Right Way, instead of bail out of strict parsing via fullySpecified: false here.
I can submit the patch for it to this PR if you're okay with that.
If not, this isn't the right way to do this. This build system uses swc via our npmLoader, which is about 10x faster than webpack's default, so we'd need to figure out how to get this block into the "vendor javascript" oneOf section below, and likely use the npmLoader for it.
There was a problem hiding this comment.
Thanks @davidmurdoch , I have mentioned it to MYX directly for urgent fix. Their product hasnt launched hence the limited usage and download but we have a signed partnership with them to implement their protocol. I previously flagged the package with security but we allowed as we are partnering with them to unblock the implementation.
There was a problem hiding this comment.
Will follow up with the team tomorrow morning, and we will align on the best path forward 👍
It sounds like patching it is probably the way to go for now.
There was a problem hiding this comment.
MYX just shipped 0.1.267 which addresses this directly: crypto-js replaced with crypto-es (maintained ESM fork), @types/ws removed from runtime deps, and the MJS is now a single bundle with zero bare relative imports. Bumped the resolution and removed the fullySpecified: false workaround in this commit — should be clean now. Added a temporary npmPreapprovedPackages bypass (same pattern as serialize-javascript) to clear the 3-day age gate.
| test: /\.mjs$/u, | ||
| include: /node_modules[\\/]@myx-trade[\\/]sdk/u, | ||
| resolve: { | ||
| fullySpecified: false, |
There was a problem hiding this comment.
I did some digging myself, and it looks like their SDK imports from crypto-js, which is not even maintained anymore (and hasn't been for a while).
If the @myx-trade/sdk is required here, which I'm sure it is, perhaps we should patch @myx-trade/sdk to do things The Right Way, instead of bail out of strict parsing via fullySpecified: false here.
I can submit the patch for it to this PR if you're okay with that.
If not, this isn't the right way to do this. This build system uses swc via our npmLoader, which is about 10x faster than webpack's default, so we'd need to figure out how to get this block into the "vendor javascript" oneOf section below, and likely use the npmLoader for it.
…rkaround - Force resolution to @myx-trade/sdk@0.1.267 via package.json resolutions - Remove fullySpecified: false webpack rule (no longer needed — 0.1.267 ships a single bundled MJS with no bare relative imports) - Add @myx-trade/sdk to npmPreapprovedPackages to bypass 3-day age gate (temporary; remove once package is >3 days old) - 0.1.267 replaces crypto-js with crypto-es (maintained ESM fork) and removes @types/ws from runtime deps Addresses review feedback from @davidmurdoch on PR #40767
|
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| './**/node_modules/@nktkas', | ||
| './**/node_modules/@noble/hashes', | ||
| './**/node_modules/@noble/curves', | ||
| './**/node_modules/@scure', |
There was a problem hiding this comment.
Broad ESM globs affect existing crypto library builds
Medium Severity
The glob patterns ./**/node_modules/@noble/hashes, ./**/node_modules/@noble/curves, and ./**/node_modules/@scure match ALL versions of these packages at any nesting depth, not just the v2 versions brought in by @nktkas/hyperliquid (a transitive dependency of @metamask/perps-controller). These packages (@noble/hashes@1.8.0, @noble/curves@1.x, @scure/bip32, @scure/bip39) are already used extensively throughout MetaMask for core crypto operations and were not previously in this ESM transform list. Applying ESM handling to all versions project-wide could subtly change how the existing v1 packages are bundled by browserify. Narrower patterns scoped to the perps dependency subtree (e.g., targeting only the v2 paths) would be safer.
There was a problem hiding this comment.
This is fine. It may slow the build process down a bit though, however, it actually leads to more "technically correct" builds that properly target are supported browser range by "transpiling" modern JS features into polyfills. In an ideal world we would always do this (we do for webpack), but I believe (this was before my time) the reason we don't is that the build time performance hit was too much (and it hasn't been enough of an actual production problem enough us).
|
Builds ready [59ddb67]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| # Temporary bypass for serialize-javascript@7.0.3 CVE fix; remove once older than age gate. | ||
| - 'serialize-javascript' | ||
| # Temporary bypass for @myx-trade/sdk@0.1.267 — fixes ESM/crypto-js issues flagged in PR #40767; remove once >3 days old. | ||
| - '@myx-trade/sdk' |
There was a problem hiding this comment.
this is not a change request. just an FYI!
I was recently informed that if you add the package to this list locally, run yarn install, then commit the package.json and yarn.lock files, you can then remove the package from this list and things will work.





Description
Installs
perps-controllerv1 package as a dependency, removes aliased local mock. Update import paths as necessary to satisfy lint configuartions related to local vs imported modules.Broken out from feature branch for easier review: #40078
Changelog
CHANGELOG entry: Install perps-controller v1, remove local mocked alias
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds a new core dependency (
@metamask/perps-controller) plus multiple ESM/transpilation and Yarn resolution changes, which can impact build/test bundling behavior. Risk is mainly around module resolution/compatibility rather than runtime logic changes.Overview
This PR switches Perps UI integration from a locally-aliased mock
@metamask/perps-controllerto the real published@metamask/perps-controller@^1.0.0, updating TypeScript/Jest/webpack path mappings accordingly.To support the controller’s ESM-heavy dependency tree, it expands the build transpilation allowlist (e.g.,
valibot,@nktkas/*,@myx-trade/*,lodash-es,wretch) and adds Yarn pinning/age-gate exceptions (including a temporary preapproval for@myx-trade/sdk). It also introducesMM_PERPS_BLOCKED_REGIONSas a build-time env var for a perps geoblock fallback.Written by Cursor Bugbot for commit 59ddb67. This will update automatically on new commits. Configure here.