[pull] main from MetaMask:main#297
Merged
Merged
Conversation
## **Description** Fixed incorrect decimal precision for Entry price display on the PnL card and transaction details. **Problem:** Entry prices were using `PRICE_RANGES_MINIMAL_VIEW` (2 decimal places, fiat-style) instead of `PRICE_RANGES_UNIVERSAL` (5 significant digits, up to 6 decimals) that Mark prices use. This caused: - PUMP: Displayed "<$0.01" instead of actual value - ETH: Displayed "xxxx.60" instead of "xxxx.6" (trailing zero) - XRP: Displayed "$2.26" instead of "$2.2626" (insufficient precision) **Solution:** Changed Entry price formatting to use `PRICE_RANGES_UNIVERSAL` to match Mark price decimal logic, ensuring consistent precision across all price displays. ## **Changelog** CHANGELOG entry: Fixed Entry price decimal precision on PnL card to match Mark price formatting ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1976 ## **Manual testing steps** ```gherkin Feature: Entry price decimal consistency Scenario: user views PnL card for low-value asset (PUMP) Given user has an open position in PUMP When user navigates to the PnL hero card (Share your trade view) Then Entry price should display actual value with appropriate decimals And Entry price should match Mark price decimal formatting Scenario: user views PnL card for ETH Given user has an open position in ETH When user navigates to the PnL hero card Then Entry price should display "xxxx.6" without trailing zeros And Entry price should match Mark price decimal formatting Scenario: user views PnL card for XRP Given user has an open position in XRP When user navigates to the PnL hero card Then Entry price should display "$2.2626" with full precision And Entry price should match Mark price decimal formatting Scenario: user views transaction history Given user has closed positions When user views position transaction details Then Entry/Close price should display with universal decimal precision ``` ## **Screenshots/Recordings** ### **Before** PUMP: Entry shows "<$0.01" ETH: Entry shows "xxxx.60" (trailing zero) XRP: Entry shows "$2.26" (insufficient precision) ### **After** Entry prices now match Mark price formatting: - PUMP: Shows actual value (e.g., "$0.003889") - ETH: Shows "xxxx.6" (no trailing zero) - XRP: Shows "$2.2626" (full precision) https://github.com/user-attachments/assets/22528486-a079-41a3-abfa-1f344ef5dbb6 ## **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 (existing tests pass) - [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. --- ## **Technical Details** ### Files Modified: 1. `app/components/UI/Perps/Views/PerpsHeroCardView/PerpsHeroCardView.tsx:235` - Changed Entry price from `PRICE_RANGES_MINIMAL_VIEW` � `PRICE_RANGES_UNIVERSAL` 2. `app/components/UI/Perps/Views/PerpsTransactionsView/PerpsPositionTransactionView.tsx:107-109` - Added `PRICE_RANGES_UNIVERSAL` config to Entry/Close price formatting ### Verification: - � ESLint: No errors - � Prettier: Formatting correct - � Unit tests: All tests pass (21 tests for PerpsHeroCardView, 2 tests for PerpsPositionTransactionView) ### Reference Implementation: - `PerpsPositionCard.tsx` already uses `PRICE_RANGES_UNIVERSAL` (lines 414-417) - `PerpsTPSLView.tsx` already uses `PRICE_RANGES_UNIVERSAL` (lines 445-447) - Consistent with `fix/perps/decimal-consistency` branch work <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Switch Entry/Close price formatting to PRICE_RANGES_UNIVERSAL in PnL hero card and transaction details for consistent precision. > > - **Perps UI**: > - **PnL Hero Card (`PerpsHeroCardView.tsx`)**: Format `entryPrice` with `formatPerpsFiat(..., { ranges: `PRICE_RANGES_UNIVERSAL` })`. > - **Transaction Details (`PerpsPositionTransactionView.tsx`)**: Format Entry/Close price with `PRICE_RANGES_UNIVERSAL` for consistent decimal precision. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 1a13254. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## **Description** This PR fixes the missing MetaMask referral code display in the Perps PnL Hero Card (shareable card view). ### What is the reason for the change? Users who are opted into MetaMask Rewards and have a referral code were not seeing it displayed on the shareable PnL Hero Card when accessing Perps directly, even though the UI design and display logic were already implemented. The referral code would only appear if users had previously visited the Rewards section of the app. Issue: https://consensyssoftware.atlassian.net/browse/TAT-1981 ### What is the improvement/solution? The root cause was that the `useReferralDetails()` hook (which fetches the user's referral code from the backend) was only being called in Rewards components, not in the Perps Hero Card view. This meant: - ✅ User visits Rewards first → code loads → shows on Hero Card - ❌ User goes directly to Perps → code never fetched → missing from Hero Card **Fix implemented:** - Added `useReferralDetails()` hook to `PerpsHeroCardView.tsx` - The hook automatically fetches referral details when the Hero Card opens - Code gets stored in Redux and picked up by the existing UI (which was already implemented at lines 262-281) - No UI changes needed - the design with `RewardsReferralCodeTag` component was already there **Technical details:** - Only 2 lines added (import + hook call) - Uses existing `useReferralDetails` hook from Rewards - Leverages existing `selectReferralCode` Redux selector - Respects user opt-in status (only shows for opted-in users) ## **Changelog** CHANGELOG entry: Fixed missing MetaMask referral code display in Perps PnL shareable card for opted-in users ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1981 ## **Manual testing steps** ```gherkin Feature: Display referral code on Perps PnL Hero Card Scenario: User with referral code accesses PnL Hero Card directly Given user is opted into MetaMask Rewards And user has a referral code assigned (e.g., "MMCSI") And user has NOT visited the Rewards section yet in this session When user navigates to Perps tab And user opens an existing position And user taps the "Share" button to open PnL Hero Card Then the referral code should appear in the top-right corner of the shareable card And the referral code should display using the RewardsReferralCodeTag component And the referral code should be included when sharing the card Scenario: User without opt-in does not see referral code Given user has NOT opted into MetaMask Rewards And user does NOT have a referral code When user navigates to Perps tab And user opens an existing position And user taps the "Share" button to open PnL Hero Card Then no referral code should be displayed And the card should render normally without the referral section Scenario: Referral code persists across multiple card views Given user is opted into MetaMask Rewards And user has a referral code assigned When user opens PnL Hero Card for position A Then referral code should be displayed When user goes back and opens PnL Hero Card for position B Then referral code should still be displayed without refetching ``` ## **Screenshots/Recordings** ### **Before** Referral code missing from PnL Hero Card when accessing Perps directly (only appeared if user visited Rewards section first). ### **After** Referral code now displays correctly in top-right corner of PnL Hero Card for all opted-in users, regardless of navigation path. The design matches the provided mockup with referral code displayed as a tag (e.g., "MMCSI" or "BUDDHA" in the example). https://github.com/user-attachments/assets/2bd2b1fe-faa0-4051-b1b0-41064455a7e3 ## **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. --- ## Technical Implementation Details ### Files Modified **Single file changed:** - `app/components/UI/Perps/Views/PerpsHeroCardView/PerpsHeroCardView.tsx` - Added import: `useReferralDetails` hook from Rewards - Added hook call: `useReferralDetails()` to fetch referral code on component mount ### Code Changes **Lines added: 2** ```typescript // Import added at line 63 import { useReferralDetails } from '../../../Rewards/hooks/useReferralDetails'; // Hook call added at lines 91-92 // Fetch referral details to ensure code is available for display useReferralDetails(); ``` ### Why This Works 1. **Existing Infrastructure**: The UI for displaying referral codes was already implemented at lines 262-281 of the Hero Card 2. **Conditional Rendering**: Code already checks `rewardsReferralCode` and only displays if present 3. **Redux Integration**: `useReferralDetails()` fetches data and stores it via `setReferralDetails` action 4. **Automatic Updates**: The `useSelector(selectReferralCode)` hook automatically re-renders when data arrives 5. **Opt-in Respect**: Only displays for users who have opted into Rewards and have a referral code ### Data Flow ``` PerpsHeroCardView mounts ↓ useReferralDetails() called ↓ Fetches from RewardsController ↓ dispatch(setReferralDetails({ referralCode: "MMCSI" })) ↓ Redux state updated ↓ useSelector(selectReferralCode) re-renders ↓ RewardsReferralCodeTag component renders with code ``` ### Performance Impact - **Minimal**: Single API call on Hero Card mount (only if not already cached) - **Cached**: Data persists in Redux for the session - **No extra renders**: Component already had the selector, just needed the data ### Testing Verification ✅ ESLint passes - no linting errors ✅ TypeScript compilation - types are correct ✅ No breaking changes - purely additive ✅ Backward compatible - gracefully handles missing referral codes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Invoke `useReferralDetails()` in `PerpsHeroCardView` so referral code loads and displays (and is used in share message); update tests to mock the hook/design tokens. > > - **Perps PnL Hero Card (`PerpsHeroCardView.tsx`)**: > - Fetch referral details on mount by calling `useReferralDetails()` and importing the hook. > - Leverages existing `selectReferralCode` usage to display the referral tag and include code in share message. > - **Tests (`PerpsHeroCardView.test.tsx`)**: > - Mock `useReferralDetails` and add `brandColor` to design tokens mock. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5f70c40. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…esh (#21853) <!-- 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** Improve changelog management ## **Changelog** CHANGELOG entry: null ## **Related issues** INFRA-3031 Fixes: - Run `Update Release Changelog PR` only when release branch matches `release/x.y.z` ## **Manual testing steps** - Test release branch name `release/x.y.z` -> https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/18942043247/job/54083117562 - Test release branch name `release/x.y.z-Changelog` -> https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/18942263401/job/54083874574 - Test invalid branch name `release/test-branch` -> https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/18942308096/job/54084029210 - Test invalid branch, incomplete semver `release/x.y` -> https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/18942339330/job/54084135741 ## **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.
…1686) <!-- 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** In this PR, I've aligned the Import Wallet UI in the 'Add Wallet' flow with the existing 'Import SRP' onboarding design for consistency Jira Link: https://consensyssoftware.atlassian.net/browse/SL-238, https://consensyssoftware.atlassian.net/browse/SL-274, https://consensyssoftware.atlassian.net/browse/SL-275 BugFixes: https://consensyssoftware.atlassian.net/browse/SL-267 #15928 #15929 Figma Link: https://www.figma.com/design/pViOUcmjwhEzFsdrwknpNc/Onboarding?node-id=18161-80663&t=1c5E4QKtEnnYjijl-0 <!-- 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: Align Import Wallet UI in Add Wallet flow with Import SRP onboarding design for consistency. ## **Related issues** Fixes: 1) https://consensyssoftware.atlassian.net/browse/SL-267 2) #15928 3) #15929 ## **Manual testing steps** ```gherkin Feature: my feature name 1) Open the App. 2) Create a new wallet or import an existing one 3)On the home page, click "Add Wallet" from the account dropdown 4) Verify that the Import Wallet UI matches the design in the provided Figma link ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** https://www.figma.com/design/pViOUcmjwhEzFsdrwknpNc/Onboarding?node-id=18161-80216&t=1c5E4QKtEnnYjijl-0 <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/76e3db92-27c3-4b3a-9623-263347712a33 https://github.com/user-attachments/assets/da90b1a1-e077-47bc-ba3a-5fc032b4b6a2 <!-- [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] > Introduces a reusable `SrpInputGrid` with paste/clear, validation, and QR support, and refactors SRP import screens and navigation to use it with updated UI, tests, and locales. > > - **UI/Flows**: > - Refactor `ImportFromSecretRecoveryPhrase` and `ImportNewSecretRecoveryPhrase` to use new grid-based SRP input, with updated layout, navbar, and SafeArea handling. > - Disable/enable continue/import buttons based on SRP validity; show inline errors; add paste/clear affordances. > - **Components**: > - Add reusable `app/components/UI/SrpInputGrid` (styles, types, logic) supporting textarea→grid switch, keyboard navigation, word validation, and QR-filled input. > - Update `SrpInput` input style typings to `TextStyle`. > - **Navigation**: > - Update `ImportSRPView` stack to `mode="modal"`; add routes for `QRTabSwitcher` and `SeedphraseModal` with transparent card style. > - **Validation/Utils**: > - Add `app/util/srp/srpInputUtils` (lengths, space handling, word validation, helpers). > - **Tests**: > - Add unit snapshots for `SrpInputGrid`; expand tests for both import screens (paste/clear, QR, errors, keyboard/backspace, focus); update E2E selectors and page objects. > - **Localization**: > - Add/adjust strings for new import wallet copy, placeholders, and QR error messages. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6010425. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: ieow <4881057+ieow@users.noreply.github.com>
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 : )