Skip to content

Comments

fix/PRO-3159/polygon-gas-token-updates#273

Merged
RanaBug merged 4 commits intostagingfrom
fix/PRO-3159/polygon-gas-token-updates
Mar 26, 2025
Merged

fix/PRO-3159/polygon-gas-token-updates#273
RanaBug merged 4 commits intostagingfrom
fix/PRO-3159/polygon-gas-token-updates

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Mar 26, 2025

Description

  • Ignore POL token from mobula token lists as already handled as a gas token by data-utils
  • Management of Wrapped tokens in token price history graph

How Has This Been Tested?

  • 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 filtering to accurately identify and display native and wrapped tokens, including modifications to token symbols for clarity.
    • Introduced a new function to convert Mobula blockchain names to chain IDs.
  • Bug Fixes

    • Improved handling of specific token criteria to standardize data and prevent the display of outdated or ambiguous entries.
    • Updated logic to filter out specific contract addresses for better accuracy in token listings.

@RanaBug RanaBug requested a review from IAmKio March 26, 2025 11:38
@RanaBug RanaBug self-assigned this Mar 26, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 26, 2025

Walkthrough

This pull request updates token handling in two modules. In the token atlas module, a new constant isWrappedOrNativeToken is introduced, which modifies how query parameters (id and asset) are set based on whether the token is native or wrapped. Additionally, a new function getSymbol adjusts the symbol for specific wrapped tokens. In the tokens data service, conditional checks standardize the naming for tokens labeled as 'POL (ex-MATIC)' and filter out tokens with a specific contract address.

Changes

File(s) Change Summary
src/apps/token-atlas/index.tsx Added isWrappedOrNativeToken to check if a token is native or wrapped, and introduced getSymbol to modify token symbols for 'WETH' and 'WXDAI'.
src/services/tokensData.ts Inserted conditionals to normalize tokens named 'POL (ex-MATIC)', adjusting them to 'POL', and filtering out tokens with a specific contract address.

Possibly related PRs

Suggested reviewers

  • IAmKio

Poem

I’m a rabbit with hops so spry,
Leaping through tokens, oh my my!
Wrapped or native, I check with care,
Filtering tokens here and there.
CodeRabbit cheers with a joyful ear!
🐰🌟
Keep on coding without a sigh!


📜 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 1407c37 and 6467eaf.

