Skip to content

Conversation

@rekmarks
Copy link
Member

@rekmarks rekmarks commented Oct 7, 2025

Explanation

As of #6328 SafeEventEmitterProvider no longer used the EventEmitter API, making its name misleading. Consequently, this PR renames it to InternalProvider and stops extending SafeEventEmitter. This new name better reflects its use as an internal-only provider that does not conform to any particular standard.

SafeEventEmitterProvider is still exported as a deprecated alias of InternalProvider in order to circumvent build failures due to repo-external packages that use this alias. Once we have updated external packages to use InternalProvider instead, the old alias can be removed.

References

Closes #6594

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Renames and replaces SafeEventEmitterProvider with InternalProvider across packages, updates proxies and types, adds a deprecated alias, and adjusts tests/changelogs accordingly.

  • Provider (eth-json-rpc-provider):
    • Add InternalProvider (no longer extends SafeEventEmitter); update providerFromEngine/providerFromMiddleware to return it.
    • Export SafeEventEmitterProvider as a deprecated alias; update tests/exports; drop @metamask/safe-event-emitter dep.
  • Middleware (eth-json-rpc-middleware):
    • Change provider types to InternalProvider in block-ref, retryOnEmpty, and providerAsMiddleware.
  • Block Tracker (eth-block-tracker):
    • Expect InternalProvider in PollingBlockTracker and tests; update CHANGELOG (BREAKING).
  • Network Controller:
    • Switch provider type to InternalProvider across types/clients.
    • Use createSwappableProxy for provider proxies; keep createEventEmitterProxy for block tracker; adjust handlers/comments and tests.
  • Selected Network Controller:
    • Use createSwappableProxy for provider proxy; align with InternalProvider; update tests.
  • Tests/Utilities:
    • Update FakeProvider/FakeBlockTracker and various tests to InternalProvider.
  • Changelogs:
    • Note BREAKING change across affected packages.
  • Misc:
    • Update ESLint thresholds and snapshots; lockfile changes reflect dependency removal.

Written by Cursor Bugbot for commit e1faf35. This will update automatically on new commits. Configure here.

@rekmarks rekmarks changed the title refactor!: refactorSafeEventEmitterProvider -> InternalProvider refactor!: Replace SafeEventEmitterProvider with InternalProvider Oct 7, 2025
@rekmarks rekmarks marked this pull request as ready for review October 7, 2025 20:59
@rekmarks rekmarks requested review from a team as code owners October 7, 2025 20:59
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

I think there's one thing with the proxies that we may want to adjust, but the rest looks good. Thank you for removing the lint warnings as well!

Can you:

  • generate preview builds
  • make a new branch on Extension, upgrade network-controller to the preview build, push the PR, and wait for CI to pass
  • build the extension locally, open the test dapp, and make sure you can still make network requests on different chains
  • do the same thing for mobile

Let me know if you want to tag team this, I have a bit of time now.

cursor[bot]

This comment was marked as outdated.

@rekmarks
Copy link
Member Author

rekmarks commented Oct 7, 2025

@metamaskbot publish-preview

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2025

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-tree-controller": "1.4.0-preview-622f3f09",
  "@metamask-previews/accounts-controller": "33.1.0-preview-622f3f09",
  "@metamask-previews/address-book-controller": "6.1.1-preview-622f3f09",
  "@metamask-previews/announcement-controller": "7.0.3-preview-622f3f09",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-622f3f09",
  "@metamask-previews/approval-controller": "7.1.3-preview-622f3f09",
  "@metamask-previews/assets-controllers": "78.0.0-preview-622f3f09",
  "@metamask-previews/base-controller": "8.4.0-preview-622f3f09",
  "@metamask-previews/bridge-controller": "48.0.0-preview-622f3f09",
  "@metamask-previews/bridge-status-controller": "48.0.0-preview-622f3f09",
  "@metamask-previews/build-utils": "3.0.3-preview-622f3f09",
  "@metamask-previews/chain-agnostic-permission": "1.1.1-preview-622f3f09",
  "@metamask-previews/composable-controller": "11.0.0-preview-622f3f09",
  "@metamask-previews/controller-utils": "11.14.0-preview-622f3f09",
  "@metamask-previews/delegation-controller": "0.7.0-preview-622f3f09",
  "@metamask-previews/earn-controller": "8.0.0-preview-622f3f09",
  "@metamask-previews/eip-5792-middleware": "1.2.0-preview-622f3f09",
  "@metamask-previews/eip1193-permission-middleware": "1.0.0-preview-622f3f09",
  "@metamask-previews/ens-controller": "17.0.1-preview-622f3f09",
  "@metamask-previews/error-reporting-service": "2.2.0-preview-622f3f09",
  "@metamask-previews/eth-json-rpc-provider": "5.0.0-preview-622f3f09",
  "@metamask-previews/foundryup": "1.0.1-preview-622f3f09",
  "@metamask-previews/gas-fee-controller": "24.0.0-preview-622f3f09",
  "@metamask-previews/gator-permissions-controller": "0.2.0-preview-622f3f09",
  "@metamask-previews/json-rpc-engine": "10.1.0-preview-622f3f09",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-622f3f09",
  "@metamask-previews/keyring-controller": "23.1.0-preview-622f3f09",
  "@metamask-previews/logging-controller": "6.0.4-preview-622f3f09",
  "@metamask-previews/message-manager": "13.0.0-preview-622f3f09",
  "@metamask-previews/messenger": "0.3.0-preview-622f3f09",
  "@metamask-previews/multichain-account-service": "1.6.0-preview-622f3f09",
  "@metamask-previews/multichain-api-middleware": "1.2.0-preview-622f3f09",
  "@metamask-previews/multichain-network-controller": "1.0.0-preview-622f3f09",
  "@metamask-previews/multichain-transactions-controller": "5.0.0-preview-622f3f09",
  "@metamask-previews/name-controller": "8.0.3-preview-622f3f09",
  "@metamask-previews/network-controller": "24.2.0-preview-622f3f09",
  "@metamask-previews/network-enablement-controller": "2.1.0-preview-622f3f09",
  "@metamask-previews/notification-services-controller": "18.2.0-preview-622f3f09",
  "@metamask-previews/permission-controller": "11.0.6-preview-622f3f09",
  "@metamask-previews/permission-log-controller": "4.0.0-preview-622f3f09",
  "@metamask-previews/phishing-controller": "14.1.0-preview-622f3f09",
  "@metamask-previews/polling-controller": "14.0.0-preview-622f3f09",
  "@metamask-previews/preferences-controller": "20.0.1-preview-622f3f09",
  "@metamask-previews/profile-sync-controller": "25.1.0-preview-622f3f09",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-622f3f09",
  "@metamask-previews/remote-feature-flag-controller": "1.7.0-preview-622f3f09",
  "@metamask-previews/sample-controllers": "2.0.0-preview-622f3f09",
  "@metamask-previews/seedless-onboarding-controller": "4.0.0-preview-622f3f09",
  "@metamask-previews/selected-network-controller": "24.0.0-preview-622f3f09",
  "@metamask-previews/shield-controller": "0.2.0-preview-622f3f09",
  "@metamask-previews/signature-controller": "34.0.0-preview-622f3f09",
  "@metamask-previews/subscription-controller": "1.0.0-preview-622f3f09",
  "@metamask-previews/token-search-discovery-controller": "3.3.0-preview-622f3f09",
  "@metamask-previews/transaction-controller": "60.6.0-preview-622f3f09",
  "@metamask-previews/user-operation-controller": "39.0.0-preview-622f3f09"
}

