Skip to content

Comments

feat/update-market-historical-pair-token-atlas-graph#283

Merged
RanaBug merged 5 commits intostagingfrom
feat/update-market-historical-pair-token-atlas-graph
Apr 8, 2025
Merged

feat/update-market-historical-pair-token-atlas-graph#283
RanaBug merged 5 commits intostagingfrom
feat/update-market-historical-pair-token-atlas-graph

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Apr 7, 2025

Description

  • Market History Pair endpoint (from Mobula) implementation
  • Replacement of previous endpoint

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

    • Launched a new market history endpoint to retrieve token trading pair data with enhanced error handling and retry support.
    • Introduced dynamic display settings that adjust graph resolutions based on selected time periods.
  • Refactor

    • Updated components and state management to accommodate a more detailed market data structure, improving how token trends are visualized.
  • Tests

    • Revised test scenarios and data mocks to align with the updated market data format.
  • Chores

    • Optimized retry parameters for smoother API interactions.

@RanaBug RanaBug requested a review from IAmKio April 7, 2025 11:06
@RanaBug RanaBug self-assigned this Apr 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 7, 2025

Walkthrough

The changes introduce a new API endpoint for retrieving token market history pairs using retry logic (up to 5 attempts). Updates span several files: the API definition in token.ts, state management in the Redux slice, and UI components along with their tests, which now use the new MarketHistoryPairData type instead of the old price history format. A new utility function for graph resolution mapping has been added, and the default token address plus query hooks in the main index file have been updated accordingly.

Changes

