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

refactor: remove global network from transaction controller #4920

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

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Nov 13, 2024

Explanation

Remove all global network usage from the @metamask/transaction-controller package.

Specifically:

  • Remove the following constructor options:
    • blockTracker
    • isMultichainEnabled
    • onNetworkStateChange
    • provider
  • Require networkClientId option in calls to addTransaction.
  • Make networkClientId required in TransactionMeta type.
  • Remove global instances of:
    • PendingTransactionTracker
    • IncomingTransactionHelper
    • NonceTracker.
  • Replace wipeTransactions method arguments with object containing optional chainId and address properties.
  • Require networkClientId argument in:
    • getNonceLock
    • estimateGas
    • estimateGasBuffered
  • Remove filterToCurrentNetwork option from getTransactions method.
  • Add networkClientId argument to handleMethodData method.
  • Add MethodDataHelper to encapsulate handleMethodData method logic.
  • Replace getProvider and getEthQuery methods with getNetworkClient method in MultichainTrackingHelper.
  • Created nested debug loggers per chain in PendingTransactionTracker and IncomingTransactionHelper.
  • Create dedicated debug logger for MultichainTrackingHelper with additional logs.

References

Changelog

See CHANGELOG.md.

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

Remove multichain flag.
Remove provider and block tracker constructor options.
Temporarily disable handleMethodData method.
Remove unnecessary unit tests.
Fix unit tests.
Fix logging in multichain helper.
Change wipeTransactions arguments to object.
Remove stopAllIncomingTransactionPolling method.
Create separate helper loggers per chain.
@matthewwalsh0
Copy link
Member 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": "19.0.0-preview-e6757fdb",
  "@metamask-previews/address-book-controller": "6.0.1-preview-e6757fdb",
  "@metamask-previews/announcement-controller": "7.0.1-preview-e6757fdb",
  "@metamask-previews/approval-controller": "7.1.1-preview-e6757fdb",
  "@metamask-previews/assets-controllers": "43.0.0-preview-e6757fdb",
  "@metamask-previews/base-controller": "7.0.2-preview-e6757fdb",
  "@metamask-previews/build-utils": "3.0.1-preview-e6757fdb",
  "@metamask-previews/chain-controller": "0.1.3-preview-e6757fdb",
  "@metamask-previews/composable-controller": "9.0.1-preview-e6757fdb",
  "@metamask-previews/controller-utils": "11.4.3-preview-e6757fdb",
  "@metamask-previews/ens-controller": "15.0.0-preview-e6757fdb",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-e6757fdb",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-e6757fdb",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-e6757fdb",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-e6757fdb",
  "@metamask-previews/keyring-controller": "18.0.0-preview-e6757fdb",
  "@metamask-previews/logging-controller": "6.0.2-preview-e6757fdb",
  "@metamask-previews/message-manager": "11.0.1-preview-e6757fdb",
  "@metamask-previews/multichain": "0.0.0-preview-e6757fdb",
  "@metamask-previews/name-controller": "8.0.1-preview-e6757fdb",
  "@metamask-previews/network-controller": "22.0.2-preview-e6757fdb",
  "@metamask-previews/notification-controller": "7.0.0-preview-e6757fdb",
  "@metamask-previews/notification-services-controller": "0.13.0-preview-e6757fdb",
  "@metamask-previews/permission-controller": "11.0.3-preview-e6757fdb",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-e6757fdb",
  "@metamask-previews/phishing-controller": "12.3.0-preview-e6757fdb",
  "@metamask-previews/polling-controller": "12.0.1-preview-e6757fdb",
  "@metamask-previews/preferences-controller": "14.0.0-preview-e6757fdb",
  "@metamask-previews/profile-sync-controller": "1.0.0-preview-e6757fdb",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-e6757fdb",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-e6757fdb",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-e6757fdb",
  "@metamask-previews/signature-controller": "22.0.0-preview-e6757fdb",
  "@metamask-previews/transaction-controller": "39.0.0-preview-e6757fdb",
  "@metamask-previews/user-operation-controller": "18.0.0-preview-e6757fdb"
}

@matthewwalsh0
Copy link
Member 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": "19.0.0-preview-49553b36",
  "@metamask-previews/address-book-controller": "6.0.1-preview-49553b36",
  "@metamask-previews/announcement-controller": "7.0.1-preview-49553b36",
  "@metamask-previews/approval-controller": "7.1.1-preview-49553b36",
  "@metamask-previews/assets-controllers": "43.0.0-preview-49553b36",
  "@metamask-previews/base-controller": "7.0.2-preview-49553b36",
  "@metamask-previews/build-utils": "3.0.1-preview-49553b36",
  "@metamask-previews/chain-controller": "0.1.3-preview-49553b36",
  "@metamask-previews/composable-controller": "9.0.1-preview-49553b36",
  "@metamask-previews/controller-utils": "11.4.3-preview-49553b36",
  "@metamask-previews/ens-controller": "15.0.0-preview-49553b36",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-49553b36",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-49553b36",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-49553b36",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-49553b36",
  "@metamask-previews/keyring-controller": "18.0.0-preview-49553b36",
  "@metamask-previews/logging-controller": "6.0.2-preview-49553b36",
  "@metamask-previews/message-manager": "11.0.1-preview-49553b36",
  "@metamask-previews/multichain": "0.0.0-preview-49553b36",
  "@metamask-previews/name-controller": "8.0.1-preview-49553b36",
  "@metamask-previews/network-controller": "22.0.2-preview-49553b36",
  "@metamask-previews/notification-controller": "7.0.0-preview-49553b36",
  "@metamask-previews/notification-services-controller": "0.13.0-preview-49553b36",
  "@metamask-previews/permission-controller": "11.0.3-preview-49553b36",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-49553b36",
  "@metamask-previews/phishing-controller": "12.3.0-preview-49553b36",
  "@metamask-previews/polling-controller": "12.0.1-preview-49553b36",
  "@metamask-previews/preferences-controller": "14.0.0-preview-49553b36",
  "@metamask-previews/profile-sync-controller": "1.0.0-preview-49553b36",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-49553b36",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-49553b36",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-49553b36",
  "@metamask-previews/signature-controller": "22.0.0-preview-49553b36",
  "@metamask-previews/transaction-controller": "39.0.0-preview-49553b36",
  "@metamask-previews/user-operation-controller": "18.0.0-preview-49553b36"
}