📒 Files selected for processing (1)
  • src/services/tokensData.ts (5 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/services/tokensData.ts (1)
src/utils/blockchain.ts (1)
  • CompatibleChains (218-235)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (8)
src/services/tokensData.ts (8)

42-46: Well-written function documentation.

The added documentation clearly explains the purpose of the loadTokensData function, making the code more maintainable and understandable for other developers.


48-51: Good contextual documentation.

These comments effectively explain the blockchains compatibility logic and the renaming process, which helps other developers understand the relationship with the CompatibleChains constant.


56-60: Clear explanation of tokens processing.

The comments provide useful context on how the tokens list is processed and structured, improving code readability.


69-73: Improved documentation for wrapped tokens handling.

The comment clearly explains that certain tokens in Mobula are actually wrapped tokens based on their contract addresses, which provides important context for the code below.


88-91: POL token standardization handles renamed MATIC appropriately.

This conditional ensures the standardization of POL tokens that were previously named MATIC, aligning with the PR objective to address POL token issues in the Polygon network.


93-103: Properly filtering out POL as a gas token.

The added conditional logic and comments correctly implement the PR objective to ignore the POL token from Mobula token lists since it's already managed as a gas token by data-utils.


171-171: Clearer function documentation.

The updated comment more accurately describes what the function does - it converts a chain ID to a Mobula blockchain name rather than just mapping them.


189-205: Good addition of the reverse conversion function.

Adding chainNameToChainIdTokensData creates symmetry with the existing chainIdToChainNameTokensData function and provides a useful utility for converting between chain names and IDs. This helps maintain consistency in token handling across the application.

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 26, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6467eaf
Status: ✅  Deploy successful!
Preview URL: https://69658624.x-e62.pages.dev
Branch Preview URL: https://fix-pro-3159-polygon-gas-tok.x-e62.pages.dev

View logs

@github-actions github-actions bot temporarily deployed to Preview (fix/PRO-3159/polygon-gas-token-updates) March 26, 2025 12:02 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 (2)
src/apps/token-atlas/index.tsx (2)

81-86: Consider adding a comment explaining the special handling for wrapped/native tokens

The new isWrappedOrNativeToken constant adds special handling for wrapped tokens like POL, WETH, and WXDAI. While this addresses the PR objective for managing the POL token differently, adding a comment explaining the rationale would improve maintainability.

Also, the current approach using exact string matching might be brittle if token metadata changes (e.g., capitalization, formatting).

+// Identifies tokens that need special handling in queries:
+// - Native tokens (like MATIC on Polygon)
+// - Wrapped tokens that represent native tokens of other chains
 const isWrappedOrNativeToken =
   isNativeToken ||
   (selectedToken.name === 'POL' && selectedToken.symbol === 'POL') ||
   (selectedToken.name === 'Wrapped Ether' &&
     selectedToken.symbol === 'WETH') ||
   (selectedToken.name === 'Wrapped XDAI' && selectedToken.symbol === 'WXDAI');

88-96: Document the purpose of symbol transformation for wrapped tokens

The getSymbol function transforms wrapped token symbols to their unwrapped equivalents, which aligns with the PR objective to update the management of wrapped tokens. However, there's no transformation for POL even though it's included in isWrappedOrNativeToken.

Consider documenting why this transformation is necessary for the token price graph and info queries.

+// Transforms wrapped token symbols to their native equivalents for API queries
+// This ensures consistent price data retrieval for both wrapped and unwrapped tokens
 const getSymbol = (symbol: string) => {
   if (isWrappedOrNativeToken && symbol === 'WETH') {
     return 'ETH';
   }
   if (isWrappedOrNativeToken && symbol === 'WXDAI') {
     return 'XDAI';
   }
   return symbol;
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f529995 and 3e7c7c3.

📒 Files selected for processing (1)
  • src/apps/token-atlas/index.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unit-tests
  • GitHub Check: Cloudflare Pages
  • GitHub Check: build
🔇 Additional comments (1)
src/apps/token-atlas/index.tsx (1)

104-108:

Details

❓ Verification inconclusive

Verify the API behavior when omitting id and asset parameters

For wrapped or native tokens, both id and asset parameters are set to undefined, which means the API queries will rely solely on the transformed symbol. Does the API handle this case correctly for all tokens, especially POL which has no symbol transformation?

Consider adding a comment explaining why this approach is correct for these tokens or verify that relying only on the symbol provides accurate results.

Also applies to: 116-120


🏁 Script executed:

#!/bin/bash
# Check whether the API properly handles queries with only symbol parameter

# Search for the token API schema or implementation to verify expected behavior
echo "Searching for token API implementation..."
rg -A 10 "useGetTokenInfoQuery|useGetTokenGraphQuery" --glob "**/*.{ts,tsx}" --exclude "index.tsx"

Length of output: 603


Below is a new shell script to re-run the search with the correct exclusion syntax. This will help us locate the token API implementation (e.g., usage of useGetTokenInfoQuery or useGetTokenGraphQuery) in the codebase:

Once this command produces output (or if manual verification is required), please verify that the API indeed handles queries where both the id and asset parameters are omitted—relying solely on the transformed symbol—in all cases (especially tokens like POL that might not undergo any symbol transformation).

Based on this verification, update the code by either adding a clarifying inline comment that documents why it’s safe to rely on symbol only for wrapped/native tokens or by adjusting the API call if needed.

Action Required: Please verify that the API correctly processes token queries with only the symbol parameter (with id and asset omitted). Also, consider adding an inline comment here (in src/apps/token-atlas/index.tsx at lines 104–108 and 116–120) explaining this fallback logic for wrapped/native tokens.


🏁 Script executed:

#!/bin/bash
# Corrected command: using -g to exclude index.tsx properly
rg -A 10 "useGetTokenInfoQuery|useGetTokenGraphQuery" -g '!index.tsx'

Length of output: 569


Action Required: Verify API fallback behavior for wrapped/native tokens

The verification script confirmed that the token API endpoints (i.e. useGetTokenInfoQuery and useGetTokenGraphQuery) are defined in src/apps/token-atlas/api/token.ts. However, it's still unclear from the implementation whether the API correctly handles cases when both id and asset parameters are omitted—relying solely on the transformed symbol—especially for tokens like POL that lack symbol transformation.

  • Please manually verify that the API processes queries based only on the symbol when the token is wrapped or native.
  • Consider adding inline comments in src/apps/token-atlas/index.tsx (lines 104–108 and 116–120) to document why it's safe to rely on symbol only for these tokens, assuming manual verification confirms correct API behavior.

@github-actions github-actions bot temporarily deployed to Preview (fix/PRO-3159/polygon-gas-token-updates) March 26, 2025 14:35 Inactive
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!

Co-authored-by: I Am Kio <kieran@digitalindustria.com>
@RanaBug RanaBug merged commit 85fa601 into staging Mar 26, 2025
7 checks passed
@RanaBug RanaBug deleted the fix/PRO-3159/polygon-gas-token-updates branch April 3, 2025 09:08
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