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: remove eth-method-registry package #5203

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cryptodev-2s
Copy link
Contributor

@cryptodev-2s cryptodev-2s commented Jan 27, 2025

Explanation

This PR removes the eth-method-registry package, as it relies on @metamask/ethjs-query and @metamask/ethjs-contract, which are not EIP-1193 compatible.

References

Fixes: partially completes #5121

Changelog

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 highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@cryptodev-2s cryptodev-2s requested review from a team as code owners January 27, 2025 21:50
@cryptodev-2s cryptodev-2s force-pushed the cryptodev2s/remove-eth-method-registry-package branch from 1cfbf7c to 77c9cd8 Compare January 27, 2025 21:57
@cryptodev-2s cryptodev-2s self-assigned this Jan 27, 2025
@cryptodev-2s cryptodev-2s changed the title chore: remove eth-method-registry package chore: remove eth-method-registry package Jan 27, 2025
OGPoyraz
OGPoyraz previously approved these changes Jan 28, 2025
@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

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.

See questions below. I'm curious whether it would be worth it not to mock @ethersproject/abi in the tests?

Copy link
Contributor

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

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "21.0.2-preview-77c9cd86",
  "@metamask-previews/address-book-controller": "6.0.2-preview-77c9cd86",
  "@metamask-previews/announcement-controller": "7.0.2-preview-77c9cd86",
  "@metamask-previews/approval-controller": "7.1.2-preview-77c9cd86",
  "@metamask-previews/assets-controllers": "46.0.1-preview-77c9cd86",
  "@metamask-previews/base-controller": "7.1.1-preview-77c9cd86",
  "@metamask-previews/build-utils": "3.0.2-preview-77c9cd86",
  "@metamask-previews/composable-controller": "10.0.0-preview-77c9cd86",
  "@metamask-previews/controller-utils": "11.4.5-preview-77c9cd86",
  "@metamask-previews/ens-controller": "15.0.1-preview-77c9cd86",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-77c9cd86",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-77c9cd86",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-77c9cd86",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-77c9cd86",
  "@metamask-previews/keyring-controller": "19.0.4-preview-77c9cd86",
  "@metamask-previews/logging-controller": "6.0.3-preview-77c9cd86",
  "@metamask-previews/message-manager": "12.0.0-preview-77c9cd86",
  "@metamask-previews/multichain": "2.1.0-preview-77c9cd86",
  "@metamask-previews/multichain-transactions-controller": "0.0.1-preview-77c9cd86",
  "@metamask-previews/name-controller": "8.0.2-preview-77c9cd86",
  "@metamask-previews/network-controller": "22.1.1-preview-77c9cd86",
  "@metamask-previews/notification-services-controller": "0.17.0-preview-77c9cd86",
  "@metamask-previews/permission-controller": "11.0.5-preview-77c9cd86",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-77c9cd86",
  "@metamask-previews/phishing-controller": "12.3.1-preview-77c9cd86",
  "@metamask-previews/polling-controller": "12.0.2-preview-77c9cd86",
  "@metamask-previews/preferences-controller": "15.0.1-preview-77c9cd86",
  "@metamask-previews/profile-sync-controller": "4.1.1-preview-77c9cd86",
  "@metamask-previews/queued-request-controller": "9.0.0-preview-77c9cd86",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-77c9cd86",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-77c9cd86",
  "@metamask-previews/selected-network-controller": "21.0.0-preview-77c9cd86",
  "@metamask-previews/signature-controller": "23.2.0-preview-77c9cd86",
  "@metamask-previews/token-search-discovery-controller": "1.0.0-preview-77c9cd86",
  "@metamask-previews/transaction-controller": "43.0.0-preview-77c9cd86",
  "@metamask-previews/user-operation-controller": "22.0.0-preview-77c9cd86"
}

