feat(transaction-pay-controller): live token balances#7935
Merged
matthewwalsh0 merged 3 commits intomainfrom Feb 20, 2026
Merged
feat(transaction-pay-controller): live token balances#7935matthewwalsh0 merged 3 commits intomainfrom
matthewwalsh0 merged 3 commits intomainfrom
Conversation
44986a4 to
3084450
Compare
8b48e2c to
e7b1aa6
Compare
Member
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
61f5438 to
9547b7e
Compare
7 tasks
OGPoyraz
previously approved these changes
Feb 18, 2026
9547b7e to
3246505
Compare
OGPoyraz
approved these changes
Feb 20, 2026
|
|
||
| updateTransactionData(transactionId, (data) => { | ||
| data.paymentToken = updatedToken; | ||
| }); |
There was a problem hiding this comment.
Stale balance refresh can revert user's token selection
Medium Severity
refreshPaymentTokenBalance unconditionally writes data.paymentToken = updatedToken after the async getLiveTokenBalance RPC call, where updatedToken is derived from the token captured before the await. If the user selects a different payment token during that async gap, this write overwrites their new selection with the stale token (plus refreshed balance). Because #updateTransactionData detects the address/chainId change, it then triggers a new updateQuotes for the wrong token — effectively reverting the user's choice with no cancellation mechanism in place.
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
Use live on-chain balance checks to improve stability:
balanceOforeth_getBalance.References
Checklist
Note
Medium Risk
Touches quote-refresh and Relay deposit submission paths and introduces new RPC reads/permission requirements, so failures or latency could block quoting or submission if not handled as expected.
Overview
Adds live on-chain balance reads to pay flows:
updateQuotesnow refreshes the selected payment token balance from chain before building quote requests, and Relay submissions now validate the quote’ssourceAmount.rawagainst a live balance check to fail fast with a descriptive error.Introduces new token utilities (
getLiveTokenBalanceusingethersprovider/balanceOf, plus sharedcomputeTokenAmounts) and refactors existing balance/amount computations to use them; updates tests accordingly and tightensTransactionPayController’s “payment token changed” detection to compareaddress(case-insensitive) andchainId. Also adds@ethersproject/providersdependency and documents the breaking messenger permission requirement forNetworkController:getNetworkClientById.Written by Cursor Bugbot for commit 3246505. This will update automatically on new commits. Configure here.