Skip to content

fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839

Merged
matthewwalsh0 merged 12 commits into
mainfrom
fix/pay-infura-balance-nonce
Jun 1, 2026
Merged

fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839
matthewwalsh0 merged 12 commits into
mainfrom
fix/pay-infura-balance-nonce

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented May 18, 2026

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 the pending block 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 findNetworkClientIdByChainId behaviour if no Infura endpoint is configured or if the lookup throws.

References

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 communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes which RPC endpoint serves balance checks and on-chain amount reads before Relay submit; wrong endpoint selection could block or mis-validate pay deposits, though Infura preference falls back to the default client.

Overview
Introduces shared provider utilities (getNetworkClientId, rpcRequest) so chain RPC calls go through the controller messenger’s provider.request instead of ethers Web3Provider / Contract.

Live token balances (getLiveTokenBalance) now call eth_getBalance / eth_call with the pending block tag and pass preferInfura: true, picking the chain’s Infura networkClientId when configured and otherwise using findNetworkClientIdByChainId—addressing failures on custom RPCs that don’t support pending queries.

The same RPC helper path is used for fiat source amount resolution and transfer amount from tx hash (receipt logs, debug_traceTransaction, eth_getTransactionByHash). Across, Relay, and gas estimation call sites switch to getNetworkClientId for consistency.

Messenger AllowedActions and test mocks register NetworkController:getNetworkConfigurationByChainId. Changelog documents the Infura preference for live balance queries.

Reviewed by Cursor Bugbot for commit 4ca5364. Bugbot is set up for automated code reviews on this repo. Configure here.

@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch 4 times, most recently from 77eee8b to a9de394 Compare May 18, 2026 14:14
@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch from 4c70b63 to 8350c8e Compare May 27, 2026 23:14
@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch from aa7c99a to 2b7b6e0 Compare May 29, 2026 21:01
@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review May 29, 2026 23:23
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners May 29, 2026 23:23
@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch from 2472294 to 4ca5364 Compare June 1, 2026 09:45
@matthewwalsh0 matthewwalsh0 added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit 7b49e02 Jun 1, 2026
370 checks passed
@matthewwalsh0 matthewwalsh0 deleted the fix/pay-infura-balance-nonce branch June 1, 2026 11:12
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.

2 participants