Skip to content

fix(predict): prevent pay token alert flicker#30108

Merged
pedronfigueiredo merged 1 commit into
mainfrom
pnf/route-not-available
May 15, 2026
Merged

fix(predict): prevent pay token alert flicker#30108
pedronfigueiredo merged 1 commit into
mainfrom
pnf/route-not-available

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented May 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a Predict pay-with-any-token alert flicker where a blocking pay-token alert could briefly take precedence while payment quotes/totals were still settling.

Problem:

  • Predict can have a valid external payment token selected while the Transaction Pay quote state is still catching up to the latest amount.
  • During that settling window, blockingPayAlertMessage could be treated as ready and suppress the active order banner / surface an insufficient-funds style message too early.
  • The payment settling key also used the raw total amount, making it more sensitive than the user-facing quote amount needs to be.

Fix:

  • Normalize the payment settling key amount by rounding the required quote amount up to two decimals.
  • Pass isPaySystemSettling into usePredictBuyError.
  • Prevent blocking pay-token alerts from taking precedence while the pay system is still settling.
  • Add focused hook coverage for settling-time pay-alert suppression.

Changelog

CHANGELOG entry: Fixed a bug that caused Predict pay-with-any-token alerts to flicker while quotes were loading

Related issues

https://consensyssoftware.atlassian.net/browse/CONF-1345

Manual testing steps

Feature: Predict pay with any token

  Scenario: user changes the Predict order amount while paying with a token
    Given the user is on a Predict market buy flow
    And the user has selected a pay-with-any-token payment token
    When the user changes the order amount
    Then the pay-token alert does not flicker while the new quote is loading
    And the correct blocking alert is shown only after the quote/totals state has settled

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches Predict pay-with-any-token settling and error-surfacing logic, which could change when users see blocking balance alerts vs. order failure banners during quote updates.

Overview
Prevents blocking pay-token balance alerts from flickering/overriding active-order error banners while the Transaction Pay system is still settling after token/amount changes.

Normalizes the pay-system “settling key” by rounding the tracked quote amount up to 2 decimals, and threads isPaySystemSettling into usePredictBuyError so pay alerts are suppressed until settling completes. Adds a focused unit test to cover settling-time suppression behavior.

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

@pedronfigueiredo pedronfigueiredo self-assigned this May 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 13, 2026
@metamaskbotv2 metamaskbotv2 Bot added the team-confirmations Push issues to confirmations team label May 13, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/route-not-available branch from b2f92a2 to 1878e1d Compare May 14, 2026 09:30
@github-actions github-actions Bot added size-S and removed size-M labels May 14, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/route-not-available branch from 1878e1d to d189f4d Compare May 14, 2026 09:34
@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review May 14, 2026 09:46
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner May 14, 2026 09:46
@pedronfigueiredo pedronfigueiredo removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are scoped to the Predict (Polymarket) feature's PredictBuyWithAnyToken component and its hooks:

  1. usePredictBuyError.ts: Adds isPaySystemSettling parameter that suppresses blocking pay alert messages when the payment system is settling. This affects error display logic in multiple places within the hook.

  2. usePredictBuyConditions.ts: Fixes quote amount calculation by rounding to 2 decimal places using BigNumber, and falls back to currentValue when totalPayForPredictBalance is falsy.

  3. PredictBuyWithAnyToken.tsx: Passes the new isPaySystemSettling prop to usePredictBuyError.

  4. usePredictBuyError.test.ts: Adds test coverage for the new settling suppression behavior.

These changes affect the Predict buy flow - specifically error handling and quote amount precision. The risk is medium as it changes user-facing behavior in the prediction market buy flow.

Tag selection rationale:

  • SmokePredictions: Directly affected - the buy flow for prediction markets is modified
  • SmokeWalletPlatform: Required by SmokePredictions description (Predictions is a section inside Trending tab)
  • SmokeConfirmations: Required by SmokePredictions description (opening/closing positions are on-chain transactions)

No other tags are needed as the changes don't touch swap infrastructure, network management, accounts, or other unrelated features.

Performance Test Selection:
The changes are conditional logic modifications in React hooks (error suppression and quote rounding). These are not performance-sensitive operations - they don't affect rendering performance, list rendering, data loading patterns, or app initialization. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 51ee6aa May 15, 2026
158 of 159 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/route-not-available branch May 15, 2026 13:23
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-S team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants