[pull] main from MetaMask:main#441
Merged
Merged
Conversation
<!-- 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** fixes an issue where flipping source/dest assets do not update balances when user has zero balance on non-evm chains <!-- 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: fixes an issue where flipping source/dest assets do not update balances when user has zero balance on non-evm chains ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3696 ## **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** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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** - [ ] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Improves `useLatestBalance` behavior for non‑EVM and token switching scenarios. > > - Resets balance state when `token.address` changes to avoid stale UI; returns cached balance immediately while fetching new data > - For non‑EVM chains, uses controller data and sets balance to `0` when token not found or balance is empty/undefined > - Expands effect deps to include previous/current token address > - Adds comprehensive tests covering address flips, non‑EVM fallbacks, zero/invalid balances, and race conditions > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 330d2db. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…#24169) This PR addresses HyperLiquid API rejections that occur when TP/SL prices exceed 5 significant figures. **Problem:** - HyperLiquid API rejects orders with prices containing more than 5 significant figures - Users could type prices with excessive precision that would fail on submission - RoE percentage calculations could produce prices exceeding the limit **Solution:** 1. Added input validation to prevent users from typing more than 5 significant figures in TP/SL price fields 2. Added rounding logic when prices are calculated from RoE percentages to ensure they stay within limits 3. Added `MAX_SIGNIFICANT_FIGURES` constant for centralized configuration 4. Fixed TP/SL price display in position cards to use consistent formatting (`PRICE_RANGES_UNIVERSAL`) **Technical changes:** - Added three new utility functions: `countSignificantFigures`, `hasExceededSignificantFigures`, `roundToSignificantFigures` - Fixed regex bug in `countSignificantFigures` that incorrectly handled negative numbers (`/^-?0+/` → `/^-?0*/`) - Added comprehensive unit tests for the new validation utilities ## **Changelog** CHANGELOG entry: Fixed TP/SL price input validation to respect HyperLiquid's 5 significant figure limit ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2063 ## **Manual testing steps** ```gherkin Feature: TP/SL significant figure validation Scenario: user cannot type more than 5 significant figures Given user has an open perps position And user opens the TP/SL form When user types "123.45" in the Take Profit price field Then the input accepts the value (5 sig figs) When user tries to type "123.456" in the Take Profit price field Then the input blocks the 6th significant figure Scenario: RoE percentage calculation rounds to 5 significant figures Given user has an open perps position And user opens the TP/SL form When user enters a RoE percentage that would calculate to "123.456789" Then the price field displays the value rounded to 5 significant figures ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** User was able to enter more decimals than supported ### **After** https://github.com/user-attachments/assets/9c563850-dcfd-4880-934d-5e0efd6953be ## **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** - [ ] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Ensures TP/SL prices comply with HyperLiquid’s 5 significant-figure rule and aligns formatting across UI and adapters. > > - Introduces `DECIMAL_PRECISION_CONFIG.MAX_SIGNIFICANT_FIGURES` and shared utils: `countSignificantFigures`, `hasExceededSignificantFigures`, `roundToSignificantFigures` > - Updates `usePerpsTPSLForm` to prevent typing beyond 5 sig figs and round prices derived from RoE inputs/buttons; maintains bidirectional sync without interfering while fields are focused > - Switches TP/SL display in `PerpsPositionCard` to `PRICE_RANGES_UNIVERSAL` for consistent price formatting > - Refactors `formatHyperLiquidPrice` in `hyperLiquidAdapter` to use shared significant-figure rounding logic > - Adds comprehensive unit tests for formatting/validation and adjusts existing tests to match new rounding behavior > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 59a6a65. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Nick Gambino <35090461+gambinish@users.noreply.github.com>
<!--
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:
## **Related issues**
Fixes:
## **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**
- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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**
- [ ] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Bootstraps an Appwright e2e flow for `@metamask/sdk-connect`
connecting a dapp via mobile browser and deeplink.
>
> - Adds `appwright/tests/mm-connect/connection.spec.js` to launch
browser, navigate to `Multichain Test Dapp`, initiate connect, switch to
MetaMask via deeplink, approve, and assert connection
> - Introduces utilities and screen objects:
`utils/flows/MobileBrowser.js`, `wdio/screen-objects/MobileBrowser.js`,
`wdio/screen-objects/Modals/DappConnectionModal.js`,
`wdio/screen-objects/MultiChainTestDapp.js`,
`wdio/screen-objects/Native/Android.js`
> - Extends `appwright.config.ts` with `mm-connect` projects for
Android/iOS on BrowserStack and local emulators (includes demo
`buildPath` for iOS BS)
> - Adds npm script `run-appwright:mm-connect-android-local` to execute
the local Android `mm-connect` project
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
886004f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Curtis David <Curtis.David7@gmail.com>
<!--
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?
-->
- Prevent E2E tests from hanging for 30 minutes after test timeouts
- Add diagnostic logging for open handles in CI
## Problem
E2E tests that timeout (5 minutes) cause the entire workflow to hang for
30 minutes because Jest waits indefinitely for open handles (sockets,
timers) to close. The test results are already determined, but Jest
never exits.
Example from logs:
Test Suites: 1 failed, 5 passed, 6 total
Tests: 1 failed, 9 passed, 10 total
...
Jest did not exit one second after the test run has completed.
'This usually means that there are asynchronous operations that weren't
stopped in your tests.
Then the workflow times out 25 minutes later.
## Solution
Add `forceExit` and `detectOpenHandles` Jest flags in CI only:
- `forceExit`: Forces Jest to exit after all tests complete, even with
open handles
- `detectOpenHandles`: Logs what's keeping Jest open (helps identify
cleanup issues)
These flags only apply in CI (`process.env.CI`), so local development is
unaffected.
## **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:
## **Related issues**
Fixes:
## **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
- [ ] I’ve included tests if applicable
- [ ] 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**
- [ ] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Ensures CI E2E runs terminate promptly and provide diagnostics for
lingering async handles.
>
> - In `.detoxrc.js`, adds CI-only Jest args in `testRunner.args`:
`forceExit: true` and `detectOpenHandles: true`
> - Commented to clarify CI-only behavior; local development remains
unchanged
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
947ee0b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )