Skip to content

fix(predict): fix query invalidation logic in usePredictToastRegistrations#27147

Merged
matallui merged 1 commit into
mainfrom
predict/fix-query-invalidation
Mar 6, 2026
Merged

fix(predict): fix query invalidation logic in usePredictToastRegistrations#27147
matallui merged 1 commit into
mainfrom
predict/fix-query-invalidation

Conversation

@matallui
Copy link
Copy Markdown
Contributor

@matallui matallui commented Mar 6, 2026

Description

Deposit and withdraw toast handlers were incorrectly invalidating positions and activity queries, causing unnecessary refetches. This change scopes those invalidations to only the claim type, where they are actually relevant. Balance and unrealized PnL queries remain invalidated for all types.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Predict query invalidations

  Scenario: Deposit completes without refetching positions/activity
    Given the user has a pending deposit transaction

    When the deposit transaction is confirmed
    Then balance and unrealized PnL queries are invalidated
    And positions and activity queries are NOT invalidated

  Scenario: Claim completes and refetches all relevant data
    Given the user has a pending claim transaction

    When the claim transaction is confirmed
    Then balance, unrealized PnL, positions, and activity queries are all invalidated

Screenshots/Recordings

Before

After

Pre-merge author checklist

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

Low Risk
Low-risk change limited to React Query cache invalidation; it only reduces unnecessary refetches after deposit/withdraw confirmations and should not affect transaction execution.

Overview
Fixes usePredictToastRegistrations query invalidation so on confirmed transactions it always invalidates balance and unrealizedPnL, but only invalidates positions and activity when the transaction type is claim.

This prevents deposit/withdraw toast flows from triggering unnecessary positions/activity refetches while keeping claim-related data refresh behavior intact.

Written by Cursor Bugbot for commit e157a2e. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

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.

@metamaskbot metamaskbot added the team-predict Predict team label Mar 6, 2026
@github-actions github-actions Bot added the size-S label Mar 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePredict
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The change modifies usePredictToastRegistrations.tsx, a hook that handles toast notifications and query invalidation for Predict (Polymarket) transactions. The specific change alters the query invalidation logic:

  1. Previously, when any transaction (deposit, withdraw, claim) was confirmed, the code invalidated balance, unrealizedPnL, activity, and positions queries.
  2. Now, positions and activity queries are only invalidated for 'claim' transactions, not for deposit/withdraw.
  3. This is a behavioral optimization - deposit/withdraw transactions don't need to refresh positions/activity data.

Tag Selection Rationale:

  • SmokePredictions: Primary tag - directly affects Predict transaction handling (deposit, withdraw, claim flows), balance synchronization, and the Positions/Activities tabs.
  • SmokeWalletPlatform: Per tag description, "Predictions is also a section inside the Trending tab (SmokeWalletPlatform); changes to Predictions views affect Trending."
  • SmokeConfirmations: Per SmokePredictions description, "opening/closing positions are on-chain transactions" that require confirmations. The claim flow involves on-chain transactions.

The change is medium risk because it modifies data refresh behavior that could affect user experience if positions/activity don't update correctly after claim transactions, but it's a targeted optimization that should improve performance by reducing unnecessary query invalidations.

Performance Test Selection:
The change modifies query invalidation logic for Predict transactions, which directly affects how and when data is refreshed in the Predict feature. While this is an optimization (reducing unnecessary invalidations for deposit/withdraw), it's worth running performance tests to verify the change doesn't negatively impact the Predict market loading, position management, or balance display performance. The @PerformancePredict tag covers prediction market list loading, market details, deposit flows, and balance display - all relevant to this change.

View GitHub Actions results

@matallui matallui marked this pull request as ready for review March 6, 2026 19:27
@matallui matallui requested a review from a team as a code owner March 6, 2026 19:27
Copy link
Copy Markdown
Contributor

@caieu caieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matallui matallui enabled auto-merge March 6, 2026 19:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

E2E Fixture Validation — Schema is up to date
7 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 6, 2026

@matallui matallui added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 96b7054 Mar 6, 2026
195 of 197 checks passed
@matallui matallui deleted the predict/fix-query-invalidation branch March 6, 2026 20:35
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-S team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants