Repository navigation
Enforce chainId - #324
Merged
Merged
Enforce chainId#324
Conversation
This reverts commit 20b0adb.
rekmarks
suggested changes
Jan 15, 2021
rekmarks
left a comment
Contributor
There was a problem hiding this comment.
Overall looks good! Just a few questions and requests.
Comment on lines
+15
to
+21
| mainnet = '1', | ||
| kovan = '42', | ||
| rinkeby = '4', | ||
| goerli = '5', | ||
| ropsten = '3', | ||
| localhost = '', | ||
| rpc = '', |
Contributor
There was a problem hiding this comment.
Could we store these in hexadecimal instead?
Possibly related: #326
Contributor
Author
There was a problem hiding this comment.
oh wait, this would need a migration as well
Contributor
Author
There was a problem hiding this comment.
for transactions, I'd put that together with the work on the tx controller
Contributor
There was a problem hiding this comment.
We decided to do this in a follow-up.
3 tasks done
Mrtenz
pushed a commit
that referenced
this pull request
Oct 16, 2025
amitabh94
pushed a commit
to amitabh94/core
that referenced
this pull request
Jun 16, 2026
Naz-Ovh
pushed a commit
to 0x-fork/metamask-core
that referenced
this pull request
Sep 13, 2026
Replaces MetaMask#324, which GitHub auto-closed as merged during a stack reorder when its head briefly became an ancestor of its base. The changes never reached `main`; this carries the same two commits. Mirrors [MetaMask#9976](MetaMask#9976), the bottom of core's foundational stack. | | Before | After | | --- | --- | --- | | `engines.node` | `^18.18 \|\| ^20.14 \|\| >=22` | `^22.14.0 \|\| ^24` | | `@types/node` | `~18.18.14` | `^22.13.14` | | CI matrix | 18, 20, 22 | 22, 24 | `constraints.pro` is updated so `yarn constraints` enforces the new range. Core makes the `@types/node` bump in this same PR rather than with its TypeScript change, since the types track the supported runtime. ## Position in the stack This now sits **below** the ESM conversion (MetaMask#323), so everything up to and including this PR is still a hybrid CJS/ESM build: ``` main → … → MetaMask#322 → this → MetaMask#323 (ESM only) → MetaMask#325 (TypeScript) ``` That matters for testing. A preview build from here still resolves through `main: ./dist/index.cjs` with the `require` condition intact, so it can be consumed by `metamask-extension` as-is. Everything below the ESM cut can therefore be verified against a real downstream consumer before the breaking change lands. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Semver-breaking runtime requirement may block consumers still on Node 18 or 20; in-repo changes are mostly policy, CI, and test cleanup with limited logic impact. > > **Overview** > **Breaking:** supported Node is now `^22.14.0 || ^24` instead of 18/20/22. That is enforced in `package.json`, `constraints.pro`, and documented under Unreleased in `CHANGELOG.md`. > > CI **prepare**, **test**, and **compatibility-test** jobs now run on Node **22.x** and **24.x** only (18 and 20 dropped from the matrix). Dev typings move from `@types/node` ~18 to **^22.13.14**, with matching `yarn.lock` updates. > > Test and lint tooling align with the new floor: ESLint comments for `n/no-unsupported-features/node-builtins` reflect that global `crypto` is expected on 22+, and `hashing.test.ts` drops the Node 18 `webcrypto` polyfill/`beforeEach` setup—tests assume `globalThis.crypto.subtle` exists. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ba81eca2d4fa1d9a00faa1bd7e975d1b5d02fc8d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Naz-Ovh
pushed a commit
to 0x-fork/metamask-core
that referenced
this pull request
Sep 13, 2026
Top of stack MetaMask#315, on MetaMask#324. Mirrors [MetaMask#9518](MetaMask#9518). | | Before | After | | --- | --- | --- | | `packageManager` | `yarn@4.16.0` | `yarn@4.17.1` | | `typescript` | `~5.3.3` | `npm:@typescript/typescript6@^6.0.2` | | `@typescript/native` | — | `npm:typescript@^7.0.2` | ## Why not just bump to TypeScript 7 I tried that first. It fails for two independent reasons: **1. Yarn.** 4.16.0 auto-applies a builtin `compat/typescript` patch targeting `lib/_tsc.js`. That file doesn't exist in TS 7, which is the native port with a different layout, so the install fails outright: ``` typescript@patch:typescript@npm%3A7.0.2#optional!builtin<compat/typescript> ENOENT: no such file or directory, lstat '.../typescript/lib/_tsc.js' ``` Yarn 4.17.1 resolves it, which is why core bumps the package manager in the same PR. **2. typescript-eslint.** With the install fixed, linting then hard-errors: ``` typescript-eslint does not support TS 7.0. Please see ... to run typescript-eslint using the TS 6 API. ``` Tracked upstream at [typescript-eslint#10940](typescript-eslint/typescript-eslint#10940). So the aliases aren't incidental overhead. Resolving `typescript` to the **TS 6 API** is what keeps `typescript-eslint`, `ts-jest` and `typedoc` working, while TS 7 sits alongside as `@typescript/native`. Compilation runs on 6.0.3; nothing in the toolchain can consume 7 yet. Same position core is in. ## Source changes Two, both from `Uint8Array` becoming generic: - **`hashing.ts`** — `crypto.subtle.digest` takes a `BufferSource`, which no longer accepts a plain `Uint8Array` because the buffer could be a `SharedArrayBuffer`. Asserted at the three call sites rather than narrowing the exported signatures, which would break callers. - **`errors.ts`** — `no-base-to-string` now sees that `String(error)` can produce `[object Object]`. That is the documented fallback of `getErrorMessage`, so it's suppressed with a reason. ## Not carried over Core's third entry, `@typescript/old`, is a patched 6.0.3 pointing at a patch file in core's own `.yarn/patches`. Nothing here needs it and its contents aren't reproducible from outside that repo. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Toolchain-wide TypeScript/Yarn changes can surface build or lint regressions; hashing changes touch crypto paths but preserve digest output via the noble fallback. > > **Overview** > Aligns the repo with MetaMask core’s **TypeScript 6 + native TS 7** setup: **`typescript`** resolves to **`@typescript/typescript6@^6.0.2`** (so **typescript-eslint**, **ts-jest**, and **typedoc** keep working), adds **`@typescript/native`** (TS 7) alongside, bumps **Yarn** to **4.17.1**, and refreshes the lockfile. > > **Jest/ts-jest** gets **`ignoreDeprecations: '6.0'`** so test compilation can keep **`moduleResolution: 'Node'`** under TS 6 without noise. > > Two small **source** fixes for stricter TS 6 types: **`hashing.ts`** only calls **`crypto.subtle.digest`** when input bytes are backed by an **`ArrayBuffer`** (otherwise **noble**), avoiding runtime errors on **`SharedArrayBuffer`** views while keeping public APIs unchanged. **`getErrorMessage`** adds a targeted **`no-base-to-string`** suppression for the intentional **`String(error)`** fallback. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit aac3fa43658ca1e6db082bd80fb06d132caf6fc6. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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.
This PR makes sure that all custom rpc networks have a valid chainId, and disregard the usage of networkId in favor of chainId