Skip to content

Commit 1d4bd68

Browse files
authored
fix: 25144 QR code popup constantly in explorer screen due to predictions require typed sign to connect. cp-7.63.0 (#25334)
This PR will fix #25144 which constantly popup QR signing transaction. ### Root clause The cause of this issue is little bit complicate, The issue is that the Explorer/Trending tab has a Perps section that automatically initializes when the tab is clicked. This initialization: 1. Creates a wallet adapter (createWalletAdapter() in HyperLiquidWalletService.ts) 2. Prepares signing methods that require hardware wallet interaction 3. Monitors account changes via Redux subscription in PerpsConnectionManager.ts (lines 81-163) 4. Repeatedly reconnects when account changes are detected, creating new wallet adapters each time The whole flow like below ``` Explorer Tab Click → PerpsSection renders (sections.config.tsx) → usePerpsMarkets() hook → streamManager.marketData.subscribe() → PerpsConnectionManager.connect() → setupStateMonitoring() - subscribes to Redux → reconnectWithNewContext() on account change → createWalletAdapter() → signTypedData method created → QR POPUP TRIGGERED (for hardware wallets) ``` ### solution implement global signing cache for DEX abstraction and referral setup - Introduces a global singleton cache to manage signing operations for DEX abstraction, builder fee approval, and referral code setup, preventing repeated signing requests across provider reconnections. - Updates `HyperLiquidProvider` to utilize the new cache for checking and setting DEX abstraction status, ensuring critical operations for hardware wallets are streamlined. - Adds methods in `PerpsConnectionManager` to clear cache entries, enhancing debugging and user experience after signature rejections. - Refactors existing logic to improve handling of concurrent signing attempts and cache state management. This change enhances the user experience by reducing unnecessary signing prompts and improving the efficiency of the DEX abstraction process. <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: implement global signing cache for DEX abstraction and referral setup to fix the issue #25144 ## **Related issues** Fixes: #25144 ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes when and how perps signing operations (DEX abstraction, builder fee, referral) are triggered, and adds a global cache/lock to suppress retries across reconnections; mistakes could block trading setup or incorrectly skip required signatures. > > **Overview** > Introduces a new global singleton `TradingReadinessCache`/`PerpsSigningCache` to persist per-user/per-network signing state and coordinate *in-flight* signing operations across provider reconnections. > > Refactors `HyperLiquidProvider` to **defer all signature-requiring setup** out of `ensureReady()` into a new `ensureReadyForTrading()` (used by `placeOrder`, cancels, closes, TP/SL updates), and updates DEX abstraction, builder-fee approval, and referral setup to consult/cache results (including failures) and wait on global in-flight locks to avoid repeated hardware-wallet prompts. > > Adds `PerpsConnectionManager` APIs to clear DEX abstraction cache for a user or clear all signing cache, and expands/updates tests to cover the new cache behavior and the now non-blocking builder-fee failure behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e147571. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent de0997f commit 1d4bd68

6 files changed

Lines changed: 2148 additions & 161 deletions

File tree

0 commit comments

Comments
 (0)