fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839
Open
matthewwalsh0 wants to merge 12 commits into
Open
fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839matthewwalsh0 wants to merge 12 commits into
matthewwalsh0 wants to merge 12 commits into
Conversation
77eee8b to
a9de394
Compare
4c70b63 to
8350c8e
Compare
…rams with generic return type
…ting after rpcRequest refactor
…pe param name, unused import, unnecessary casts
aa7c99a to
2b7b6e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
When querying a live on-chain token balance, the controller previously resolved the network client using
findNetworkClientIdByChainId, which returns whatever endpoint is currently selected for that chain — including custom RPC endpoints. Custom RPC endpoints may not support thependingblock tag used by these calls, causing the query to fail.This change adds a preference for the chain's Infura endpoint when one is configured, falling back to the existing
findNetworkClientIdByChainIdbehaviour if no Infura endpoint is configured or if the lookup throws.References
Checklist
Note
Medium Risk
Changes which RPC endpoint serves balance validation and on-chain amount reads for pay/relay flows; behavior is mitigated by fallback to the default network client when Infura is missing.
Overview
Introduces shared
getNetworkClientId/rpcRequesthelpers that can prefer a chain’s Infura RPC (viaNetworkController:getNetworkConfigurationByChainId) and otherwise fall back to the selected network client.getLiveTokenBalancenow uses direct JSON-RPC (eth_call/eth_getBalancewithpending) through those helpers withpreferInfura: true, replacing ethersWeb3Provider/Contract—aimed at custom RPCs that don’t support pending block tags.On-chain amount resolution for fiat flows and
getTransferredAmountFromTxHashis updated to the same provider-based RPC path. Across, Relay submit, and gas estimation usegetNetworkClientIdwithout the Infura preference. Tests and the test messenger mockgetNetworkConfigurationByChainIdaccordingly.Reviewed by Cursor Bugbot for commit 2472294. Bugbot is set up for automated code reviews on this repo. Configure here.