File(s) Change Summary
src/apps/token-atlas/api/token.ts
src/services/pillarXApiSearchTokens.ts
Introduced a new API endpoint tokenMarketHistoryPair with endpoint getTokenMarketHistoryPair that uses a retry mechanism (max 5 retries) and exports the hook useGetTokenMarketHistoryPairQuery. In the service file, the maximum retry count was reduced from 10 to 5.
src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx Updated the tokenDataGraph type from TokenMarketHistory to MarketHistoryPairData. Changed references from price_history to result.data for extracting labels (time) and datasets (close prices).
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx Modified the component’s state type from `TokenMarketHistory
src/apps/token-atlas/components/TokenGraph/test/TokenGraph.test.tsx
src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx
Adjusted the mock data structure from a simple price history array (TokenMarketHistory) to a nested result object containing a data array with detailed market data fields. Imports and tests now reference the new MarketHistoryPairData type.
src/apps/token-atlas/index.tsx
src/apps/token-atlas/reducer/tokenAtlasSlice.ts
Replaced useGetTokenGraphQuery with useGetTokenMarketHistoryPairQuery. Updated the default token address and introduced a new periodFilter state. Updated Redux state and action payload types so that tokenDataGraph uses the new MarketHistoryPairData type.
src/apps/token-atlas/utils/converters.ts
src/types/api.ts
Added a new function getGraphResolution that maps a PeriodFilter to a resolution string. Introduced the new type MarketHistoryPairData defining the structure for market history data.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant Hook as useGetTokenMarketHistoryPairQuery
    participant API as Token API Endpoint
    participant Retry as Retry Handler
    participant Store as Redux Store

    UI->>Hook: Trigger market history query with parameters
    Hook->>API: Call getTokenMarketHistoryPair (POST request)
    API->>Retry: Process request with retry logic (max 5 attempts)
    Retry-->>API: Return success response or error after retries
    API->>Hook: Return MarketHistoryPairData
    Hook->>Store: Dispatch action to update tokenDataGraph
    Store->>UI: Update component with new market history data
Loading

Possibly related PRs

  • feat/PRO-3166/search-contract-address #275: The changes in the main PR are related to the modifications in the retrieved PR as both involve the introduction and usage of the MarketHistoryPairData type, which is central to the new API and its integration into various components.
  • fix/PRO-3159/polygon-gas-token-updates #273: The changes in the main PR are related to the modifications in the tokenDataGraph type and structure, which are also reflected in the updates to the handling of token data in the retrieved PR, specifically regarding the management of Wrapped tokens and their integration into the token price history graph.
  • fix/sending-tokens-issue #258: The changes in the main PR are related to the introduction of the MarketHistoryPairData type, which is also referenced in the retrieved PR, indicating a shared focus on the new data structure for token market history, although the specific functionalities being modified differ.

Suggested reviewers

  • IAmKio

Poem

Hopping through code with a cheerful beat,
I found new endpoints that just can't be beat.
Market history now dances in pairs so neat,
With retries that keep our API complete. 🐰💻
In every line, innovation and fun meet!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c022cac and 1b79a78.

📒 Files selected for processing (3)
  • src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (6 hunks)
  • src/apps/token-atlas/index.tsx (6 hunks)
  • src/apps/token-atlas/reducer/tokenAtlasSlice.ts (7 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
src/apps/token-atlas/index.tsx (4)
src/apps/token-atlas/hooks/useReducerHooks.tsx (1)
  • useAppSelector (6-6)
src/services/tokensData.ts (1)
  • chainIdToChainNameTokensData (211-232)
src/apps/token-atlas/utils/converters.ts (1)
  • getGraphResolution (28-48)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (3)
  • setTokenDataGraph (87-92)
  • setIsGraphErroring (120-122)
  • setIsGraphLoading (102-104)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (22)
src/apps/token-atlas/index.tsx (8)

10-13: Import updated to use new market history pair query.

The code now imports the new useGetTokenMarketHistoryPairQuery hook which will be used to fetch token market history data from the API.


17-17: Added setIsGraphErroring import to handle API errors.

This import allows the component to properly handle and communicate error states when fetching graph data fails.


28-30: Added utility imports for chain name conversion and graph resolution.

These utility functions support the new market history pair query implementation:

  • chainIdToChainNameTokensData: Converts chain IDs to blockchain names required by the API
  • getGraphResolution: Maps period filters to appropriate time resolution strings

42-50: Updated default token address.

The default token address has been updated to a new Ethereum address for PLR token.


70-72: Added period filter selector.

This selector retrieves the current period filter from Redux state, which is used to determine the appropriate time resolution for the market history data.


138-151: Replaced token graph query with market history pair query.

The component now uses the new useGetTokenMarketHistoryPairQuery hook to fetch token price data, with improved parameters:

  • Uses token address or symbol depending on whether it's a wrapped/native token
  • Includes blockchain name derived from the chain ID
  • Incorporates time resolution based on the selected period filter
  • Maintains the from/to time range from the previous implementation

191-203: Updated effect to handle market history pair data.

The useEffect hook has been updated to:

  1. Set the token graph data when market history pair data is successfully fetched
  2. Clear the graph data when fetching fails
  3. Set the error state appropriately based on API response or errors

This provides better error handling than the previous implementation.


207-214: Updated loading state handling for market history data.

The effect now tracks loading states from the market history pair query to properly display loading indicators in the UI.

src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (8)

27-30: Updated imports to use MarketHistoryPairData type.

The component now imports the new MarketHistoryPairData type which represents the structure of data returned by the market history pair API.


53-56: Updated tokenDataGraph type to MarketHistoryPairData.

The selector now correctly types the token graph data as MarketHistoryPairData | undefined to match the new Redux state structure.


66-68: Added isGraphErroring selector.

This selector enables the component to determine when graph data fetching has failed, allowing for better error handling in the UI.


103-132: Updated graph scale logic to use new data structure.

The graphXScale callback function now correctly references tokenDataGraph?.result.data.length to check if data is available, and the dependency array has been updated to match this new structure.


138-140: Updated empty data check for "data not found" message.

The condition now correctly checks for empty data using tokenDataGraph?.result.data.length instead of the previous structure.


142-149: Added specific error message for graph errors.

This new condition provides a better user experience by displaying a helpful error message when the graph data fetching fails, suggesting that the user try a different timeframe or reload the page.


164-164: Updated labels mapping to use new data structure.

The chart labels are now correctly mapped from tokenDataGraph?.result.data.map((x) => x.time) instead of the previous price history structure.


170-170: Updated price data mapping to use new data structure.

The chart data points are now correctly mapped from tokenDataGraph?.result.data.map((price) => price.close) to display closing prices from the market history data.

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

7-12: Added MarketHistoryPairData type import.

The reducer now imports the new MarketHistoryPairData type to correctly type the token graph data in the state.


18-35: Updated TokenAtlasState to use new data type and added error handling.

Two key changes to the state type:

  1. tokenDataGraph is now typed as MarketHistoryPairData | undefined
  2. Added new isGraphErroring boolean property to track graph data fetch errors

These changes ensure the state properly reflects the new data structure and error handling capabilities.


37-57: Updated initial state with isGraphErroring property.

The initial state now includes isGraphErroring: false, ensuring this new state property is properly initialized.


87-92: Updated setTokenDataGraph action to use MarketHistoryPairData type.

The action now correctly accepts a payload of type PayloadAction<MarketHistoryPairData | undefined> to match the new state structure.


120-122: Added setIsGraphErroring reducer.

This new reducer allows components to update the graph error state when API requests fail, enabling better error handling in the UI.


126-143: Exported setIsGraphErroring action.

The new action is properly exported, making it available for use in components.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db4292f and c022cac.

⛔ Files ignored due to path filters (1)
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • src/apps/token-atlas/api/token.ts (2 hunks)
  • src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (5 hunks)
  • src/apps/token-atlas/components/TokenGraph/test/TokenGraph.test.tsx (2 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (3 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx (1 hunks)
  • src/apps/token-atlas/index.tsx (6 hunks)
  • src/apps/token-atlas/reducer/tokenAtlasSlice.ts (3 hunks)
  • src/apps/token-atlas/utils/converters.ts (2 hunks)
  • src/services/pillarXApiSearchTokens.ts (1 hunks)
  • src/types/api.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (7)
src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx (1)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
src/apps/token-atlas/components/TokenGraph/test/TokenGraph.test.tsx (2)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1)
  • setTokenDataGraph (85-90)
src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (1)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
src/apps/token-atlas/api/token.ts (3)
src/utils/blockchain.ts (1)
  • isTestnet (29-35)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
src/store.ts (1)
  • addMiddleware (48-58)
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (1)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
src/apps/token-atlas/index.tsx (4)
src/apps/token-atlas/hooks/useReducerHooks.tsx (1)
  • useAppSelector (6-6)
src/services/tokensData.ts (1)
  • chainIdToChainNameTokensData (211-232)
src/apps/token-atlas/utils/converters.ts (1)
  • getGraphResolution (28-48)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (2)
  • setTokenDataGraph (85-90)
  • setIsGraphLoading (100-102)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1)
src/types/api.ts (1)
  • MarketHistoryPairData (432-443)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (33)
src/services/pillarXApiSearchTokens.ts (1)

22-22: Reduced retry count looks appropriate.

The change from 10 to 5 retries is reasonable, as 5 attempts should be sufficient to handle transient API issues while preventing excessive wait times for clients when the service is genuinely unavailable.

src/types/api.ts (1)

432-443: Well-structured type definition for market data.

The MarketHistoryPairData type follows standard OHLCV (Open, High, Low, Close, Volume) structure commonly used in financial charts, with an appropriate timestamp field. This will provide good type safety when working with the market history data from the API.

src/apps/token-atlas/utils/converters.ts (2)

1-1: Import added for new utility function.

The PeriodFilter import is correctly added to support the new graph resolution function.


28-48: Good implementation of time-based resolution mapping.

The getGraphResolution function properly maps different time periods to appropriate data granularity. The implementation includes clear comments explaining each resolution and handles all cases with a sensible default.

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

18-18: Updated import to use new data type.

The import is correctly updated from TokenMarketHistory to MarketHistoryPairData to align with the new data structure being used.


26-55: Well-structured test data for the new format.

The mock data has been thoroughly updated to match the new MarketHistoryPairData type. The test data includes multiple entries with realistic values for all required fields (volume, open, high, low, close, time), which provides good test coverage for the component.


105-105: Test case correctly updated for empty data scenario.

The empty data test case has been properly updated to use the new data structure, ensuring that the "no data" scenario is still being tested.

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

20-21: Updated import to use MarketHistoryPairData type

The import has been changed from TokenMarketHistory to MarketHistoryPairData to reflect the new data structure used for token market history data.


25-53: Updated mock data structure to match new API response format

The mock data structure has been updated to match the new MarketHistoryPairData type, which has a nested structure with a result object containing a data array of OHLCV (Open, High, Low, Close, Volume) price points. This change is consistent with the updated API response format.

Each data point now includes:

  • volume, open, high, low, close values
  • time as a Unix timestamp (instead of the previous timestamp format)

This change ensures the test accurately reflects the actual data structure used in the application.

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

11-13: Updated imports to include the new market history pair query

The imports have been modified to include useGetTokenMarketHistoryPairQuery which replaces the previous useGetTokenGraphQuery, reflecting the transition to the new API endpoint for retrieving token market history data.


27-29: Added imports for chain name mapping and graph resolution

New utility imports have been added:

  1. chainIdToChainNameTokensData - Used for converting chain IDs to blockchain names required by the new API
  2. getGraphResolution - Used for determining the appropriate graph resolution based on the period filter

These utilities support the new market history pair API requirements.


41-49: Updated default token address

The default token address has been updated to a specific Ethereum address for the PLR token. This ensures that when no token is explicitly selected, the application will display data for the PLR token.


69-71: Added selector for period filter

A new selector for the periodFilter has been added to retrieve the current period filter state from Redux. This is used to determine the appropriate graph resolution for the market history pair API query.


137-149: Replaced token graph query with market history pair query

The previous token graph query has been replaced with the new market history pair query. The new query:

  1. Uses more descriptive variable names (marketHistoryPair, isMarketHistoryPairLoading, etc.)
  2. Passes the required parameters to the API:
    • asset or symbol depending on token type
    • blockchain name derived from chain ID
    • period resolution based on the selected period filter
    • time range parameters (from/to)

This implementation properly handles the transition to the new API endpoint.


189-196: Updated effect hook for token graph data

The useEffect hook for updating the token graph data has been modified to use the new market history pair query response. It now checks for marketHistoryPair and isMarketHistoryPairSuccess instead of the previous variables.


200-207: Updated effect hook for graph loading status

The useEffect hook for updating the graph loading status has been modified to use the new market history pair loading and fetching states. This ensures the loading indicator is displayed appropriately while the new API is fetching data.

src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (6)

27-30: Updated imports to use MarketHistoryPairData type

The imports have been updated to use the new MarketHistoryPairData type instead of the previous TokenMarketHistory type, reflecting the change in the data structure used for token market history.


53-56: Updated tokenDataGraph type

The type of tokenDataGraph has been updated to MarketHistoryPairData | undefined to match the new data structure returned by the API. This ensures type safety throughout the component.


99-103: Updated data access pattern in comments and code

The comment and code have been updated to reflect the new data structure. The component now checks for tokenDataGraph?.result.data.length instead of the previous structure.


128-129: Updated dependency array for useCallback

The dependency array for the graphXScale callback has been updated to use tokenDataGraph?.result.data.length to match the new data structure. This ensures the callback is correctly re-computed when the data changes.


135-137: Updated conditional check for empty data

The conditional check for empty data has been updated to use !tokenDataGraph?.result.data.length to match the new data structure. This ensures the "Price history not found" message is displayed correctly when there is no data.


151-159: Updated data mapping for chart

The data mapping for the chart has been updated to use the new data structure:

  1. Labels now use tokenDataGraph.result.data.map((x) => x.time) to extract timestamps
  2. Dataset data now uses tokenDataGraph.result.data.map((price) => price.close) to extract closing prices

This correctly maps the OHLCV data to the chart's expected format.

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

1-1: Added retry import for implementing retry logic

The import statement has been updated to include retry from Redux Toolkit, which is used to implement retry logic for API requests that might fail temporarily.


9-10: Added import for MarketHistoryPairData type

Import for the MarketHistoryPairData type has been added, which defines the structure of the response from the new market history pair API endpoint.


96-106: Implemented retry logic for API requests

A new fetch base query with retry logic has been created:

const fetchBaseTokenMarketHistoryPairWithRetry = retry(
  fetchBaseQuery({
    baseUrl: isTestnet
      ? 'https://hifidata-nubpgwxpiq-uc.a.run.app'
      : 'https://hifidata-7eu4izffpa-uc.a.run.app',
    headers: {
      'Content-Type': 'application/json',
    },
  }),
  { maxRetries: 5 }
);

This implementation:

  1. Uses the appropriate base URL based on whether the app is in testnet mode
  2. Sets the content type header to JSON
  3. Configures retry behavior with a maximum of 5 retries for failed requests

This improves reliability when fetching market history data, which is essential for a good user experience.


108-144: Added new API for token market history pairs

A new API has been created for fetching token market history pairs:

  1. Uses a unique reducer path 'tokenMarketHistoryPair'
  2. Uses the base query with retry logic
  3. Implements the getTokenMarketHistoryPair endpoint that:
    • Accepts parameters for asset, symbol, blockchain, period, time range, and amount
    • Constructs a POST request with the appropriate path and parameters
    • Returns data in the MarketHistoryPairData format

This implementation properly replaces the previous token graph API with a more robust solution.


153-153: Added new API to store middleware

The new token market history pair API has been added to the store middleware using addMiddleware(tokenMarketHistoryPair). This ensures the API is properly integrated with the Redux store.


159-159: Exported hook for the new API

The hook useGetTokenMarketHistoryPairQuery has been exported, making it available for use in components that need to fetch market history data.

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

9-10: Import updated correctly to use MarketHistoryPairData.

The import statement has been properly updated to include the new MarketHistoryPairData type, which is a part of replacing the previous endpoint with the Market History Pair endpoint from Mobula.


25-25: Type definition properly updated for tokenDataGraph.

The tokenDataGraph property type in the TokenAltasState interface has been correctly updated to use the new MarketHistoryPairData type. This aligns with the implementation of the new Market History Pair endpoint.


87-87: Action payload type updated correctly.

The setTokenDataGraph action's payload type has been properly updated to use MarketHistoryPairData, ensuring type safety throughout the state management flow.

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

18-21: Imports updated correctly to use new types.

The imports have been properly updated to include both MarketHistoryPairData and TokenAtlasInfoData, using a named imports structure to better organize the code.


50-52: Type assertion updated for MarketHistoryPairData.

The type assertion for the tokenDataGraph state selector has been correctly updated to match the new data structure.

Comment on lines +223 to +226
tokenDataGraph?.result.data.length
? 'hover:bg-green hover:text-dark_grey'
: ''
} ${periodFilter === filter && tokenDataGraph?.price_history ? 'bg-green text-dark_grey' : 'text-white_grey bg-medium_grey'}`}
} ${periodFilter === filter && tokenDataGraph?.result.data.length ? 'bg-green text-dark_grey' : 'text-white_grey bg-medium_grey'}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add null check for tokenDataGraph.result.

