feat(transaction-pay-controller): add optional getBalance callback for max-amount source-amount calculation - #9802
Draft
matthewwalsh0 wants to merge 4 commits into
Draft
feat(transaction-pay-controller): add optional getBalance callback for max-amount source-amount calculation#9802matthewwalsh0 wants to merge 4 commits into
matthewwalsh0 wants to merge 4 commits into
Conversation
matthewwalsh0
force-pushed
the
feat/pay-get-balance-callback
branch
from
August 7, 2026 13:57
ee37727 to
bdb9609
Compare
…sts, changelog link
matthewwalsh0
force-pushed
the
feat/pay-get-balance-callback
branch
from
August 7, 2026 15:26
c72dab9 to
6d62adf
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
The pay controller's
isMaxAmountlogic hard-codes a token-balance lookup frompaymentToken.balanceHuman/balanceRaw. This works for the standard flow, but alternate transaction types (perps, predict, money-account overrides, post-quote flows) source their balance differently. Previously this forced complex conditional logic to live outside the controller in mobile and other consumers.This PR adds an optional, synchronous
getBalancecallback toTransactionPayControllerOptions. When supplied, it is called once per source-amount update (inside the existing immer state-update block) and its return value replaces the built-in token balance in both the standard and post-quoteisMaxAmountbranches. Returningundefinedfrom the callback (or not providing it at all) falls back to the existing token-balance behaviour, preserving 100% backward compatibility.The callback must be synchronous because
updateSourceAmountsruns insidethis.update()— an async version would require a larger refactor and is out of scope.The
PaymentOverride.MoneyAccountguard is preserved; it intentionally bypasses the max branch regardless of any override.References
Checklist