@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

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

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "21.0.2-preview-009eef6b",
  "@metamask-previews/address-book-controller": "6.0.2-preview-009eef6b",
  "@metamask-previews/announcement-controller": "7.0.2-preview-009eef6b",
  "@metamask-previews/approval-controller": "7.1.2-preview-009eef6b",
  "@metamask-previews/assets-controllers": "46.0.1-preview-009eef6b",
  "@metamask-previews/base-controller": "7.1.1-preview-009eef6b",
  "@metamask-previews/build-utils": "3.0.2-preview-009eef6b",
  "@metamask-previews/composable-controller": "10.0.0-preview-009eef6b",
  "@metamask-previews/controller-utils": "11.4.5-preview-009eef6b",
  "@metamask-previews/ens-controller": "15.0.1-preview-009eef6b",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-009eef6b",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-009eef6b",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-009eef6b",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-009eef6b",
  "@metamask-previews/keyring-controller": "19.0.4-preview-009eef6b",
  "@metamask-previews/logging-controller": "6.0.3-preview-009eef6b",
  "@metamask-previews/message-manager": "12.0.0-preview-009eef6b",
  "@metamask-previews/multichain": "2.1.0-preview-009eef6b",
  "@metamask-previews/multichain-transactions-controller": "0.0.1-preview-009eef6b",
  "@metamask-previews/name-controller": "8.0.2-preview-009eef6b",
  "@metamask-previews/network-controller": "22.1.1-preview-009eef6b",
  "@metamask-previews/notification-services-controller": "0.17.0-preview-009eef6b",
  "@metamask-previews/permission-controller": "11.0.5-preview-009eef6b",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-009eef6b",
  "@metamask-previews/phishing-controller": "12.3.1-preview-009eef6b",
  "@metamask-previews/polling-controller": "12.0.2-preview-009eef6b",
  "@metamask-previews/preferences-controller": "15.0.1-preview-009eef6b",
  "@metamask-previews/profile-sync-controller": "4.1.1-preview-009eef6b",
  "@metamask-previews/queued-request-controller": "9.0.0-preview-009eef6b",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-009eef6b",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-009eef6b",
  "@metamask-previews/selected-network-controller": "21.0.0-preview-009eef6b",
  "@metamask-previews/signature-controller": "23.2.0-preview-009eef6b",
  "@metamask-previews/token-search-discovery-controller": "1.0.0-preview-009eef6b",
  "@metamask-previews/transaction-controller": "43.0.0-preview-009eef6b",
  "@metamask-previews/user-operation-controller": "22.0.0-preview-009eef6b"
}

@cryptodev-2s
Copy link
Contributor Author

@metamask-previews/transaction-controller": "43.0.0-preview-009eef6b

I am testing the changes in this PR: MetaMask/metamask-extension#29749. You can check this commit for details: 1d1f45b.

I will also try to update the test to avoid mocking @ethersproject/abi.

@mcmire
Copy link
Contributor

mcmire commented Jan 28, 2025

@cryptodev-2s One more question on this PR. I get that we want to remove dependencies on ethjs packages, but I'm curious about the rationale for removing the eth-method-registry package entirely. Was there discussion somewhere that I might have missed? I get that we haven't taken good care of this package, but it's a fairly important part of the confirmation flow and it may have more visibility if it were kept separate from transaction-controller. Or do we plan on replacing it with something else in the future?

@cryptodev-2s
Copy link
Contributor Author

@cryptodev-2s One more question on this PR. I get that we want to remove dependencies on ethjs packages, but I'm curious about the rationale for removing the eth-method-registry package entirely. Was there discussion somewhere that I might have missed? I get that we haven't taken good care of this package, but it's a fairly important part of the confirmation flow and it may have more visibility if it were kept separate from transaction-controller. Or do we plan on replacing it with something else in the future?

To answer your question, there hasn’t been any discussion about the package, nor am I aware of any plans to replace it. I made the change primarily because it removed several eth* packages at once and reduced the build size by nearly 1MB.

In this case, it might make more sense to update eth-method-registry ?

@mcmire
Copy link
Contributor

mcmire commented Jan 28, 2025

@cryptodev-2s Yeah, I'm thinking that it might be better to update eth-method-registry.

But I guess I can see the other way too; by moving the code here we're effectively moving the package into the monorepo, and that's kind of nice from a maintainability perspective.