The current implementation might cause runtime errors if tokenDataGraph is defined but tokenDataGraph.result is undefined. Consider adding a more defensive check.

- tokenDataGraph?.result.data.length
+ tokenDataGraph?.result?.data?.length

This ensures the component handles cases where the response might have an unexpected structure or when partial data is available.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tokenDataGraph?.result.data.length
? 'hover:bg-green hover:text-dark_grey'
: ''
} ${periodFilter === filter && tokenDataGraph?.price_history ? 'bg-green text-dark_grey' : 'text-white_grey bg-medium_grey'}`}
} ${periodFilter === filter && tokenDataGraph?.result.data.length ? 'bg-green text-dark_grey' : 'text-white_grey bg-medium_grey'}`}
tokenDataGraph?.result?.data?.length
? 'hover:bg-green hover:text-dark_grey'
: ''
} ${periodFilter === filter && tokenDataGraph?.result?.data?.length ? 'bg-green text-dark_grey' : 'text-white_grey bg-medium_grey'}`}

@cloudflare-workers-and-pages
Copy link

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

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1b79a78
Status: ✅  Deploy successful!
Preview URL: https://1d821384.x-e62.pages.dev
Branch Preview URL: https://feat-update-market-historica.x-e62.pages.dev

View logs

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!

@RanaBug RanaBug merged commit a3eb429 into staging Apr 8, 2025
7 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 23, 2025
3 tasks
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