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

Merged

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
OGPoyraz
OGPoyraz previously approved these changes Nov 25, 2024
Copy link
Member

@OGPoyraz OGPoyraz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for detailed changes in the description.

@matthewwalsh0 matthewwalsh0 requested review from OGPoyraz and pedronfigueiredo and removed request for OGPoyraz November 26, 2024 09:13
OGPoyraz
OGPoyraz previously approved these changes Nov 26, 2024
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

@matthewwalsh0 matthewwalsh0 merged commit ddbd5db into main Nov 26, 2024
121 checks passed
@matthewwalsh0 matthewwalsh0 deleted the refactor/transaction-controller-remove-global-network branch November 26, 2024 09:59
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": "20.0.0-preview-f4bb6719",
  "@metamask-previews/address-book-controller": "6.0.1-preview-f4bb6719",
  "@metamask-previews/announcement-controller": "7.0.1-preview-f4bb6719",
  "@metamask-previews/approval-controller": "7.1.1-preview-f4bb6719",
  "@metamask-previews/assets-controllers": "45.1.0-preview-f4bb6719",
  "@metamask-previews/base-controller": "7.0.2-preview-f4bb6719",
  "@metamask-previews/build-utils": "3.0.1-preview-f4bb6719",
  "@metamask-previews/chain-controller": "0.2.0-preview-f4bb6719",
  "@metamask-previews/composable-controller": "9.0.1-preview-f4bb6719",
  "@metamask-previews/controller-utils": "11.4.3-preview-f4bb6719",
  "@metamask-previews/ens-controller": "15.0.0-preview-f4bb6719",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-f4bb6719",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-f4bb6719",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-f4bb6719",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-f4bb6719",
  "@metamask-previews/keyring-controller": "19.0.0-preview-f4bb6719",
  "@metamask-previews/logging-controller": "6.0.2-preview-f4bb6719",
  "@metamask-previews/message-manager": "11.0.1-preview-f4bb6719",
  "@metamask-previews/multichain": "1.0.0-preview-f4bb6719",
  "@metamask-previews/name-controller": "8.0.1-preview-f4bb6719",
  "@metamask-previews/network-controller": "22.0.2-preview-f4bb6719",
  "@metamask-previews/notification-controller": "7.0.0-preview-f4bb6719",
  "@metamask-previews/notification-services-controller": "0.14.0-preview-f4bb6719",
  "@metamask-previews/permission-controller": "11.0.3-preview-f4bb6719",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-f4bb6719",
  "@metamask-previews/phishing-controller": "12.3.0-preview-f4bb6719",
  "@metamask-previews/polling-controller": "12.0.1-preview-f4bb6719",
  "@metamask-previews/preferences-controller": "15.0.0-preview-f4bb6719",
  "@metamask-previews/profile-sync-controller": "2.0.0-preview-f4bb6719",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-f4bb6719",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-f4bb6719",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-f4bb6719",
  "@metamask-previews/signature-controller": "23.0.0-preview-f4bb6719",
  "@metamask-previews/transaction-controller": "40.1.0-preview-f4bb6719",
  "@metamask-previews/user-operation-controller": "19.0.0-preview-f4bb6719"
}

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.

3 participants