Skip to content

Conversation

@juanmigdr
Copy link
Member

@juanmigdr juanmigdr commented Nov 24, 2025

Explanation

Right now the results from trending returns the following data:

   {
      "assetId":"eip155:1/erc20:0xdac17f958d2ee523a2206206994597c13d831ec7",
      "decimals":6,
      "name":"Tether USD",
      "symbol":"USDT"
   }

This impacts the UI in the following way:
image

As you can see the items returned from the search API do not have:

  • volume
  • market-cap
  • price
  • price change (24h)

I have modified the search API here to return marketData optionally. This PR makes it possible for Mobile and Extension to fetch and use this data


Note

Adds an includeMarketData option to searchTokens (default false) and propagates it to the token search API; updates tests and changelog.

  • Token Service (src/token-service.ts):
    • Extend getTokenSearchURL and searchTokens to support includeMarketData (defaults to false) and append includeMarketData to the /tokens/search query.
  • Tests (src/token-service.test.ts):
    • Update expectations to include includeMarketData=false in requests.
    • Add test covering includeMarketData=true.
  • Docs:
    • Update CHANGELOG.md to note optional market data support for searchTokens.

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

References

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1834

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@juanmigdr juanmigdr marked this pull request as ready for review November 26, 2025 11:47
@juanmigdr juanmigdr requested review from a team as code owners November 26, 2025 11:47
@juanmigdr juanmigdr enabled auto-merge November 26, 2025 11:47
@juanmigdr juanmigdr added this pull request to the merge queue Nov 26, 2025
Merged via the queue into main with commit 9dc36c2 Nov 26, 2025
275 checks passed
@juanmigdr juanmigdr deleted the feat/support-marketdata-in-token-search branch November 26, 2025 11:57
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Nov 28, 2025
<!--
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**
Right now the results from trending returns the following data:

```
   {
      "assetId":"eip155:1/erc20:0xdac17f958d2ee523a2206206994597c13d831ec7",
      "decimals":6,
      "name":"Tether USD",
      "symbol":"USDT"
   }
```

This impacts the UI in the following way:
<img height="700" alt="image"
src="https://github.com/user-attachments/assets/19dd0865-55cc-4a45-9fe7-89476060dc47"
/>

As you can see the items returned from the search API do not have:
- volume
- market-cap
- price
- price change (24h)

I have modified:
- The search API
[here](consensys-vertical-apps/va-mmcx-token-api#194)
to return marketData optionally.
- Core [here](MetaMask/core#7226) to adopt this
new `includeMarketData` parameter

<!--
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: get marketData on trending search request

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1834

## **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**

### **Before**

<img height="700" alt="image"
src="https://github.com/user-attachments/assets/19dd0865-55cc-4a45-9fe7-89476060dc47"
/>

### **After**

<img height="700" alt="image"
src="https://github.com/user-attachments/assets/b79e4ce8-153a-49ab-9402-187b79b6f2b6"
/>


## **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]
> Integrates market data from token search into trending results, adds
robust typing and stale-request handling in hooks, and updates tests and
section config accordingly.
> 
> - **Trending/Search Hooks**:
> - **`useSearchRequest`**: Adds typed `SearchResult` with market data
fields; returns typed results; improves loading/error handling; prevents
stale overwrites via request IDs; skips calls and clears results on
empty queries; stabilizes `chainIds` to avoid redundant fetches.
> - **`useTrendingSearch`**: Merges search results into trending tokens,
mapping market data and 24h price change (`pricePercentChange1d` ->
`priceChangePct.h24`); deduplicates by `assetId`; maintains sort and
loading behavior.
> - **Tests**:
> - Expand unit tests for success/error states, manual retry, empty
query behavior, stale request protection, param-change triggering, and
stable `chainIds` reference; add helpers and correct typing.
> - **Sections Config**:
> - Updates `useSectionData` `refetch` type to allow `Promise<void> |
void`; simplifies `SectionData` to `data` and `isLoading`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2bc3dea. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants