fix(predict): stabilize Predict pay-with-any-token quote updates cp-7.77.0#30064
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Hey @caieu this is what i found High severity1. No safety timeout on
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #30064 +/- ##
==========================================
+ Coverage 81.54% 81.62% +0.08%
==========================================
Files 5343 5369 +26
Lines 142128 143010 +882
Branches 32411 32644 +233
==========================================
+ Hits 115899 116735 +836
+ Misses 18299 18295 -4
- Partials 7930 7980 +50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8076ba7 to
ea34d01
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
SmokePredictions: Directly required - the buy flow with any token is the core changed functionality. Error handling, payment token selection, and CTA state management are all modified. SmokeWalletPlatform: Required per SmokePredictions tag description - "Predictions is also a section inside the Trending tab (SmokeWalletPlatform); changes to Predictions views affect Trending." SmokeConfirmations: Required per SmokePredictions tag description - "opening/closing positions are on-chain transactions." Additionally, the changed hooks (usePredictBuyConditions, PredictPayWithAnyTokenInfo) directly use confirmation-related hooks from Performance Test Selection: |
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.
Reviewed by Cursor Bugbot for commit ea34d01. Configure here.
|




Description
This fixes Predict pay-with-any-token quote and CTA timing issues that could appear when users changed payment tokens.
The quote trigger previously deduped updates only by amount, so a new transaction or selected token using the same amount could skip
updatePendingAmount/updateTokenAmountCallbackand fail to start the quote request. This PR keys those emissions by transaction id, token address, and chain id so the same amount is still emitted when the active transaction or payment token changes.The Predict buy CTA could also remain enabled briefly while the payment selector was closing and before the new quote loading state appeared. This PR adds a Predict-only payment-selector navigation lock in
usePredictBuyConditions, disables the buy CTA/pay row immediately when the selector opens, and releases the lock one second after the screen regains focus.It also waits for account tokens before defaulting back to Predict balance, avoiding an early fallback while token data is still empty.
Finally, this keeps transaction-pay alert text visible in the Predict bottom-sheet flow, including while quote/pay-fee loading is in progress, and persists order-failed banners after the controller refreshes active order state, preventing alert/banner flicker.
When a pay-totals alert is returned with fee data, the displayed Total now still includes the deposit fee so users can see the actual amount required by the selected payment token.
Changelog
CHANGELOG entry: Fixed bugs that could prevent Predict pay-with-any-token quotes and alerts from refreshing correctly after changing payment tokens
Related issues
Fixes: PRED-882
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Touches Predict buy/payment gating, navigation timing, and error surfacing logic; issues could block order placement or hide critical alerts if the new lock/settling conditions misfire.
Overview
Predict pay-with-any-token quote/CTA timing is hardened. Adds a payment-selector navigation lock (with 1s delayed unlock + 5s safety timeout) and threads it through
PredictBuyWithAnyToken/usePredictBuyConditionsto disable the buy CTA andPredictPayWithRowimmediately while the selector is opening/closing.Quote settling and emissions are made token/tx-aware.
usePredictBuyConditionsnow treats settling as a token+chain+amount key (not just token address), andPredictPayWithAnyTokenInfodedupesupdatePendingAmount/updateTokenAmountbytransactionMeta.id + token address + chainIdso selecting a new token/tx with the same amount still re-triggers quotes.Error UX is refined for sheet mode.
usePredictBuyErrornow returnserrorMessageSource, prioritizes blocking pay-alert text (even while pay fees load), persistsorder_failedbanners across controller refreshes, and clears persisted banners on token change;PredictBuyWithAnyTokenconditionally suppresses only insufficient-balance helper text in Change Payment/Add Funds modes while keeping blocking pay alerts visible alongside banners.Default token and fee display behavior is adjusted.
usePredictDefaultPaymentTokenwaits for account tokens before falling back, andusePredictBuyInfoalways computesdepositFeefrompayTotals(including when pay alerts exist) without caching a “last accepted” fee during confirming.Reviewed by Cursor Bugbot for commit ea34d01. Bugbot is set up for automated code reviews on this repo. Configure here.