Curious to know what the Confirmations team thinks...

@cryptodev-2s
Copy link
Contributor Author

@cryptodev-2s Yeah, I'm thinking that it might be better to update eth-method-registry.

But I guess I can see the other way too; by moving the code here we're effectively moving the package into the monorepo, and that's kind of nice from a maintainability perspective.

Curious to know what the Confirmations team thinks...

@OGPoyraz, any thoughts on the discussion regarding this change or whether we should keep eth-method-registry? move it to core ?

@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

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

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "21.0.2-preview-455ba549",
  "@metamask-previews/address-book-controller": "6.0.2-preview-455ba549",
  "@metamask-previews/announcement-controller": "7.0.2-preview-455ba549",
  "@metamask-previews/approval-controller": "7.1.2-preview-455ba549",
  "@metamask-previews/assets-controllers": "46.0.1-preview-455ba549",
  "@metamask-previews/base-controller": "7.1.1-preview-455ba549",
  "@metamask-previews/build-utils": "3.0.2-preview-455ba549",
  "@metamask-previews/composable-controller": "10.0.0-preview-455ba549",
  "@metamask-previews/controller-utils": "11.4.5-preview-455ba549",
  "@metamask-previews/ens-controller": "15.0.1-preview-455ba549",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-455ba549",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-455ba549",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-455ba549",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-455ba549",
  "@metamask-previews/keyring-controller": "19.0.4-preview-455ba549",
  "@metamask-previews/logging-controller": "6.0.3-preview-455ba549",
  "@metamask-previews/message-manager": "12.0.0-preview-455ba549",
  "@metamask-previews/multichain": "2.1.0-preview-455ba549",
  "@metamask-previews/multichain-transactions-controller": "0.0.1-preview-455ba549",
  "@metamask-previews/name-controller": "8.0.2-preview-455ba549",
  "@metamask-previews/network-controller": "22.1.1-preview-455ba549",
  "@metamask-previews/notification-services-controller": "0.17.0-preview-455ba549",
  "@metamask-previews/permission-controller": "11.0.5-preview-455ba549",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-455ba549",
  "@metamask-previews/phishing-controller": "12.3.1-preview-455ba549",
  "@metamask-previews/polling-controller": "12.0.2-preview-455ba549",
  "@metamask-previews/preferences-controller": "15.0.1-preview-455ba549",
  "@metamask-previews/profile-sync-controller": "4.1.1-preview-455ba549",
  "@metamask-previews/queued-request-controller": "9.0.0-preview-455ba549",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-455ba549",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-455ba549",
  "@metamask-previews/selected-network-controller": "21.0.0-preview-455ba549",
  "@metamask-previews/signature-controller": "23.2.0-preview-455ba549",
  "@metamask-previews/token-search-discovery-controller": "1.0.0-preview-455ba549",
  "@metamask-previews/transaction-controller": "43.0.0-preview-455ba549",
  "@metamask-previews/user-operation-controller": "22.0.0-preview-455ba549"
}

@OGPoyraz
Copy link
Member

OGPoyraz commented Jan 30, 2025

@cryptodev-2s I will defer this question to @matthewwalsh0 as we discussed yesterday

Copy link
Member

@matthewwalsh0 matthewwalsh0 left a comment

Choose a reason for hiding this comment

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

We can all agree the TransactionController is large already, and the placement of this method data lookup within this controller has already been debated in the past.

The handleMethodData isn't used in extension, and only slightly in mobile, but that too could be removed to align with the extension code that uses token ABIs, 4Byte, Uniswap Command Parsing, and Sourcify.

I think in future the confirmations team would like to bundle all of that transaction decoding logic into a clean @metamask/transaction-decode that lives in core and is used by this controller to augment transaction metadata.

Given that intention, I'd vote not to push in the opposite direction now by adding more lower-level logic into this controller.

Instead we could continue to encapsulate via the method registry package at least for now, and then in future we could use that package within a new dedicated transaction decode package, or flatten its contents into the new package given its very small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants