Skip to content

fix/PRO-3190/hifi-endpoint-replacement#286

Merged
RanaBug merged 3 commits intostagingfrom
fix/PRO-3190/hifi-endpoint-replacement
Apr 10, 2025
Merged

fix/PRO-3190/hifi-endpoint-replacement#286
RanaBug merged 3 commits intostagingfrom
fix/PRO-3190/hifi-endpoint-replacement

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Apr 9, 2025

Description

  • Replacement of trending tokens, blockchains list and token market data endpoints (through Mobula)

How Has This Been Tested?

  • Existing Unit Tests and Manual Testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features

    • Enhanced token navigation and selection, now ensuring compatibility with supported blockchains.
    • Introduced new endpoints to deliver real-time market, trending, and blockchain data.
    • Integrated token price displays for improved user insights.
  • Bug Fixes

    • Improved error handling to prevent issues during token data retrieval and display.
  • Tests

    • Updated mock data to include token pricing for comprehensive component validation.
  • Refactor

    • Streamlined data processing for tokens and blockchain details for better reliability.

@RanaBug RanaBug requested a review from IAmKio April 9, 2025 14:37
@RanaBug RanaBug self-assigned this Apr 9, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request refactors various components and tests across the PillarX and TokenAtlas codebases to improve robustness and maintainability. The changes focus on safer data access using optional chaining for blockchain-related properties, enhanced token navigation logic with utility functions, and streamlined API integration by replacing deprecated endpoints with new implementations. Additionally, test mock data has been updated with new price fields, and the TypeScript type definitions have been standardized to enforce consistent API response structures.

Changes

File(s) Summary of changes
src/apps/.../HorizontalToken.tsx, src/apps/.../TokenInfoHorizontal.tsx Modified chainData assignment to use optional chaining (blockchainListData?.result?.data) for safe nested property access.
src/apps/.../TokensHorizontalTile/TokensHorizontalTile.tsx Introduced useEtherspotUtils hook and isZeroAddress for improved token navigation logic; updated URL construction based on compatible token contracts.
src/apps/.../TokensHorizontalTile/test/TokensHorizontalTile.test.tsx Added a new price property in the test mockData for token pricing.
src/apps/.../TokensVerticalList/TokensVerticalList.tsx, src/apps/.../TokensVerticalList/test/TokensVerticalList.test.tsx Enhanced token navigation logic with compatibility checks; updated mapping logic and appended blockchain info; added price fields in tests.
src/apps/.../TokensVerticalTile/test/TokensVerticalTile.test.tsx Added new price fields to token mock data in tests.
src/apps/.../SwapReceiveCard/SwapReceiveCard.tsx Simplified token search and receive token logic; replaced contractAddress with chain, updated query parameters, and enhanced native token filtering.
src/apps/.../api/token.ts Restructured API endpoints by removing tokenInfoApi, tokenGraphApi, trendingTokensApi, and blockchainsListApi; added new endpoints (tokenMarketData, blockchainsList, trendingTokens); updated base query to fetchBaseMobula.
src/apps/.../ChainCard/ChainCard.tsx Updated Redux dispatch and data access to use optional chaining (blockchainListData?.result?.data).
src/apps/.../TokenGraphColumn/TokenGraphColumn.tsx Added useEtherspotUtils hook and isZeroAddress utility for URL logic; introduced isTokenDataErroring state for error handling in token data retrieval.
src/apps/.../TokensSlider/TokensSlider.tsx, src/apps/.../TokensSlider/test/TokenSlider.test.tsx Refined trending tokens filtering using compatible chains; updated token selection logic with chain ID conversion; modified mock data structure (data to result).
src/apps/.../token-atlas/index.tsx Replaced useGetTokenInfoQuery with useGetTokenMarketDataQuery; added useGetSearchTokensQuery; incorporated token conversion and enhanced error handling via dispatching appropriate actions.
src/apps/.../tokenAtlas/reducer/tokenAtlasSlice.ts Introduced a new isTokenDataErroring state property and added setIsTokenDataErroring reducer to update error status.
src/.../types/api.ts Updated type definitions by adding a required price property in TokenData and enforcing a consistent API response structure by replacing data with result in several types.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant IA as TokenAtlas Index
    participant API as Search Query API
    participant RS as Redux Store

    U->>IA: Enter token search (asset, chain)
    IA->>API: Execute useGetSearchTokensQuery
    API-->>IA: Return search results (wrapped in result)
    IA->>IA: Convert API response to token objects
    IA->>RS: Dispatch selected token & update error state if needed
    RS-->>IA: Updated token data state
Loading

Possibly related PRs

Suggested reviewers

  • IAmKio

Poem

In a code field where rabbits roam,
I hop and nibble through each chrome.
Optional chains now guard my trail,
Safe and sound, I shall not fail.
New APIs bloom like carrots so sweet,
My code garden now feels complete!
🐇🌸


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 9, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 051284c
Status: ✅  Deploy successful!
Preview URL: https://9a007b1b.x-e62.pages.dev
Branch Preview URL: https://fix-pro-3190-hifi-endpoint-r.x-e62.pages.dev

View logs

@github-actions github-actions bot temporarily deployed to Preview (fix/PRO-3190/hifi-endpoint-replacement) April 9, 2025 14:39 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx (1)

57-68: Improved token filtering with blockchain compatibility check.

The new implementation properly filters trending tokens to only include those with contracts on compatible chains, ensuring that users only see tokens they can actually interact with. The use of chainNameFromViemToMobula standardizes chain names between different systems.

Consider adding a comment explaining the filtering logic in more detail, as it's a critical part of the user experience.

// look for trending tokens with compatible chains and reduce the list the 20 first trending tokens
const trendingTokens =
  trendingTokensData?.result
    ?.filter((token) =>
+     // Only show tokens that have at least one contract on a compatible chain
      token.contracts?.some((contract) =>
        CompatibleChains.some(
          (chain) =>
            chainNameFromViemToMobula(chain.chainName) === contract.blockchain
        )
      )
    )
    .slice(0, 20) || [];
src/apps/the-exchange/components/SwapReceiveCard/SwapReceiveCard.tsx (1)

70-81: Added specialized handling for native tokens.

The updated logic now properly distinguishes between native tokens and contract tokens by checking if the token's symbol matches the asset parameter. This improved approach ensures that the correct token is selected when navigating from Token Atlas.

Consider adding error handling for the case when no results are found:

if (nativeToken.length > 0) {
  dispatch(setReceiveToken(nativeToken[0]));
} else {
+  // Only dispatch if results exist
+  if (result.length > 0) {
    dispatch(setReceiveToken(result[0]));
+  }
+  // Consider logging or handling case when no tokens are found
}
src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (1)

78-101: Handle potential undefined blockchain in query parameters.
If compatibleTokenContract is missing or undefined, ${compatibleTokenContract?.blockchain} could become blockchain=undefined in the route, which may lead to unintended behavior. Consider providing a fallback or skipping the param when undefined.

-  navigate(
-    `/token-atlas?${!isZeroAddress(compatibleTokenContract?.address || '') 
-      ? \`&asset=\${compatibleTokenContract?.address}\` 
-      : \`&asset=\${token.symbol}\`}&blockchain=\${compatibleTokenContract?.blockchain}`
-  )
+  const blockchainParam = compatibleTokenContract?.blockchain 
+    ? \`&blockchain=\${compatibleTokenContract.blockchain}\` 
+    : '';
+  navigate(
+    \`/token-atlas?\${!isZeroAddress(compatibleTokenContract?.address || '') 
+      ? \`&asset=\${compatibleTokenContract?.address}\` 
+      : \`&asset=\${token.symbol}\`}\${blockchainParam}\`
+  );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8535215 and ab1cd87.

⛔ Files ignored due to path filters (2)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (16)
  • src/apps/pillarx-app/components/HorizontalToken/HorizontalToken.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokenInfoHorizontal/TokenInfoHorizontal.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (4 hunks)
  • src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensVerticalList/TokensVerticalList.tsx (2 hunks)
  • src/apps/pillarx-app/components/TokensVerticalList/test/TokensVerticalList.test.tsx (2 hunks)
  • src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (2 hunks)
  • src/apps/the-exchange/components/SwapReceiveCard/SwapReceiveCard.tsx (1 hunks)
  • src/apps/token-atlas/api/token.ts (3 hunks)
  • src/apps/token-atlas/components/ChainCard/ChainCard.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (6 hunks)
  • src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx (3 hunks)
  • src/apps/token-atlas/components/TokensSlider/test/TokenSlider.test.tsx (2 hunks)
  • src/apps/token-atlas/index.tsx (6 hunks)
  • src/apps/token-atlas/reducer/tokenAtlasSlice.ts (4 hunks)
  • src/types/api.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
src/apps/pillarx-app/components/TokensVerticalList/TokensVerticalList.tsx (2)
src/utils/blockchain.ts (1)
  • CompatibleChains (260-289)
src/services/tokensData.ts (1)
  • chainNameFromViemToMobula (66-84)
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (3)
src/apps/token-atlas/hooks/useReducerHooks.tsx (1)
  • useAppSelector (6-6)
src/services/tokensData.ts (1)
  • chainIdToChainNameTokensData (211-232)
src/apps/simpleswap/components/NewCoinsDropdown/styles.ts (1)
  • Body (29-35)
src/apps/token-atlas/components/ChainCard/ChainCard.tsx (1)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1)
  • setBlockchainList (107-112)
src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (2)
src/utils/blockchain.ts (1)
  • CompatibleChains (260-289)
src/services/tokensData.ts (1)
  • chainNameFromViemToMobula (66-84)
src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx (3)
src/utils/blockchain.ts (1)
  • CompatibleChains (260-289)
src/services/tokensData.ts (2)
  • chainNameFromViemToMobula (66-84)
  • chainNameToChainIdTokensData (235-256)
src/apps/token-atlas/types/types.tsx (1)
  • SelectedTokenType (14-22)
src/apps/token-atlas/api/token.ts (3)
src/types/api.ts (3)
  • TokenAtlasInfoApiResponse (214-218)
  • BlockchainList (305-307)
  • TrendingTokens (243-245)
src/utils/blockchain.ts (1)
  • isTestnet (29-35)
src/store.ts (1)
  • addMiddleware (48-58)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (51)
src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (1)

24-24: Addition of price data to test mock is good.

Adding the price property to the token mock data aligns with the PR objectives to replace endpoints related to token market data. This change ensures that the component can properly handle and display token pricing information.

src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (1)

32-32: LGTM: Price properties added to mock tokens.

The addition of price properties to both token objects in the mock data is consistent with the changes made in other test files. This ensures consistent test coverage for price-related functionality across components.

Also applies to: 44-44

src/apps/pillarx-app/components/TokensVerticalList/test/TokensVerticalList.test.tsx (1)

25-25: Price properties added to mock data as expected.

Adding price properties to the token objects in this test file maintains consistency with the other test files, ensuring comprehensive test coverage for the token price display functionality across the application.

Also applies to: 37-37

src/apps/pillarx-app/components/HorizontalToken/HorizontalToken.tsx (1)

47-47: Improved robustness with optional chaining.

The addition of optional chaining (?.) when accessing the blockchain data properties is a good defensive programming practice. This change prevents potential runtime errors if the API response structure changes or if the data is temporarily unavailable.

This change aligns with the PR objective of improving endpoint integration by making the code more resilient to variations in API response structures.

src/apps/pillarx-app/components/TokenInfoHorizontal/TokenInfoHorizontal.tsx (1)

41-43: Improved error handling with optional chaining

The addition of optional chaining (?.result?.) when accessing the blockchain data makes the code more robust by safely handling potential undefined values in the nested structure of the API response. This change aligns with the endpoint replacement objectives mentioned in the PR.

src/apps/token-atlas/components/ChainCard/ChainCard.tsx (2)

26-26: Improved error handling with optional chaining

The update to blockchainListData?.result?.data adds defensive programming with optional chaining operators, preventing potential runtime errors if the API response structure changes or is temporarily undefined.


34-36: Consistent data access pattern applied

This change to use blockchainListData?.result?.data.find() maintains consistency with the update on line 26, ensuring the same data access pattern is used throughout the component.

src/apps/pillarx-app/components/TokensVerticalList/TokensVerticalList.tsx (4)

1-1: Added EtherSpot utility import

The import of useEtherspotUtils enables address validation capabilities that are utilized later in the component.


7-9: Added utility imports for blockchain data handling

These imports bring in functionality needed for token contract validation and blockchain name mapping, supporting the enhanced token navigation logic.


21-21: Extracted address validation utility

The extraction of isZeroAddress from the Etherspot utilities hook provides a clean way to validate token contract addresses.


28-53: Enhanced token navigation logic

The improved implementation:

  1. Finds compatible token contracts by matching against supported blockchains
  2. Constructs navigation URLs with address validation
  3. Adds blockchain context to the navigation URL

This makes token navigation more reliable and contextual, supporting the endpoint replacement objectives of the PR.

src/apps/token-atlas/reducer/tokenAtlasSlice.ts (4)

35-35: Added token data error tracking state

This new boolean property enhances error handling capabilities, allowing the application to track and respond to token data API errors.


58-58: Initialized token data error state

The initial state is appropriately set to false, assuming no errors by default.


125-127: Added reducer for token data error state

This new reducer function allows components to update the error state when token data API requests fail, improving error handling throughout the application.


148-148: Exported token data error action

The action is properly exported, making it available for use in components that need to update the error state.

src/apps/token-atlas/components/TokensSlider/test/TokenSlider.test.tsx (3)

27-27: Updated mock data structure to match new API schema.

The property name has been changed from data to result in the mockTrendingTokens object to align with the updated API response structure used throughout the application.


33-33: Updated blockchain names to realistic values.

The mock blockchain names have been replaced with actual chain names ('Ethereum' and 'Polygon') instead of generic placeholders ('blockchain1' and 'blockchain2'), which improves test clarity and better represents real-world data.

Also applies to: 40-40


134-134: Updated expected chainId in token selection test.

The expected chainId value is now correctly set to 1 (Ethereum) instead of undefined, which properly reflects the expected behavior when a token on the Ethereum chain is selected.

src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx (2)

26-30: Added necessary utility imports for blockchain compatibility.

The added imports provide essential functionality for blockchain name standardization and chain ID mapping, which enhances the component's ability to work with tokens across different blockchains.


110-123:

Details

✅ Verification successful

Enhanced token selection logic with blockchain compatibility.

The implementation now correctly identifies a compatible token contract and determines the appropriate chainId using utility functions. This ensures that selected tokens are properly associated with the correct blockchain network.

Verify that chainNameToChainIdTokensData handles all potential blockchain names properly:


🏁 Script executed:

#!/bin/bash
# Check if any contract might have a blockchain name not handled by chainNameToChainIdTokensData
rg -A 1 "chainNameToChainIdTokensData\(" src/
# Look at the implementation to verify all cases are covered
cat src/services/tokensData.ts | grep -A 20 "chainNameToChainIdTokensData"

Length of output: 5166


Re: Verified Enhanced Token Selection Logic in TokensSlider

The updated logic in TokensSlider now correctly identifies the compatible token contract and determines the proper chainId by utilizing the chainNameToChainIdTokensData utility. After reviewing its implementation in src/services/tokensData.ts, we can confirm that the function covers all the standard blockchain names used throughout the codebase—namely, Ethereum, Polygon, Base, XDAI, BNB Smart Chain (BEP20), Optimistic, and Arbitrum—and appropriately defaults to 0 for any undefined or unrecognized values.

  • Actionable Note: Ensure that if new blockchain names are introduced in future, the chainNameToChainIdTokensData utility is updated accordingly to avoid relying on the default fallback.
src/apps/the-exchange/components/SwapReceiveCard/SwapReceiveCard.tsx (3)

51-51: Replaced contractAddress with chain parameter.

Using the blockchain identifier directly improves clarity and aligns with the URL parameter structure from Token Atlas.


56-59: Simplified token search query parameters.

The search input now properly focuses on the asset name/symbol, and the blockchain filter uses the chain parameter directly, which streamlines the API call logic.


82-82: Updated useEffect dependencies to match new implementation.

The dependency array now correctly includes only asset and searchData, removing the unused contractAddress dependency. This prevents unnecessary effect re-runs.

src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (4)

1-1: Added Etherspot utility for address validation.

The isZeroAddress utility from useEtherspotUtils provides a reliable way to determine if a token address is valid, which is crucial for creating correct navigation URLs.

Also applies to: 51-51


66-68: Added error state selector for token data.

Adding the isTokenDataErroring selector from the Redux store provides a way to track and respond to token data retrieval errors, improving the user experience by enabling error state handling.


190-191: Enhanced navigation logic with address validation.

The updated navigation URL construction now properly handles both contract tokens and native tokens by checking if the token address is a zero address. This ensures that the correct parameter (address or symbol) is used in the URL.


200-205: Added error feedback for failed token data retrieval.

The new conditional rendering provides clear user feedback when token data cannot be retrieved, instructing users to try searching again. This improves the user experience by explicitly communicating when something goes wrong.

src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (3)

1-1: Import usage is valid.
The newly imported useEtherspotUtils is correctly used later for isZeroAddress.


11-13: Imports successfully centralize complementary utilities.
Fetching chainNameFromViemToMobula and CompatibleChains here helps keep blockchain logic encapsulated in relevant utilities.


30-30: Destructured utility ensures safer address checks.
Using isZeroAddress clarifies the token address validity check and reduces reliance on manual string comparisons.

src/apps/token-atlas/index.tsx (11)

10-12: Newly introduced API imports.
Switching to useGetSearchTokensQuery and useGetTokenMarketDataQuery aligns with the new API naming convention and usage. Ensure references to older hooks are fully removed.


20-20: Clearer state management for token data error.
Adding setIsTokenDataErroring helps distinguish token data error conditions, improving clarity in error handling flows.


30-34: Extended utility imports for chain conversions.
Importing chainIdToChainNameTokensData, chainNameToChainIdTokensData, and convertAPIResponseToTokens offers explicit conversions, improving maintainability across multiple chain naming conventions.

Also applies to: 39-39


136-137: Expose query error for robust error handling.
Renaming and storing the error as tokenDataError clarifies its usage in subsequent error checks.


139-142: Conditional asset vs symbol usage for wrapped or native tokens.
The logic ensures the correct API call params based on whether the token is a wrapped or native asset. Double-check all edge cases, such as unexpected chain IDs or unusual wrapped tokens, to confirm robust coverage.


166-175: Conditional token search query.
Skipping the query if both asset and chain are missing is a sensible approach. If relevant, verify that searching only by chain (no asset) or only by asset (no chain) behaves as intended.


179-180: Safeguard early return on missing search data.
Exiting early when !searchData avoids errors in subsequent processing of searchData?.result.

Also applies to: 181-185


186-205: Token selection logic for native or gas tokens.
This block gracefully handles scenarios where the user clicks on a purely symbolic chain asset, or on a standard contract-based token.


220-220: Dependence on query param changes.
Including [asset, searchData] in the effect ensures the token data updates once relevant queries return results for the provided search input.


232-234: Improved token data error visibility.
This set of conditions accurately sets or clears the token data state, ensuring that the UI consistently reflects data loading or error states.

Also applies to: 238-239, 240-242, 244-244


257-257: Setting graph error states.
Dispatching setIsGraphErroring(true) if the token market history pair fails is consistent with the parallel token error approach. The effect dependencies ensure automatic updates when marketHistoryPair or any of its statuses change.

Also applies to: 260-260

src/types/api.ts (4)

172-172: Mandatory price improves consistency.
Requiring the price: number; field can help normalize consumption of token data. Confirm that all downstream code gracefully handles tokens which might have missing or zero prices in real scenarios.


214-218: Renamed property ensures consistent structure.
Replacing data with result.data clarifies the nested shape and enforces a standard pattern for the API responses, improving type safety.


243-245: Unified trending tokens structure.
Changing TrendingTokens to a result array matches the new pattern, ensuring simpler usage across the codebase.


305-307: Consistent nesting for blockchain data.
Using result: { data: BlockchainData[] } centralizes the list in a standard property, preventing API shape confusion.

src/apps/token-atlas/api/token.ts (6)

22-32: Migration to a retry-wrapped base query.
By introducing fetchBaseMobula with { maxRetries: 5 }, you’re improving resiliency in case of transient network errors.

Also applies to: 36-36


72-102: New tokenMarketData API.
This endpoint’s POST request design appears consistent with the existing pattern for chaining query parameters. Validate the acceptance of id or fallback usage if neither asset nor symbol is provided.


104-121: Introduced blockchainsList API.
Fetching blockchains with 'blockchains' path ensures an updated, standardized list. This is essential for consistent cross-chain references.


123-142: trendingTokens API standardizes trending endpoint.
Aligning trending token data with the new metadata/trendings path plus consistent query parameters fosters uniform usage across the app.


147-147: Registering new APIs in the store.
Calling addMiddleware for new or refactored endpoints ensures Redux integration. Double-check that all old references have been removed to prevent collisions.

Also applies to: 149-149


152-156: Appropriate hook exports for new endpoints.
Exporting useGetTokenMarketDataQuery and useGetBlockchainsListQuery keeps the naming and usage pattern consistent with the RTK Query approach.

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions github-actions bot temporarily deployed to Preview (fix/PRO-3190/hifi-endpoint-replacement) April 10, 2025 12:15 Inactive
@RanaBug RanaBug merged commit 5d91c0d into staging Apr 10, 2025
7 checks passed
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.

2 participants