refactor(transaction-controller): encapsulate provider logic#8273
refactor(transaction-controller): encapsulate provider logic#8273matthewwalsh0 wants to merge 11 commits intomainfrom
Conversation
c2ffb95 to
72ca7a5
Compare
…ethQuery from transaction-controller Replace all ethQuery/EthQuery usage with a new rpcRequest() utility that accepts messenger + chainId/networkClientId + method + params. Any file can now send RPC requests without passing around ethQuery instances. - Add utils/provider.ts with rpcRequest() and getProvider() functions - Migrate all utils, gas-flows, helpers, hooks, and TransactionController - Update GasFeeFlowRequest type: ethQuery -> networkClientId (BREAKING) - Update determineTransactionType signature to options object (BREAKING) - Remove @metamask/eth-query dependency - Update all test files to match new signatures
72ca7a5 to
a7e5332
Compare
…nts for connectivity-controller
packages/transaction-controller/src/helpers/PendingTransactionTracker.ts
Outdated
Show resolved
Hide resolved
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
packages/transaction-controller/src/TransactionControllerIntegration.test.ts
Show resolved
Hide resolved
| const networkClientId = | ||
| transactionNetworkClientId ?? | ||
| (this.#findNetworkClientIdByChainId(chainId) as string); | ||
| getNetworkClientId({ messenger: this.#messenger, chainId }); |
There was a problem hiding this comment.
GasFeePoller network lookup failure aborts all transaction updates
Low Severity
In #getGasFeeControllerDataByChainId, getNetworkClientId throws for unrecognized chain IDs. Since this runs inside a for loop building a map for ALL chains, a single unknown chain aborts gas fee data fetching for every chain. The old callback could return undefined silently, allowing partial success. This means one stale transaction with an unknown chain could block gas fee polling for all other valid transactions in that cycle.
|
@metamaskbot publish-preview |


Explanation
Currently,
transaction-controllerpassesethQueryinstances throughout the codebase — into utils, helpers, hooks, and gas flows — to make RPC calls. This couples every layer toEthQueryinternals and makes the provider plumbing verbose and fragile.This PR introduces a
utils/provider.tsmodule with functions includingrpcRequestandgetProvider, meaning allEthQueryusage is replaced, and all provider logic is encapsulated and callable anywhere with amessenger.References
Checklist
Note
Medium Risk
Refactors transaction publishing/gas estimation/pending tracking to replace
EthQuerywith messenger-drivenrpcRequest, which could subtly change RPC call shapes/ordering and networkClientId resolution across many paths.Overview
Removes
@metamask/eth-queryand threads provider access through a newutils/provider.tsAPI (getProvider,rpcRequest,getNetworkClientId,getChainId) so helpers/flows no longer receive or constructEthQueryinstances.Transaction submission, gas estimation/fee flows (including Linea), balance/simulation utilities, batch publishing hooks, and pending transaction tracking are updated to use
rpcRequest+networkClientId/chainIdresolution viaNetworkControllermessenger actions, and internal helper signatures are adjusted accordingly (e.g.,PendingTransactionTrackernow takesnetworkClientIddirectly).Tests are updated to mock
rpcRequest/provider utilities, account for changed network client ID lookup, and align integration mocks with the updated RPC call sequence;determineTransactionTypeis no longer exported from the package and the changelog marks this as a breaking removal.Written by Cursor Bugbot for commit a0caca0. This will update automatically on new commits. Configure here.