@matthewwalsh0
Copy link
Member 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": "19.0.0-preview-913113cf",
  "@metamask-previews/address-book-controller": "6.0.1-preview-913113cf",
  "@metamask-previews/announcement-controller": "7.0.1-preview-913113cf",
  "@metamask-previews/approval-controller": "7.1.1-preview-913113cf",
  "@metamask-previews/assets-controllers": "43.0.0-preview-913113cf",
  "@metamask-previews/base-controller": "7.0.2-preview-913113cf",
  "@metamask-previews/build-utils": "3.0.1-preview-913113cf",
  "@metamask-previews/chain-controller": "0.1.3-preview-913113cf",
  "@metamask-previews/composable-controller": "9.0.1-preview-913113cf",
  "@metamask-previews/controller-utils": "11.4.3-preview-913113cf",
  "@metamask-previews/ens-controller": "15.0.0-preview-913113cf",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-913113cf",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-913113cf",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-913113cf",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-913113cf",
  "@metamask-previews/keyring-controller": "18.0.0-preview-913113cf",
  "@metamask-previews/logging-controller": "6.0.2-preview-913113cf",
  "@metamask-previews/message-manager": "11.0.1-preview-913113cf",
  "@metamask-previews/multichain": "0.0.0-preview-913113cf",
  "@metamask-previews/name-controller": "8.0.1-preview-913113cf",
  "@metamask-previews/network-controller": "22.0.2-preview-913113cf",
  "@metamask-previews/notification-controller": "7.0.0-preview-913113cf",
  "@metamask-previews/notification-services-controller": "0.13.0-preview-913113cf",
  "@metamask-previews/permission-controller": "11.0.3-preview-913113cf",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-913113cf",
  "@metamask-previews/phishing-controller": "12.3.0-preview-913113cf",
  "@metamask-previews/polling-controller": "12.0.1-preview-913113cf",
  "@metamask-previews/preferences-controller": "14.0.0-preview-913113cf",
  "@metamask-previews/profile-sync-controller": "1.0.0-preview-913113cf",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-913113cf",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-913113cf",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-913113cf",
  "@metamask-previews/signature-controller": "22.0.0-preview-913113cf",
  "@metamask-previews/transaction-controller": "39.0.0-preview-913113cf",
  "@metamask-previews/user-operation-controller": "18.0.0-preview-913113cf"
}

@matthewwalsh0
Copy link
Member 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": "19.0.0-preview-14d3599e",
  "@metamask-previews/address-book-controller": "6.0.1-preview-14d3599e",
  "@metamask-previews/announcement-controller": "7.0.1-preview-14d3599e",
  "@metamask-previews/approval-controller": "7.1.1-preview-14d3599e",
  "@metamask-previews/assets-controllers": "43.0.0-preview-14d3599e",
  "@metamask-previews/base-controller": "7.0.2-preview-14d3599e",
  "@metamask-previews/build-utils": "3.0.1-preview-14d3599e",
  "@metamask-previews/chain-controller": "0.1.3-preview-14d3599e",
  "@metamask-previews/composable-controller": "9.0.1-preview-14d3599e",
  "@metamask-previews/controller-utils": "11.4.3-preview-14d3599e",
  "@metamask-previews/ens-controller": "15.0.0-preview-14d3599e",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-14d3599e",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-14d3599e",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-14d3599e",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-14d3599e",
  "@metamask-previews/keyring-controller": "18.0.0-preview-14d3599e",
  "@metamask-previews/logging-controller": "6.0.2-preview-14d3599e",
  "@metamask-previews/message-manager": "11.0.1-preview-14d3599e",
  "@metamask-previews/multichain": "0.0.0-preview-14d3599e",
  "@metamask-previews/name-controller": "8.0.1-preview-14d3599e",
  "@metamask-previews/network-controller": "22.0.2-preview-14d3599e",
  "@metamask-previews/notification-controller": "7.0.0-preview-14d3599e",
  "@metamask-previews/notification-services-controller": "0.13.0-preview-14d3599e",
  "@metamask-previews/permission-controller": "11.0.3-preview-14d3599e",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-14d3599e",
  "@metamask-previews/phishing-controller": "12.3.0-preview-14d3599e",
  "@metamask-previews/polling-controller": "12.0.1-preview-14d3599e",
  "@metamask-previews/preferences-controller": "14.0.0-preview-14d3599e",
  "@metamask-previews/profile-sync-controller": "1.0.0-preview-14d3599e",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-14d3599e",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-14d3599e",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-14d3599e",
  "@metamask-previews/signature-controller": "22.0.0-preview-14d3599e",
  "@metamask-previews/transaction-controller": "39.0.0-preview-14d3599e",
  "@metamask-previews/user-operation-controller": "18.0.0-preview-14d3599e"
}

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review November 19, 2024 13:44
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners November 19, 2024 13:44
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.

2 participants