@rekmarks
Copy link
Member Author

rekmarks commented Oct 7, 2025

cc: @mcmire

@mcmire

This comment was marked as outdated.

@rekmarks

This comment was marked as outdated.

@rekmarks rekmarks marked this pull request as draft October 8, 2025 16:17
@rekmarks rekmarks force-pushed the rekm/internal-provider branch 2 times, most recently from c48651b to 2caa429 Compare October 28, 2025 17:39
@rekmarks rekmarks force-pushed the rekm/internal-provider branch from 2caa429 to f0dbedf Compare October 29, 2025 20:39
@rekmarks rekmarks requested a review from mcmire October 29, 2025 20:40
@rekmarks rekmarks marked this pull request as ready for review October 29, 2025 20:40
* @deprecated Use {@link InternalProvider} instead.
*/
type SafeEventEmitterProvider = InternalProvider;
const SafeEventEmitterProvider = InternalProvider;
Copy link
Member

Choose a reason for hiding this comment

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

What is the reasoning for keeping the alias around if we are removing it everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Builds / tests fail because something monorepo-external uses SafeEventEmitterProvider and removing it completely blows up. My suspicion is that all library uses of it need to be removed, then we can delete the deprecated alias completely.


this.messenger.registerActionHandler(
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Copy link
Member

Choose a reason for hiding this comment

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

Why are all of these no longer required? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

My suspicion is that they weren't required prior to this PR, and the manner in which I linted the package (yarn eslint --fix packages/... from root) removed a bunch of unused disable directives.

Copy link
Contributor

Choose a reason for hiding this comment

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

When these lint violations appeared, at the time we were using an older version of the typescript-eslint packages. When we upgraded, they went away.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

LGTM!

import { type JsonRpcRequest, type Json } from '@metamask/utils';
import { BrowserProvider } from 'ethers';
import { promisify } from 'util';
// eslint-disable-next-line import-x/namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, I'm not sure why we have this lint rule, it doesn't make sense to me. Oh well...


this.messenger.registerActionHandler(
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Copy link
Contributor

Choose a reason for hiding this comment

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

When these lint violations appeared, at the time we were using an older version of the typescript-eslint packages. When we upgraded, they went away.

@rekmarks rekmarks enabled auto-merge (squash) October 31, 2025 18:17
@rekmarks rekmarks disabled auto-merge October 31, 2025 18:17
@rekmarks rekmarks enabled auto-merge (squash) October 31, 2025 18:19
@rekmarks rekmarks disabled auto-merge October 31, 2025 19:07
@rekmarks
Copy link
Member Author

I am bypassing rules to merge this without a review from @MetaMask/confirmations. Their review requirement was triggered by changes to packages/transaction-controller, but the only thing we did was rename the type of a property in a test mock.

@rekmarks rekmarks merged commit b3b0638 into main Oct 31, 2025
260 checks passed
@rekmarks rekmarks deleted the rekm/internal-provider branch October 31, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SafeEventEmitterProvider should reflect that it is no longer a SafeEventEmitter

6 participants