[pull] main from MetaMask:main#324
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**
<!--
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]
> Raise iOS JS bundle size check threshold in CI from 45 to 50.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ef99dc2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
- fix(card): delegation issues (#22058) <!-- 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? --> This PR addresses several issues affecting the Card experience, ensuring proper asset display, navigation flow, and data consistency across components. Fixes - Fixed an issue where assets were not loading correctly after opening the Card Home screen. - Corrected balance handling on the Change Asset Bottom Sheet — it now displays `availableBalance` for enabled tokens and the user’s total balance for disabled ones. - Restored asset icons on all asset-related bottom sheets. - Fixed incorrect titles on the Spending Limit screen: - Selecting a token that isn’t enabled now correctly shows “Change token and network.” - Pressing “Manage spending limit” on Card Home now correctly shows “Enable token.” - Resolved concurrency issues caused by promise caching in the `useLoadCardData` hook. ## **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: Fixed issue where assets failed to load after opening the Card Home screen. CHANGELOG entry: Fixed balance display on the Change Asset Bottom Sheet to correctly show availableBalance for enabled tokens and user balance for disabled tokens. CHANGELOG entry: Restored missing asset icons on asset bottom sheets. CHANGELOG entry: Fixed incorrect Spending Limit title when selecting a token that’s not enabled (now shows “Change token and network”). CHANGELOG entry: Fixed incorrect Spending Limit title when pressing “Manage spending limit” on Card Home (now shows “Enable token”). CHANGELOG entry: Resolved concurrency and caching issues in useLoadCardData hook. ## **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 - [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] > Improve Card balances and UX (pull-to-refresh, spending limit progress), refactor delegation flow with confirmation and caching, enhance asset selection and data fetching with cache/timeout, and clear caches on logout/auth errors. > > - **Card Home UI**: > - Replace `useAssetBalance` with batched `useAssetBalances` and update balance fallbacks. > - Add pull‑to‑refresh, spending limit progress bar, and close‑limit warning with actions. > - Improve navigation for managing spending limit; hide Solana-specific options; show error toast on enable failure. > - **Spending Limit**: > - Refactor delegation flow: SIWE signing, tx confirmation wait, cache clearing, success/error toasts, navigation blocking; add `UserCancelledError`. > - **Asset Selection Bottom Sheet**: > - Use `useAssetBalances` for fiat/token balances and icons; filter/sort tokens; priority update with cache invalidation; Solana footer link. > - **Data Fetching & Caching**: > - Add `useGetDelegationSettings` and `useGetCardExternalWalletDetails` with caching and timeouts. > - Fix `useLoadCardData` concurrency; add `fetchAllData`/`refetchAllData` and authenticated data wiring. > - Clear all card caches on auth errors/logout. > - **SDK/Utils**: > - Simplify ethers provider usage; remove unused network mapper; add `mapCaipChainIdToChainName` and safer chainId utils. > - **Copy/UX**: > - Update warning dismiss label; add `enable_card_error` locale. > - **Tests**: > - Add/expand comprehensive unit/integration tests and snapshots across new hooks, components, and flows. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 69808b6. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [0b3c740](0b3c740) Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com> Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>
- fix(card): Onboarding UI issues (#22140) <!-- 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? --> This PR addresses several UI and stability issues to improve the Card onboarding and home experience on Android devices. Fixes - Fixed screen layout being cut off on Android devices with a notch. - Fixed keyboard overlapping input fields on Android, preventing users from typing. - Resolved concurrency issue causing warnings on the Card Home screen. ## **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: Fixed layout issue where the screen was cut off on Android devices with a notch. CHANGELOG entry: Fixed keyboard overlapping input fields on Android devices. CHANGELOG entry: Resolved concurrency issue causing warnings on the Card Home screen. ## **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 - [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] > Improves Android-safe onboarding layout and keyboard behavior, splits consent into create/link with Redux tracking, enhances KYC WebView, updates SIWE expiration, and tweaks card data warning priority with tests. > > - **Onboarding UI (Android)**: > - Wrap `OnboardingStep` and `KYCWebview` in `SafeAreaView`; enable `KeyboardAwareScrollView` (Android auto scroll, extra height) to prevent cut-offs/overlaps. > - `KYCWebview` adds media/storage/geolocation settings and loading state. > - **Consent Flow**: > - Split consent into `createOnboardingConsent` and `linkUserToConsent` in `useRegisterUserConsent`. > - Wire into `PhysicalAddress` (create, store `consentSetId`, link on completion) and `MailingAddress` (link on completion when token present). > - **Redux**: > - Add `onboarding.consentSetId` state, selectors, and actions (`setConsentSetId`); reset path updated. > - **Hooks**: > - `useCardDelegation`: extend SIWE message expiration to 2 minutes. > - `useLoadCardData`: prioritize `CardWarning.NoCard` in warnings. > - **Tests**: > - Update/expand unit tests across onboarding components and consent hook to cover new flow, Android layout handling, and Redux changes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 11f9eca. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [ac65f6a](ac65f6a) Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com>
…KYC webview on Android (#22238) - fix(card): add temporary fix for crashing KYC webview on Android (#22200) <!-- 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? --> This PR introduces a temporary workaround for the Android KYC verification flow. Instead of launching the embedded WebView during the Card onboarding process, it now opens the user’s native browser. The change addresses a crash caused by MetaMask’s custom WebView library, which fails under this specific KYC scenario. Additionally, this PR adds a confirmation alert when the user attempts to close the KYC page, improving user experience and preventing accidental exits. ## **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: Android crash during KYC verification caused by the custom WebView implementation. CHANGELOG entry: KYC verification flow now opens in the native browser instead of an embedded view. CHANGELOG entry: Confirmation alert when closing the KYC verification page. ## **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 - [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] > Routes Android KYC to the native browser (then `VALIDATING_KYC`) while iOS continues using WebView, and adds a confirmation alert before closing the KYC WebView; updates navigator, tests, and i18n. > > - **Card Onboarding (Verify Identity)**: > - Android: `Linking.openURL(sessionUrl)` then navigate to `Routes.CARD.ONBOARDING.VALIDATING_KYC`. > - iOS: Navigate to `Routes.CARD.ONBOARDING.WEBVIEW` with `url`. > - **Navigation Header (KYC WebView)**: > - New `KYCModalNavigationOptions`: shows alert on close with cancel/destructive actions; destructive navigates to `VALIDATING_KYC`. > - Renames/exports `KYCModalNavigationOptions` and wires it to `WEBVIEW` screen. > - **Tests**: > - Split platform-specific behaviors; assert Android `openURL` call and navigation order; ensure iOS does not call `openURL`. > - Add tests for header close alert buttons, title, and icon props. > - **i18n**: > - Add `card.card_onboarding.kyc_webview.*` strings (close-confirmation title/message/buttons). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 1a75b77. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [8a2dd25](8a2dd25) Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com> Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>
…eERC20Allowance handler (#22230) <!-- 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** Patching MetaMask/core#6994 into `@metamask/bridge-controller` to improve USDT swap/bridge tx success rates <!-- 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: fix: remove selected network reference from bridge getBridgeERC20Allowance handler ## **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] > Switches `getBridgeERC20Allowance` to use the network client for the provided `chainId`, adds a helper to fetch it, and wires the patched `@metamask/bridge-controller` dependency. > > - **Bridge Controller (`dist/bridge-controller.cjs`)**: > - `getBridgeERC20Allowance`: use provider from `getNetworkClientByChainId(chainId)` instead of selected network. > - Add `#getNetworkClientByChainId` helper: looks up client ID via `NetworkController:findNetworkClientIdByChainId` and retrieves client; use `messagingSystem` API. > - Minor whitespace cleanup in `fetchQuotes` call. > - **Dependencies**: > - Switch `@metamask/bridge-controller@50.0.0` to a Yarn patch (adds above changes); update `yarn.lock` accordingly. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 87b3583. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>
- fix: Android In-App Browser Crash (#22212) <!-- 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** The app crashes on Android when users grant **camera + microphone** permissions through the in-app browser (e.g., visiting https://permission.site/). Root Cause: The WebView permission handling code had a fundamental architectural flaw when multiple permissions (camera + microphone) were requested simultaneously: Old behavior: Showed separate dialogs for each permission (one for camera, one for microphone) Each dialog's "Allow" button independently called request.grant() Android's WebView API only allows calling grant() or deny() once per permission request When the user clicked "Allow" on the second dialog → CRASH: "Either grant() or deny() has been already called" Solution: Rewrote the permission handling logic in RNCWebChromeClient.java: Changed permission handling to show ONE dialog for all permissions: - "Allow example.com to use your camera and microphone?" - Call grant() only once with all permissions together - Added error handling to prevent crashes in edge cases Android build for this PR: https://app.bitrise.io/build/560c02e8-611e-4bfd-a24c-34e69751c86b?tab=artifacts PR to browser: MetaMask/react-native-webview-mm#72 ## **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:null ## **Related issues** Fixes: #22162 ## **Manual testing steps** ```gherkin Feature: Fix Android double permission bug on webview Scenario: App does not crash when user grant/deny camera + microphone permission Given user navigates to website https://permission.site in website When user select Camera + Microphone Then user is able give/deny permission to Camera and Microphone without app crashing ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** Android Before  ### **After** Android 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] > Aggregates Android WebView camera/microphone permission flows into a single confirmation and safely grants once, wired via a Yarn patch to @metamask/react-native-webview. > > - **Android WebView permissions**: > - Reset state at request start and consolidate multiple permission prompts into a single dialog (e.g., camera and microphone). > - Map OS-level permissions to WebView resources and grant once (with try/catch) to avoid IllegalStateException. > - Request missing system permissions as needed; clean up `grantedPermissions`/`permissionRequest` consistently. > - **Tooling/Deps**: > - Switch `@metamask/react-native-webview@14.5.0` to a Yarn patch via `.yarn/patches/@metamask-react-native-webview-*.patch` and update `yarn.lock`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 712412c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com> [5c63946](5c63946) Co-authored-by: Wei Sun <wei.sun@consensys.net> Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
… issues (#22268) - refactor(card): sonarcloud maintainability issues (#22221) <!-- 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? --> This PR addresses several maintainability issues reported by SonarCloud: 🔗 [View related issues on SonarCloud](https://sonarcloud.io/project/issues?id=metamask-mobile&pullRequest=22058&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true) Additionally, it reverts a temporary workaround previously added for Android to prevent a crash occurring when users navigated through the KYC WebView. The root cause of the WebView crash has been resolved in a separate PR, making the temporary fix unnecessary. ## **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: Reverted temporary workaround for KYC WebView crash (issue resolved in upstream fix). ## **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 - [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] > Unifies KYC to in-app WebView, refactors asset selection and balance/allowance calculations, tightens onboarding routing, enhances SDK logging, and adds extensive tests. > > - **KYC/Onboarding**: > - Route: `OnboardingNavigator` now requires `user.countryOfNationality` before address; adds tests for new routing paths. > - Verify: `VerifyIdentity` always navigates to `CARD.ONBOARDING.WEBVIEW`; removes platform-specific browser logic; updates tests. > - **Asset Selection** (`AssetSelectionBottomSheet.tsx`): > - Extracts helpers for Linea chain filtering, network processing, token mapping/deduping, address resolution, and sorting. > - Filters by user location and optionally hides Solana; treats `Limited` as delegated for priority updates. > - Refactors list rendering via `renderBottomSheetContent`; preserves `allowanceState` when updating priority. > - **Balances/Allowances** (`useAssetBalances.tsx`): > - Adds helpers for balance source selection, Solana/EVM fiat calc, proportional fiat fallback, and asset building. > - Normalizes parsing/formatting and returns richer balance info; large test suite added covering edge cases. > - **Card Home** (`CardHome.tsx`): > - `enableCardAction` logs errors and shows toast; fetches token and opens selection when provisioned. > - Tests added for enable flow button states and interactions. > - **External Wallet/Priority Token**: > - `useGetCardExternalWalletDetails`: factors allowance-state calc; maps totals safely. > - `useGetPriorityCardToken`: minor robustness (nullish coalescing, warning flow); more tests. > - **SDK** (`CardSDK.ts`): > - Improves error logging/handling across wallet details and provisioning; minor code cleanup. > - **Types**: > - `UserResponse` adds `countryOfNationality`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 1e1b50b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [a2bee21](a2bee21) Co-authored-by: Bruno Nascimento <brunonascimentodev@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?
-->
## **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]
> Update CHANGELOG with 7.58.1 fixes/refactor and add the 7.58.1 compare
link.
>
> - **Changelog (`CHANGELOG.md`)**:
> - **7.58.1** release notes added:
> - **Fixed**: Android in-app browser crash; KYC webview crash on
Android; onboarding UI issues; card delegation issues; remove selected
network reference from bridge `getBridgeERC20Allowance` handler.
> - **Changed**: Card refactor to address SonarCloud maintainability
issues.
> - Add compare link reference for `7.58.1`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
82dc3bf. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Runway bumped your version to 7.58.2 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Bumps app version to 7.58.2 across Android, iOS, CI, and package.json. > > - **Version bump to `7.58.2`** > - **Android**: Update `versionName` in `android/app/build.gradle`. > - **iOS**: Update `MARKETING_VERSION` across targets in `ios/MetaMask.xcodeproj/project.pbxproj`. > - **CI**: Update `VERSION_NAME` and `FLASK_VERSION_NAME` in `bitrise.yml`. > - **Repo**: Update `version` in `package.json`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 99edfab. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: runway-github[bot] <73448015+runway-github[bot]@users.noreply.github.com>
The purpose of this task is to fix the `yarn audi:ci` issues that popped up for `react-native-community/cli` packages due to a recent vulnerability related to bash commands being executed from within that package <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds `npmAuditIgnoreAdvisories: [1109627]` to `.yarnrc.yml` to temporarily suppress `@react-native-community/cli` audit failures and unblock CI. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 65be265. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Luis Taniça <matallui@gmail.com>
…lation with funding fees and live data (#22344) fix: cp-7.59.0 hotfix-7.58.2 update close position calculation with funding fees and live data (#22229) <!-- 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 bug where close position view showed incorrect receive amounts, sometimes displaying negative values when position value had dropped. Root causes: 1. Used stale position data from route params instead of live WebSocket updates 2. HyperLiquid's marginUsed already includes PnL, but code was double-counting 3. Recalculated PnL from prices, which missed accumulated funding fees 4. Timing mismatch between price updates and position updates Changes: - Add usePerpsLivePositions to subscribe to real-time position data - Use livePosition.marginUsed which already includes accumulated PnL and funding fees - Use livePosition.positionValue for fee calculations to keep margin and fees synchronized - Remove effectivePnL recalculation that missed funding fees - Round margin and fees separately before subtraction for transparent calculation - Update tests to reflect that marginUsed includes PnL from HyperLiquid Result: - Position card and close position view now show matching margin values - Funding fees correctly included in all calculations - No more incorrect negative receive amounts - Calculation transparency: displayed margin - displayed fees = displayed receive amount <!-- 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: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1956 ## **Manual testing steps** ```gherkin Feature: Close Position Calculation with Funding Fees Scenario: Close position with accumulated funding fees shows correct receive amount Given I have an open position with the following details: | Coin | ETH | | Margin Used | $100 | | Unrealized PnL| -$5 | | Entry Price | $2000 | | Current Price | $2000 | When I navigate to the close position view And I view the close position summary Then the margin displayed should be "$100" And the receive amount should match "margin - fees" And the receive amount should be positive And the receive amount should not be negative or zero Scenario: Receive amount calculation matches visual breakdown Given I have an open position When I view the close position summary Then the displayed margin should be rounded to 2 decimals And the displayed fees should be rounded to 2 decimals And the receive amount should equal "rounded margin minus rounded fees" And the calculation should be transparent to the user ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/29289663-7b77-45f7-8ff6-c48917e1e21a <!-- [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** - [ ] 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] > Update close position logic to use live position data (including funding fees) and compute receive amount as rounded margin portion minus rounded fees, with extensive test coverage and price-sync behavior. > > - **PerpsClosePositionView (`PerpsClosePositionView.tsx`)**: > - Integrates `usePerpsLivePositions`; derives `livePosition` and uses `marginUsed` and `unrealizedPnl` for calculations and tracking. > - Computes `positionValue` from limit price when set, else current price; for market orders `effectivePnL` uses live `pnl`; for limit orders derives PnL from limit/current price vs entry. > - Replaces receive calculation with `receiveAmount = round(close% × marginUsed) − round(totalFee)`; updates summary UI to display `(close% × marginUsed)` and “includes PnL”. > - Back-calculates `unrealizedPnlPercent` from `marginUsed − pnl`; initializes USD amount once; improves input focus and syncing behavior; passes `livePosition` to `handleClosePosition`. > - **Tests (`PerpsClosePositionView.test.tsx`)**: > - Mocks `usePerpsLivePositions` and updates expectations to reflect `marginUsed` includes PnL and new receive logic. > - Adds price update synchronization cases (live price changes, input sync, editing protection) and limit-order calculations. > - Removes reliance on market szDecimals; broadens interaction, validation, rewards, and tooltip coverage; updates confirm handler assertions. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 51cf3cc. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: abretonc7s <107169956+abretonc7s@users.noreply.github.com> Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>
…egation (#22433) - fix(card): UI issues on Authentication/Delegation (#22352) <!-- 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? --> This PR fixes several issues affecting the Card feature to improve stability and UI consistency: - Fixed negative allowance values displayed on CardHome - Fixed token priority not updating correctly after delegation - Fixed text clipping in the Asset BottomSheet - Ensured all addresses are properly checksummed - Fixed BottomSheet layering issue where it appeared below the header ## **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: Negative allowance values displayed on CardHome CHANGELOG entry: Token priority not updating after delegation CHANGELOG entry: Text clipping in Asset BottomSheet CHANGELOG entry: Missing address checksum formatting CHANGELOG entry: BottomSheet not appearing above header ## **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 - [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] > Refactors Card flows: adds modal navigation for Add Funds/Asset Selection, improves OTP error UX, introduces latest allowance fetching for accurate spending limits, and updates priority handling and balances with extensive test coverage. > > - **Navigation/Modals**: > - Add `CardModals` stack and navigate to `CardAddFundsModal` and `CardAssetSelectionModal` from `CardHome` and `SpendingLimit`. > - `AddFundsBottomSheet` and `AssetSelectionBottomSheet` refactored to read params via `useParams` and close via `BottomSheet` controller. > - **Spending Limit**: > - New `useGetLatestAllowanceForPriorityToken` hook + SDK `getLatestAllowanceFromLogs` to derive `totalAllowance` from approval logs; integrated in `useLoadCardData` and `CardHome`. > - Hide progress/warnings for unsupported tokens via `SPENDING_LIMIT_UNSUPPORTED_TOKENS`; `SpendingLimitProgressBar` gets `isLoading` skeleton. > - **Delegation/Priority**: > - New `useUpdateTokenPriority` used by `SpendingLimit` and `AssetSelectionBottomSheet` to update wallet priorities and invalidate cache. > - `useGetCardExternalWalletDetails` stops bulk total-allowance fetch; mapping adjusted. > - **Authentication (OTP)**: > - Show OTP errors directly beneath inputs; clear on typing; tests added. > - **Utilities/SDK**: > - `truncateAddress` checksums hex addresses. > - `CardSDK.createOnboardingConsent` injects `tenantId` from API key; minor scanner/allowance helpers adjusted. > - **Balances**: > - `useAssetBalances` improves fiat formatting fallback (zero vs no-rate cases). > - **Tests**: > - Broad updates/coverage across views, hooks, SDK, and routes for new flows and behaviors. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d463d53. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [b3e0a64](b3e0a64) Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com>
…Limit UI issues (#22448) - fix(card): cp-7.58.2 CardHome and SpendingLimit UI issues (#22387) <!-- 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? --> This PR fixes several minor UI issues on the CardHome and SpendingLimit screens, such as buttons being partially cut off on Android devices. The fix involves wrapping the affected components with a proper SafeAreaView to ensure consistent spacing and layout across platforms. ## **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: Buttons being cut off on Android in CardHome and SpendingLimit screens CHANGELOG entry: Improved layout consistency by adding SafeAreaView wrapping ## **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 - [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] > Disables spending limit UI for Solana on CardHome and refactors SpendingLimit to use SafeAreaView/KeyboardAwareScrollView with minor style tweaks; updates related tests and memo deps. > > - **CardHome**: > - Disable spending limit features for Solana by checking `isSolanaChainId` in `isSpendingLimitSupported` and when rendering `ManageCardListItem`. > - Expand `ButtonsSection` memo deps to include `changeAssetAction`, `enableCardAction`, loading flags, and need-to-enable states. > - **SpendingLimit (UI/UX)**: > - Replace `ScrollView` with `SafeAreaView` + `KeyboardAwareScrollView` to fix cutoff and improve keyboard handling. > - Update styles: add `safeAreaView`, adjust `wrapper`/`contentContainer` and paddings. > - **Tests**: > - Mock `@metamask/bridge-controller` `isSolanaChainId` and add cases ensuring Solana hides spending limit progress, warning, and manage button. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0ec61be. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [5ba96c6](5ba96c6) Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com>
…nning on Android cp-7.58.2 (#22464) - fix: pressability measureAsyncOnUI only running on Android cp-7.58.2 (#22436) <!-- 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** #22323 <!-- 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] > Uses `measureAsyncOnUI` for Pressability on Android and wires a new async measure path through Fabric (JS, iOS, Android, JNI), with mocks and dependency patch updates. > > - **Pressability (JS)**: > - On Android, call `measureAsyncOnUI` instead of `measure`; other platforms continue using `measure` in `Libraries/Pressability/Pressability.js`. > - **Fabric/Bridging**: > - JS API: add `measureAsyncOnUI` to `Libraries/ReactNative/FabricUIManager.js` Spec and cache; expose on `ReactFabricHostComponent`. > - UIManager binding: add `measureAsyncOnUI` host function in `UIManagerBinding.cpp` to invoke JS callback on completion. > - Scheduler interfaces: add async measure methods to `Scheduler`, `SchedulerDelegate`, and `UIManagerDelegate`. > - iOS: implement `-[RCTMountingManager measure:callback:]` and route via `RCTSurfacePresenter` (`schedulerMeasureAsync`), import `UIView+React`. > - Android: add `FabricUIManager.measureAsync`; implement measurement in `MountingManager` (bounding box, DIP conversion) and JNI forwarding in `FabricMountingManager`/`Binding`. > - **Tests/Mocks**: > - Add `measureAsyncOnUI` to `jest/setup.js` UIManager mock. > - **DOM shim**: > - `ReactNativeElement.measureAsyncOnUI` delegates to `measure`. > - **Dependencies**: > - Patch `react-native@0.76.9` via Yarn (`package.json`, `yarn.lock`) to include these changes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 60ff6c8. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com> [7e3f4ce](7e3f4ce) Co-authored-by: tommasini <46944231+tommasini@users.noreply.github.com> Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
…2476) - fix(card): cp-7.58.2 delegation issues (#22435) <!-- 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? --> This PR fixes an issue where delegation was failing in certain cases due to the wallet address being lowercased. The lowercase format did not comply with the SIWE (Sign-In With Ethereum) standard required by the delegation flow. Additionally, this update includes a fix for assets that were not enabled, ensuring consistent behavior across all supported assets. ## **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: Delegation failing due to lowercased wallet address not complying with SIWE standard CHANGELOG entry: Handling of not-enabled assets in the delegation flow ## **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 - [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] > Use checksummed addresses for EVM delegation, filter out external wallets with invalid/zero allowances, and avoid token priority updates when delegation amount is zero. > > - **Delegation Flow (`useCardDelegation`)**: > - Use `safeToChecksumAddress` for non-Solana networks; keep raw address for Solana. > - SIWE and token generation now use checksummed EVM address. > - **Spending Limit View (`SpendingLimit`)**: > - Only call `updateTokenPriority` when external wallet details exist and delegation amount > `0`; otherwise clear `card-external-wallet-details` cache. > - **SDK (`CardSDK`)**: > - In `getCardExternalWalletDetails`, filter out wallets with unsupported networks or invalid/zero `allowance` values using `isZeroValue`. > - **Tests**: > - Add coverage for checksummed vs raw addresses per network. > - Add cases ensuring no priority update on `0`/`0x0` delegation amounts. > - Add cases for filtering invalid/zero allowances and unsupported networks in external wallets. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a554e9a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [358b4c7](358b4c7) Co-authored-by: Bruno Nascimento <brunonascimentodev@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?
-->
hotfix release for 7.58.2
## **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: null
## **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]
> Refactors Card to use modal navigation, adds spending-limit progress
UX and updated delegation/balance logic, improves KYC/perps behavior,
updates SDK/Redux, and bumps to 7.58.2.
>
> - **Card UX/Flows**:
> - Pull-to-refresh and error toasts in `CardHome`; Solana exclusions;
cache clearing on auth errors.
> - Modal navigation for `AddFunds` and `AssetSelection` via
`Routes.CARD.MODALS.*` (replaces inline bottom sheets).
> - Spending limit: progress bar + “close to limit” warning, refined
enable/manage flows.
> - **Hooks**:
> - Add `useAssetBalances`, `useGetLatestAllowanceForPriorityToken`,
`useUpdateTokenPriority`; remove `useAssetBalance`.
> - **SDK**:
> - Add `getLatestAllowanceFromLogs`; filter invalid/zero allowances;
auto-tenant for `createOnboardingConsent`; provider/balance scanner
usage tightened.
> - **Redux**:
> - Add `onboarding.consentSetId`; expose selectors; add
`clearAllCache`; auth/logout handling.
> - **Onboarding**:
> - KYC WebView wrapped in Safe Area; close-confirmation alert; new
strings.
> - **Perps**:
> - Receive amount now `marginUsed - fees` (PnL via live positions);
remove market-data dependency; tests updated.
> - **Navigation/Version**:
> - New `CardModals` stack; version bump/build numbers to 7.58.2.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e8d447d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
) <!-- 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** - Adds correct empty state when no search results are found <!-- 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: null ## **Related issues** Fixes: [PRED-295](https://consensyssoftware.atlassian.net/browse/PRED-295) ## **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** <img width="420" alt="Simulator Screenshot - iPhone 16 Pro Max - 2025-11-13 at 10 06 02" src="https://github.com/user-attachments/assets/5d0d9aec-49e0-4e48-acf7-28ed878dda32" /> <img width="420" alt="Simulator Screenshot - iPhone 16 Pro Max - 2025-11-13 at 09 57 57" src="https://github.com/user-attachments/assets/927646d3-cab1-4144-8da6-1c4afd1e3831" /> ## **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. [PRED-295]: https://consensyssoftware.atlassian.net/browse/PRED-295?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a localized, themed empty state for no search results in Predict market list, updates styles/tests, and adds i18n strings and assets. > > - **Predict UI**: > - **Search Empty State**: When `q` is present and no results, render themed illustration and message in `app/components/UI/Predict/components/MarketListContent/MarketListContent.tsx` using `useAssetFromTheme`, `PredictionsLight/Dark` SVGs, and `strings('predict.search_no_markets_found', { q })`. > - **Default Empty State**: Replace hardcoded copy with `strings('predict.search_empty_state', { category })`. > - **Styles**: Add `emptySearchContainer` in `MarketListContent.styles.ts`. > - **Tests**: > - Update `MarketListContent.test.tsx` to support `q` prop, and add test asserting search empty state (icon + localized text) via `getPredictMarketListSelector.emptyState()`. > - **Assets & i18n**: > - Add `predictions-no-search-results-light.svg` and `predictions-no-search-results-dark.svg`. > - Add `predict.search_empty_state` and `predict.search_no_markets_found` to `locales/languages/en.json`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2f19186. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…22658) <!-- 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? --> Fixed a bug where USDC and USDT (and other non-enabled tokens) were displaying zero balances in the MetaMask Card feature, even when users had actual balances in their wallets. Root Causes: - ChainId Format Mismatch: The tokensWithBalance hook returns tokens with hex chainId format (e.g., 0xe708), but the lookup was comparing against CAIP format (e.g., eip155:59144), causing the comparison to always fail. - Case-Sensitive Address Comparison: Token addresses from tokensWithBalance use checksum format (mixed case), but the comparison was done with strict equality against lowercase addresses, causing matches to fail. Solution: - Updated the token lookup to use the normalized assetChainId (hex format) instead of the raw CAIP chainId - Made address comparisons case-insensitive by converting both sides to lowercase before comparison - Fixed unit tests to use the correct chainId format in their mocks ## **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: Fixed a bug where USDC, USDT, and other non-enabled tokens displayed zero balances in MetaMask Card when users had actual wallet balances ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: Display correct token balances in MetaMask Card Scenario: user views non-enabled tokens with wallet balances Given user has USDC and USDT balances in their Linea wallet And these tokens are not enabled for the card (no delegation) When user opens the MetaMask Card token selection screen Then user sees the correct USDC balance (not $0.00) And user sees the correct USDT balance (not $0.00) And balances match what's shown in the main wallet view ``` ## **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** - [ ] 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] > Normalizes chainId to hex and makes address comparison case-insensitive in `useAssetBalances`, fixing zero balances for non-enabled tokens; updates tests to use hex chainId mocks. > > - **Hook (`useAssetBalances.tsx`)**: > - Normalize EVM `chainId` to hex via `safeFormatChainIdToHex` when matching `tokensWithBalance`. > - Use case-insensitive address comparison for token matching. > - Clarify mapping keys and retain wallet asset fallback; no behavior changes to Solana flow. > - **Tests (`useAssetBalances.test.ts`)**: > - Update mocked `chainId` values to hex (e.g., `"0xe708"`). > - Validate balance selection for enabled/limited and non-enabled tokens using corrected matching logic. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bf7ab92. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…s cp-7.59.0 (#22646) ## **Description** This PR fixes HIP-3 market loading and visibility issues in the Perps feature: 1. **What is the reason for the change?** - HIP-3 positions were not loading on app startup due to race condition in DEX discovery - Development testing was difficult without seeing zero-volume markets 2. **What is the improvement/solution?** - HIP-3 DEX markets now default to `marketType: 'equity'` (with explicit override support) - Position loading now ensures `buildAssetMapping()` runs before WebSocket subscriptions - Development mode now shows all markets by default (`showZeroVolume = __DEV__`) ## **Changelog** CHANGELOG entry: Fixed HIP-3 markets not appearing in Stocks tab and positions not loading on startup ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2066 Fixes: #22650 ## **Manual testing steps** ```gherkin Feature: HIP-3 Market and Position Loading Scenario: User views HIP-3 markets in Stocks tab Given user has HIP-3 enabled And xyz DEX is in enabled list When user navigates to Perps > Stocks tab Then all 12 xyz markets should be visible And markets should show equity badge Scenario: User's HIP-3 positions load on startup Given user has open HIP-3 positions When user opens the app Then HIP-3 positions should load immediately And positions should appear in positions list ``` ## **Screenshots/Recordings** ### **Before** - Only 4/12 xyz markets visible in Stocks tab - HIP-3 positions not loading on startup ### **After** - All 12/12 xyz markets visible in Stocks tab - HIP-3 positions load reliably on startup ## **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 HIP-3 DEX discovery and asset mapping occur before subscriptions, defaults HIP-3 markets to equity, enables zero-volume markets in dev, and hides badges in the watchlist. > > - **Perps Provider / Subscriptions**: > - Build asset mapping on first `getMarkets()` to avoid HIP-3 discovery race before WebSocket subscriptions. > - Initialize `discoveredDexNames` from `enabledDexs` in `HyperLiquidSubscriptionService`. > - **Market Data Transform**: > - Default unmapped HIP-3 DEX markets to `marketType: 'equity'`; updated unit tests accordingly. > - **Hook**: > - `usePerpsMarkets`: `showZeroVolume` now defaults to `__DEV__` (dev shows zero-volume markets). > - **UI**: > - `PerpsWatchlistMarkets`: pass `showBadge=false` to `PerpsMarketRowItem`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6b03cab. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## **Description** Use EIP-7702 gas station in Predict withdraw and claim transactions if insufficient native balance. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [#6173](MetaMask/MetaMask-planning#6173) ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** ## **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] > Adds token gas support to Predict claim/withdraw batches, updates confirmation UI to show a Withdraw label and hide footer for predict withdraw, and bumps transaction controller deps. > > - **Predict** > - Add `gasFeeToken: MATIC_CONTRACTS.collateral` to `addTransactionBatch` for `claimWithConfirmation` and `prepareWithdraw` in `PredictController`. > - Import `MATIC_CONTRACTS` and update tests to assert new batch params with `expect.objectContaining`. > - **Confirmations UI** > - `DepositKeyboard`: supports custom `doneLabel`. > - `CustomAmountInfo`: derives button label via `useButtonLabel`; shows “Withdraw” for `TransactionType.predictWithdraw`; passes `doneLabel`; `ConfirmButton` uses same label. > - `Footer`: hide by default for `TransactionType.predictWithdraw`. > - i18n: add `confirm.deposit_edit_amount_predict_withdraw` string. > - **Controllers** > - Transaction Pay init: make `getStrategy` synchronous (still returns `Relay`). > - **Tests** > - Add/adjust tests for new labels and batch params. > - **Dependencies** > - Bump `@metamask/transaction-controller` to `61.3.0` and `@metamask/transaction-pay-controller` to `^6.0.0` (lockfile updated). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 79e0e46. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
<!--
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**
- enable predict for non-evm networks
<!--
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: null
## **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]
> Removes EVM-only gating for Predict, updates activity tab indexing,
and adjusts tests and UI to show Predict across networks.
>
> - **Predict enablement**
> - Removes EVM-only gating: `isPredictEnabled` now mirrors
`selectPredictEnabledFlag` in `app/components/Nav/Main/MainNavigator.js`
and `app/components/Views/ActivityView/index.js`.
> - Shows Predict action regardless of network in
`app/components/Views/TradeWalletActions/TradeWalletActions.tsx`.
> - **Activity tabs**
> - Adjusts Predict tab index to account for optional Perps tab:
`predictTabIndex = isPerpsEnabled ? 3 : 2` in
`app/components/Views/ActivityView/index.js`.
> - **Tests**
> - Updates test to expect Predict button on non-EVM networks in
`app/components/Views/TradeWalletActions/TradeWalletActions.test.tsx`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
bcbbe91. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
) ## **Description** Display the updated transaction details for Predict claim and withdraw transactions. Include new `Account` and `Received total` rows. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [#6182](MetaMask/MetaMask-planning#6182) ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** <img width="300" alt="Withdraw" src="https://github.com/user-attachments/assets/7ec6ac1b-cafb-4a45-a070-c219ff982d45" /> ## **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] > Adds Predict claim/withdraw support to transaction details, introduces Account and Received total rows, refactors fee/amount sourcing, and enhances gas fee calculations using receipt data. > > - **Transaction details UI** > - Add `TransactionDetailsAccountRow` (Account) for `predictClaim`/`predictWithdraw`. > - Update `TransactionDetails` to show Account row and conditionally render Summary section; set titles for `predictClaim`/`predictWithdraw`. > - Extend `TransactionDetailsHero` to support `predictWithdraw` and switch to `useTokenWithBalance` for token metadata. > - Update `TransactionDetailsPaidWithRow` to use `useTokenWithBalance`. > - Update `TransactionDetailsNetworkFeeRow` to prefer Pay metadata, fallback to calculated fees for `predictClaim`/`predictWithdraw`. > - Update `TransactionDetailsTotalRow` to prefer Pay total, fallback to token amount for `predictWithdraw`, and use `received_total` label for claim/withdraw. > - Route new detail view from list by adding `predictClaim`/`predictWithdraw` in `TransactionElement`. > - **Gas/fee logic** > - Enhance `useFeeCalculations`/`calculateGasEstimate` to use `txReceipt.gasUsed` and `txReceipt.effectiveGasPrice` when available; plumb `receiptGasPrice` through API. > - **i18n** > - Add strings for Predict titles and new labels (`account`, `received_total`). > - **Tests** > - Add/adjust unit tests for new rows, hero, network fee, total, and fee calculations (including receipt-based paths). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 18d53a6. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
<!--
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**
- change spacing in about tab
- change network border-radius
<!--
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: null
## **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]
> Refactors the About tab layout and spacing, and updates the Polygon
network badge styling.
>
> - **Predict Market Details (`PredictMarketDetails.tsx`)**:
> - *About section layout*: Groups icon+label on the left with
value/actions on the right; adjusts gaps (`gap-6`, `gap-4`) and aligns
rows with `justifyContent=Between`.
> - *Resolution link row*: Uses tighter spacing (`gap-1`) and keeps
external-link icon inline.
> - *Divider*: Removes extra vertical padding.
> - **Predict Balance (`PredictBalance.tsx`)**:
> - *Network badge*: Removes custom `rounded-2xl` style to use default
badge shape.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
76af7bf. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- 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** Remove chart pill "Current" <!-- 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: Update Current perps chart trading view label ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1185 ## **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] --> <img width="357" height="743" alt="image" src="https://github.com/user-attachments/assets/8528c3e9-fc43-41eb-ae25-dfc269bdeea3" /> ### **After** <!-- [screenshots/recordings] --> <img width="357" height="744" alt="image" src="https://github.com/user-attachments/assets/620e5e9f-35b2-4203-adad-fa65bc2e026b" /> ## **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] > Removes the "Current" label from the current price line and changes it to a dashed style across creation and restore paths. > > - **Perps TradingView chart (`app/components/UI/Perps/components/TradingViewChart/TradingViewChartTemplate.tsx`)**: > - Current price line configuration: > - Change `lineStyle` from `0` to `2` (solid → dashed). > - Remove axis title by setting `title` from `"Current"` to `""`. > - Applied consistently in `updateCurrentPriceLine` and both restoration blocks in `showAllPriceLines`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6460b42. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
<!--
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**
Sync 7.58.1 & 7.58.2
<!--
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: null
## **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.
---------
Co-authored-by: sethkfman <Seth.Kaufman@consensys.net>
Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
Co-authored-by: runway-github[bot] <73448015+runway-github[bot]@users.noreply.github.com>
Co-authored-by: Bruno Nascimento <brunonascimentodev@gmail.com>
Co-authored-by: Micaela <100321200+micaelae@users.noreply.github.com>
Co-authored-by: Wei Sun <wei.sun@consensys.net>
Co-authored-by: Kylan Hurt <6249205+smilingkylan@users.noreply.github.com>
Co-authored-by: Luis Taniça <matallui@gmail.com>
Co-authored-by: Nicholas Smith <nick.smith@consensys.net>
Co-authored-by: tommasini <46944231+tommasini@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?
-->
Change after hours warning to fit within a single line.
## **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
- [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]
> Shortens the perps after-hours volatility warning copy and updates the
related test expectation.
>
> - **Perps UI (i18n)**:
> - Shortens `perps.market.expect_more_volatility` copy to `"Expect more
volatility outside of market hours"` in `locales/languages/en.json`.
> - **Tests**:
> - Updates `PerpsMarketHoursBanner.test.tsx` to expect the new
shortened volatility warning text when market is open.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ff5f30a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: OGPoyraz <omergoktugpoyraz@gmail.com>
Co-authored-by: dylanbutler1 <99672693+dylanbutler1@users.noreply.github.com>
Co-authored-by: Matthew Walsh <matthew.walsh@consensys.net>
Co-authored-by: Michal Szorad <michal.szorad@consensys.net>
Co-authored-by: cmd-ob <ola.bale@consensys.net>
Co-authored-by: Mathieu Artu <mathieu.artu@consensys.net>
Co-authored-by: Juanmi <95381763+juanmigdr@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**
Previously, the rewards information in the Predict buy preview screen
was displayed for all users, regardless of whether they had rewards
enabled or if their account had opted into the rewards program. This
could lead to user confusion as users would see estimated rewards points
even though they weren't eligible to receive them.
This PR adds proper rewards eligibility checking by implementing a new
`usePredictRewards` hook that validates both the global rewards feature
flag and the user's account-specific opt-in status. The rewards section
is now only displayed when both conditions are met, ensuring users only
see rewards information when they're actually eligible to earn them.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Predict rewards display
Scenario: user views buy preview with rewards disabled globally
Given the rewards feature is disabled globally
And user is on the Predict buy preview screen
And user enters a bet amount greater than $1
When the preview loads
Then the rewards section should not be displayed
Scenario: user views buy preview without opt-in
Given the rewards feature is enabled globally
And user's account has not opted into rewards
And user is on the Predict buy preview screen
And user enters a bet amount greater than $1
When the preview loads
Then the rewards section should not be displayed
Scenario: user views buy preview with rewards enabled
Given the rewards feature is enabled globally
And user's account has opted into rewards
And user is on the Predict buy preview screen
And user enters a bet amount greater than $1
When the preview loads
Then the rewards section should be displayed with estimated points
```
## **Screenshots/Recordings**
### **Before**
<!-- Rewards section displayed for all users regardless of eligibility
-->
### **After**
<!-- Rewards section only displayed when user is eligible (opted in +
feature enabled) -->
https://github.com/user-attachments/assets/fca566f1-fdd4-4e3a-a74f-5c6f34b25373
## **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]
> Show rewards in Predict buy preview only when the feature is enabled
and the user’s account is opted in, via a new hook with comprehensive
tests.
>
> - **Predict UI**:
> - Integrate `usePredictRewards` into
`views/PredictBuyPreview/PredictBuyPreview.tsx` to gate rewards display
(`shouldShowRewards`) and disable placing bets while rewards status is
loading (`!isRewardsLoading`).
> - **New Hook**:
> - Add `hooks/usePredictRewards.ts` to determine rewards eligibility
by:
> - Checking `RewardsController:isRewardsFeatureEnabled`.
> - Formatting selected address to Polygon CAIP-10 and querying
`RewardsController:getHasAccountOptedIn`.
> - Managing `enabled` and `isLoading` states with error logging via
`Logger.error` and `ensureError`.
> - **Tests**:
> - Add `hooks/usePredictRewards.test.ts` covering: feature disabled,
opt-in true/false, missing address, CAIP formatting failure, controller
call failure, and account changes.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0fb71e8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
## **Description** Updated the perps error screens to match the new design specifications when connection issues occur. The changes improve the user experience by providing clearer, more concise error messaging with updated iconography. **What changed:** - Replaced the details icon with a signal/waveform icon (SignalCellular) to better represent connection issues - Updated error title from "Perps is temporarily offline" to "Couldn't connect to perps" - Removed the description text for a cleaner UI - Updated button labels: "Retry" � "Try again" and "Go Back" � "Go back" **Why:** The previous error screen design didn't clearly communicate connection issues to users. The new design provides a more intuitive visual indicator (signal icon) and more actionable copy that better matches user expectations during network failures. ## **Changelog** CHANGELOG entry: Updated perps connection error screen with new design and improved messaging ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2020 ## **Manual testing steps** ```gherkin Feature: Perps connection error handling Scenario: user encounters a connection error when accessing perps Given user has the MetaMask mobile app open And user navigates to the perps feature When perps fails to connect due to network issues Then user sees an error screen with: - A signal/waveform icon - Title "Couldn't connect to perps" - "Try again" button (primary) - "Go back" button (secondary) When user taps "Try again" Then the app attempts to reconnect to perps When user taps "Go back" Then user navigates back to the previous screen Scenario: connection automatically recovers Given user is viewing the perps connection error screen When network connection is restored Then perps automatically reconnects And user sees the perps interface ``` ## **Screenshots/Recordings** ### **Before** Previous design: - Details/info icon - Title: "Perps is temporarily offline" - Description: "We're working to get it back online soon." - Button: "Retry" ### **After** New design: - Signal/waveform icon (SignalCellular) - Title: "Couldn't connect to perps" - No description text - Buttons: "Try again" and "Go back" ## **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 Details** ### Files Modified 1. **Components:** - `app/components/UI/Perps/components/PerpsConnectionErrorView/PerpsConnectionErrorView.tsx` - `app/components/UI/Perps/components/PerpsErrorState/PerpsErrorState.tsx` 2. **Localization:** - `locales/languages/en.json` 3. **Tests:** - `app/components/UI/Perps/components/PerpsConnectionErrorView/PerpsConnectionErrorView.test.tsx` - `app/components/UI/Perps/components/PerpsErrorState/PerpsErrorState.test.tsx` ### Test Results � All ESLint checks pass � All Jest tests pass (15/15) - PerpsConnectionErrorView: 7/7 tests - PerpsErrorState: 8/8 tests <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Refreshes perps connection error screens with a warning icon, no description, updated title/buttons, and aligned tests/i18n. > > - **Perps UI**: > - `PerpsConnectionErrorView`: switch icon to `IconName.Warning`, remove description text, retain debug details; keep primary/secondary actions; adjust navigation/back handling unchanged. > - `PerpsErrorState`: use `IconName.Warning` for `CONNECTION_FAILED`, omit description; conditionally render description for other errors. > - **Localization (`locales/languages/en.json`)**: > - Update `perps.errors.connectionFailed` copy: title → "Couldn't connect to perps", buttons → "Try again" / "Go back". > - **Tests**: > - Update expectations to match removed description and new icon; adjust icon mock to expose `Warning`; ensure retry/back buttons and loading states verified. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9c49c54. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
# Predict: Entry Point Tracking & User Trait Implementation ## Overview This PR implements comprehensive entry point tracking for the Predict feature and adds a persistent user trait for Polymarket account creation. These changes enable better analytics attribution and user segmentation across all Predict interactions. CHANGELOG entry: null ## Changes ### 1. User Trait for Polymarket Account Creation **Added persistent user trait to track Polymarket account creation via MetaMask:** - **New Property**: `CREATED_POLYMARKET_ACCOUNT_VIA_MM` - **Type**: `boolean` - **Location**: Set directly in `PolymarketProvider.prepareDeposit()` when deployment transaction is included - **Persistence**: Automatically attached to all future analytics events for the user **Benefits:** - ✅ Enables cohort analysis (users with vs without Polymarket accounts) - ✅ Tracks conversion funnel from MetaMask user → Polymarket account creator - ✅ Attribution analysis for acquisition channels driving account creation - ✅ Long-term retention analysis for users who created accounts via MetaMask **Files Changed:** - `app/util/metrics/UserSettingsAnalyticsMetaData/UserProfileAnalyticsMetaData.types.ts` - `app/components/UI/Predict/providers/polymarket/PolymarketProvider.ts` ### 2. Deeplink Origin Parameter Handling **Fixed deeplink manager to correctly pass `origin` parameter to Predict navigation:** - **Issue**: Carousel banner clicks were not being tracked as `carousel` entry point - **Solution**: Updated deeplink flow to pass `origin` through entire chain and map directly to `entryPoint` - **Mapping**: `origin === 'carousel'` → `entryPoint: 'carousel'`, otherwise → `entryPoint: 'deeplink'` **Files Changed:** - `app/core/DeeplinkManager/DeeplinkManager.ts` - `app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts` - `app/core/DeeplinkManager/Handlers/handlePredictUrl.ts` ### 3. Comprehensive Entry Point Tracking **Added missing `entryPoint` parameters across all Predict navigation paths:** #### New Entry Point Constants ```typescript CAROUSEL: 'carousel', // Wallet carousel banner REWARDS: 'rewards', // Rewards ways to earn CTA GTM_MODAL: 'gtm_modal', // What's New modal ``` #### Navigation Paths Updated | Component | Entry Point | Trigger | |-----------|-------------|---------| | `PredictPositionsHeader` | `homepage_balance` | Balance card touch | | `PredictPositionEmpty` | `homepage_positions` | Empty positions "Explore" button | | `PredictNewButton` | `homepage_new_prediction` | New prediction button | | `PredictGTMModal` | `gtm_modal` | What's New modal "Get Started" | | `TradeWalletActions` | `main_trade_button` | Wallet actions predict button | | `WalletActions` | `main_trade_button` | Bottom sheet predict action | | `WaysToEarn` (Rewards) | `rewards` | Rewards predict CTA | | `PredictionSection` | `homepage_new_prediction` | Trending view "View all" | **Files Changed:** - `app/components/UI/Predict/constants/eventNames.ts` - `app/components/UI/Predict/components/PredictPositionsHeader/PredictPositionsHeader.tsx` - `app/components/UI/Predict/components/PredictPositionEmpty/PredictPositionEmpty.tsx` - `app/components/UI/Predict/components/PredictNewButton/PredictNewButton.tsx` - `app/components/UI/Predict/components/PredictGTMModal/PredictGTMModal.tsx` - `app/components/Views/TradeWalletActions/TradeWalletActions.tsx` - `app/components/Views/WalletActions/WalletActions.tsx` - `app/components/UI/Rewards/components/Tabs/OverviewTab/WaysToEarn/WaysToEarn.tsx` - `app/components/Views/TrendingView/PredictionSection/PredictionSection.tsx` ### 4. Test Updates **Updated all tests to expect `entryPoint` parameters:** - Fixed `handleUniversalLink.test.ts` to expect `origin` parameter in `_handlePredict` calls - Updated 9 component tests to expect `entryPoint` in navigation assertions - All tests use `expect.any(String)` for flexibility while ensuring parameter presence **Test Files Changed:** - `app/core/DeeplinkManager/ParseManager/handleUniversalLink.test.ts` - `app/core/DeeplinkManager/Handlers/handlePredictUrl.test.ts` - `app/components/UI/Predict/components/PredictPositionsHeader/PredictPositionsHeader.test.tsx` - `app/components/UI/Predict/components/PredictPositionEmpty/PredictPositionEmpty.test.tsx` - `app/components/UI/Predict/components/PredictNewButton/PredictNewButton.test.tsx` - `app/components/UI/Predict/components/PredictGTMModal/PredictGTMModal.test.tsx` - `app/components/Views/TradeWalletActions/TradeWalletActions.test.tsx` - `app/components/Views/WalletActions/WalletActions.test.tsx` - `app/components/UI/Rewards/components/Tabs/OverviewTab/WaysToEarn/WaysToEarn.test.tsx` - `app/components/Views/TrendingView/PredictionSection/PredictionSection.test.tsx` ## Analytics Impact ### Entry Point Coverage All user journeys to Predict now include proper `entry_point` attribution: - ✅ Carousel/banner clicks - ✅ Homepage interactions (balance, positions, new prediction button) - ✅ Main trade button - ✅ Rewards integration - ✅ What's New modal - ✅ Deeplinks (notification, carousel, generic) ### User Trait Usage The `created_polymarket_account_via_mm` trait will be automatically included in: - All Predict analytics events - All MetaMask analytics events - Segment user profiles - Allows filtering/segmentation in any analytics tool ## Testing ### Unit Tests ```bash # All deeplink tests passing yarn jest handleUniversalLink.test.ts # 55 tests ✅ yarn jest handlePredictUrl.test.ts # 30 tests ✅ # All component tests passing yarn jest PredictPositionsHeader.test.tsx yarn jest PredictPositionEmpty.test.tsx yarn jest PredictNewButton.test.tsx yarn jest PredictGTMModal.test.tsx yarn jest TradeWalletActions.test.tsx yarn jest WalletActions.test.tsx yarn jest WaysToEarn.test.tsx yarn jest PredictionSection.test.tsx ``` ### Manual Testing - [ ] Click carousel banner → Verify `entryPoint: 'carousel'` in analytics - [ ] Click balance card → Verify `entryPoint: 'homepage_balance'` - [ ] Use trade button → Verify `entryPoint: 'main_trade_button'` - [ ] Open from rewards → Verify `entryPoint: 'rewards'` - [ ] Complete first deposit (creates Polymarket account) → Verify `created_polymarket_account_via_mm: true` in subsequent events ## Migration Notes ### No Breaking Changes - All changes are additive (new parameters, new trait) - Existing analytics events continue to work - Entry points default to appropriate values when missing ### Analytics Team Action Items 1. **Verify trait propagation**: Confirm `created_polymarket_account_via_mm` appears in Segment 2. **Update dashboards**: Add entry point filters to Predict funnels 3. **Create cohorts**: Set up user segments for Polymarket account creators ## Related Documentation - **Analytics Events**: See `segment-schema` repo for Predict event schemas - **Entry Points**: Defined in `app/components/UI/Predict/constants/eventNames.ts` - **User Traits**: Defined in `app/util/metrics/UserSettingsAnalyticsMetaData/UserProfileAnalyticsMetaData.types.ts` ## Checklist - [x] Added user trait for Polymarket account creation - [x] Fixed deeplink origin parameter handling - [x] Added entry point tracking to all navigation paths - [x] Added new entry point constants - [x] Updated all affected component tests - [x] All unit tests passing - [x] No linter errors - [x] Code follows project guidelines <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds consistent `entryPoint` analytics to all Predict navigations and deeplinks, and sets a persistent user trait when a Polymarket account is created via MetaMask. > > - **Predict analytics**: > - Add `ENTRY_POINT` values (e.g., `carousel`, `rewards`, `gtm_modal`) in `constants/eventNames.ts` and pass `params.entryPoint` on navigations from `PredictGTMModal`, `PredictNewButton`, `PredictPositionEmpty`, `PredictPositionsHeader`, `TradeWalletActions`, `WalletActions`, and Rewards `WaysToEarn` CTA to `Routes.PREDICT.MARKET_LIST`. > - **Deeplinks**: > - Propagate `origin` to Predict handler via `DeeplinkManager` and `handleUniversalLink`; map `origin` -> `params.entryPoint` in `handlePredictUrl` (defaults to `deeplink`) for both market details and list routes; enhance logging. > - **User trait**: > - Add `UserProfileProperty.CREATED_POLYMARKET_ACCOUNT_VIA_MM` and set it in `PolymarketProvider.prepareDeposit()` when deploying proxy wallet (fire-and-forget with error logging). > - **Tests**: > - Update/unit tests to assert `params.entryPoint` and `origin` propagation across components and deeplink handlers. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7588b78. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## **Description**
This PR fixes an issue where unrealized P&L was being displayed even
when users had no active positions. The fix ensures that unrealized P&L
is only shown when the user has at least one position, preventing
confusing or misleading information from being displayed.
**What is the reason for the change?**
Users were seeing unrealized P&L data displayed even when they had no
positions, which could be confusing since P&L is meaningless without any
active positions.
In addition, Polymarket uPnL API endpoint seems to give us bogus
information when we have 0 positions.
**What is the improvement/solution?**
The `useUnrealizedPnL` hook now fetches both unrealized P&L data and the
user's positions in parallel. The unrealized P&L is only displayed if
`positions.length > 0`, ensuring users only see relevant P&L information
when they have active positions.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Unrealized P&L visibility based on positions
Scenario: user has no positions
Given user is logged in with an account
And user has no active positions
When user navigates to the Predict screen
Then unrealized P&L section is not displayed
Scenario: user has active positions
Given user is logged in with an account
And user has at least one active position
When user navigates to the Predict screen
Then unrealized P&L section is displayed with current P&L data
```
## **Screenshots/Recordings**
### **Before**
<!-- Unrealized P&L displayed even with 0 positions -->
### **After**
https://github.com/user-attachments/assets/cba5278e-09fe-4f75-9eb3-a17771d3174d
## **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]
> Only show unrealized PnL when the user has at least one position,
fetching PnL and positions concurrently.
>
> - **Predict Hook
(`app/components/UI/Predict/hooks/useUnrealizedPnL.tsx`)**
> - Fetches `getUnrealizedPnL` and `getPositions` in parallel via
`Promise.all`.
> - Sets `unrealizedPnL` to `null` when `positions.length === 0`;
otherwise uses fetched P&L.
> - Calls `getPositions` with `{ providerId, limit: 1, offset: 0,
claimable: false }`.
> - **Tests
(`app/components/UI/Predict/hooks/useUnrealizedPnL.test.tsx`)**
> - Add mocks and coverage for positions-based visibility (no positions
=> `null`, with positions => show P&L).
> - Verify `getPositions` is called with the correct params and
provider-specific calls.
> - Assert parallel invocation of `getUnrealizedPnL` and `getPositions`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8b77e7f. 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 : )