8000 feat: update `cow.fi` `/tokens` page by cowdan · Pull Request #5889 · cowprotocol/cowswap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: update cow.fi /tokens page #5889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 26, 2025
Merged

feat: update cow.fi /tokens page #5889

merged 5 commits into from
Jun 26, 2025

Conversation

cowdan
Copy link
Contributor
@cowdan cowdan commented Jun 25, 2025

Summary

  • add base, arbitrum, avalanche, and polygon
  • refactor components to remove some TS warnings

Screenshot 2025-06-25 at 16 55 39

To Test

  1. <> Open the page /tokens
  • click on any token
  • it should display the token's platform, including the new ones (if available)

Summary by CodeRabbit

  • New Features

    • Introduced support for additional networks (Base, Arbitrum, Avalanche, Polygon) across token and swap features.
    • Added centralized mappings for network names, logos, and explorer URLs to enhance consistency.
  • Refactor

    • Improved type safety and modularized components for network and token details.
    • Replaced standard image tags with optimized Next.js image components for better performance.
    • Split large components into smaller, reusable subcomponents for clarity and maintainability.
  • Chores

    • Updated image hosting configuration to allow additional external sources.
    • Enhanced token data handling to filter out tokens lacking required descriptions.

8000
- add `base`, `arbitrum`, `avalanche`, and `polygon`
- refactor components to remove some TS warnings
Copy link
vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cowfi ✅ Ready (Inspect) Visit Preview Jun 26, 2025 3:21pm
explorer-dev ✅ Ready (Inspect) Visit Preview Jun 26, 2025 3:21pm
swap-dev ✅ Ready (Inspect) Visit Preview Jun 26, 2025 3:21pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 3:21pm
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 3:21pm
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 3:21pm

@cowdan cowdan requested review from a team June 25, 2025 15:56
Copy link
Contributor
coderabbitai bot commented Jun 25, 2025

Walkthrough

The changes introduce a centralized mapping for blockchain network names, images, and URLs, refactor several components to utilize these mappings for improved type safety and rendering consistency, modularize the TokenDetails component into subcomponents, and update image handling to use Next.js's optimized Image component. Next.js image configuration is also expanded.

Changes

File(s) Change Summary
apps/cow-fi/const/networkMap.ts Added new module exporting NETWORK_MAP, NETWORK_IMAGE_MAP, and NETWORK_URL_MAP for network names, images, and explorer URLs.
apps/cow-fi/components/NetworkItem/index.tsx
apps/cow-fi/components/SwapLinkCard/index.tsx
Refactored to use centralized network mappings, improved type safety for network props, and replaced <img> with Next.js <Image>.
apps/cow-fi/components/TokenDetails/index.tsx Refactored to extract subcomponents for modularity and updated to use centralized network mappings and image handling.
apps/cow-fi/components/TokenPageComponent.tsx Added explicit return type annotation (JSX.Element).
apps/cow-fi/services/tokens/index.ts Expanded supported networks, improved type safety, and added filtering for missing token descriptions.
apps/cow-fi/next.config.ts Updated Next.js config to allow external images from coin-images.coingecko.com.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TokenDetails
    participant NetworkTableComponent
    participant SwapCardsComponent
    participant NetworkItem
    participant SwapLinkCard

    User->>TokenDetails: View token page
    TokenDetails->>TokenDetailsHeading: Render token heading
    TokenDetails->>NetworkTableComponent: Render network table
    NetworkTableComponent->>NetworkItem: Render each network row
    TokenDetails->>SwapCardsComponent: Render swap cards
    SwapCardsComponent->>SwapLinkCard: Render card for each supported network
Loading

Suggested reviewers

  • elena-zh
  • alfetopito

Poem

In fields of code where networks grow,
New maps and images now clearly show.
With types refined and logic neat,
Tokens and swaps are a treat!
🐇 Next.js images hop in with grace,
Modular bunnies keep a tidy place.
Onward, developers—let’s embrace!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
(node:3494) [DEP0169] DeprecationWarning: url.parse() behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for url.parse() vulnerabilities.
(Use node --trace-deprecation ... to show where the warning was created)
[2/4] Fetching packages...
error nx@21.0.3: The engine "node" is incompatible with this module. Expected version "^20.19.0 || ^22.12.0". Got "24.3.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


📜 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 04f434f and 5e0bdda.

📒 Files selected for processing (1)
  • apps/cow-fi/const/networkMap.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/cow-fi/const/networkMap.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Cypress
  • GitHub Check: Setup
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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: 2

🧹 Nitpick comments (1)
apps/cow-fi/components/TokenDetails/index.tsx (1)

78-133: Excellent modularization with comprehensive network support.

The extracted SwapCardsComponent properly handles all supported networks with conditional rendering. The addition of new networks (base, arbitrum, avalanche, polygon) aligns with the PR objectives to expand platform coverage.

Consider extracting the network-to-networkId mapping to a constant for better maintainability:

const NETWORK_ID_MAP = {
  ethereum: 1,
  xdai: 100,
  base: 8453,
  'arbitrum-one': 42161,
  avalanche: 43114,
  'polygon-pos': 137,
} as const
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 13bd0a9 and 126833 8000 7.

⛔ Files ignored due to path filters (4)
  • apps/cow-fi/public/images/arbitrum-chain.svg is excluded by !**/*.svg
  • apps/cow-fi/public/images/avalanche-chain.svg is excluded by !**/*.svg
  • apps/cow-fi/public/images/base-chain.svg is excluded by !**/*.svg
  • apps/cow-fi/public/images/polygon-chain.svg is excluded by !**/*.svg
📒 Files selected for processing (7)
  • apps/cow-fi/components/NetworkItem/index.tsx (2 hunks)
  • apps/cow-fi/components/SwapLinkCard/index.tsx (1 hunks)
  • apps/cow-fi/components/TokenDetails/index.tsx (3 hunks)
  • apps/cow-fi/components/TokenPageComponent.tsx (2 hunks)
  • apps/cow-fi/const/networkMap.ts (1 hunks)
  • apps/cow-fi/next.config.ts (1 hunks)
  • apps/cow-fi/services/tokens/index.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/cow-fi/services/tokens/index.ts (1)
apps/cow-fi/const/networkMap.ts (1)
  • NETWORK_MAP (1-8)
apps/cow-fi/components/TokenDetails/index.tsx (5)
apps/cow-fi/components/TokenDetails/index.styles.ts (5)
  • DetailHeading (136-149)
  • TokenTitle (151-181)
  • NetworkTable (198-202)
  • SwapCardsWrapper (236-243)
  • MainContent (40-47)
apps/cow-fi/components/NetworkItem/styles.ts (1)
  • NetworkHeaderItem (4-25)
apps/cow-fi/components/NetworkItem/index.tsx (1)
  • NetworkItem (22-47)
apps/cow-fi/const/networkMap.ts (1)
  • NETWORK_MAP (1-8)
apps/cow-fi/components/SwapLinkCard/index.tsx (1)
  • SwapLinkCard (15-40)
apps/cow-fi/components/NetworkItem/index.tsx (2)
apps/cow-fi/const/networkMap.ts (3)
  • NETWORK_MAP (1-8)
  • NETWORK_URL_MAP (19-26)
  • NETWORK_IMAGE_MAP (10-17)
apps/cow-fi/components/NetworkItem/styles.ts (1)
  • ItemWrapper (27-110)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Cypress
  • GitHub Check: Setup
🔇 Additional comments (21)
apps/cow-fi/next.config.ts (1)

96-101: LGTM! Proper Next.js image configuration for external sources.

The remotePatterns configuration correctly allows loading images from CoinGecko's CDN, which aligns with the network image handling improvements in the refactored components.

apps/cow-fi/const/networkMap.ts (3)

1-8: Excellent centralization of network constants.

The NETWORK_MAP provides a clean, maintainable way to manage network identifiers and their human-readable names across the application.


19-26: LGTM! Explorer URLs are correctly configured.

The blockchain explorer URLs are accurate for each respective network and follow the correct address path pattern.


10-17: Verify that the image files exist at the specified paths.

The NETWORK_IMAGE_MAP references local image files. Please ensure all these SVG files exist in the /images/ directory to prevent broken images.

#!/bin/bash
# Verify that all network image files exist
echo "Checking for existence of network image files..."

images=(
  "ethereum.svg"
  "base-chain.svg" 
  "arbitrum-chain.svg"
  "avalanche-chain.svg"
  "polygon-chain.svg"
  "gnosis-chain.svg"
)

missing_files=()
for image in "${images[@]}"; do
  if [ ! -f "apps/cow-fi/public/images/$image" ]; then
    missing_files+=("$image")
  fi
done

if [ ${#missing_files[@]} -eq 0 ]; then
  echo "✅ All network image files exist"
else
  echo "❌ Missing image files:"
  printf '%s\n' "${missing_files[@]}"
fi
apps/cow-fi/components/TokenPageComponent.tsx (2)

3-3: Good addition of explicit JSX import.

This improves TypeScript compatibility and follows React 17+ best practices for JSX usage.


27-27: Excellent explicit return type annotation.

The JSX.Element return type improves type safety and aligns with the typing improvements across other components in this PR.

apps/cow-fi/services/tokens/index.ts (4)

3-3: Good import organization.

Moving the backOff import to the top follows standard import ordering conventions.


9-12: Excellent network expansion with proper typing.

The expanded NETWORKS array now supports the new platforms (base, arbitrum, avalanche, polygon) as specified in the PR objectives. The typing using keyof typeof NETWORK_MAP ensures type safety and consistency with the centralized network constants.


35-35: Good immutability improvement.

Changing from let to const for sortedTokens is correct since the variable is not reassigned after the sort operation.


96-99: ```shell
#!/bin/bash
set -e

echo "------ Index.ts snippet (lines 80-140) ------"
sed -n '80,140p' apps/cow-fi/services/tokens/index.ts || echo "Failed to read index.ts"

echo
echo "------ Definition of descriptionFiles ------"
grep -R "descriptionFiles" -n apps/cow-fi/services/tokens/index.ts || echo "No matches for descriptionFiles"

echo
echo "------ apps/cow-fi/data directory structure (files) ------"
find apps/cow-fi/data -maxdepth 2 -type f | sed 's/^/ /'

echo
echo "------ JSON files under apps/cow-fi/data ------"
find apps/cow-fi/data -type f -name "*.json" | sed 's/^/ /'


</details>
<details>
<summary>apps/cow-fi/components/SwapLinkCard/index.tsx (5)</summary>

`1-6`: **Excellent imports for the refactored component.**

The addition of `JSX`, `Image`, and network constants imports supports the improved typing and performance optimizations in the refactored component.

---

`15-22`: **Improved function signature with proper typing.**

The updated function signature with explicit return type `JSX.Element | null` and the use of `NETWORK_IMAGE_MAP` for dynamic image resolution improves both type safety and maintainability.

---

`32-36`: **Excellent optimization with Next.js Image component.**

The replacement of HTML `<img>` tags with Next.js `<Image>` components with explicit dimensions provides better performance through automatic optimization, lazy loading, and proper sizing.

---

`8-13`: ```shell
#!/bin/bash
# Print lines 80–100 of TokenDetails to inspect full SwapLinkCard props for Ethereum
sed -n '80,100p' apps/cow-fi/components/TokenDetails/index.tsx

26-28: ```shell
#!/bin/bash

Retry without type filters to locate swap URL logic and network mappings

echo "Searching for WXDAI and WETH usage across the repo..."
rg "WXDAI|WETH" -n .

echo
echo "Searching for all occurrences of networkId..."
rg "networkId" -n .


</details>
<details>
<summary>apps/cow-fi/components/NetworkItem/index.tsx (4)</summary>

`1-6`: **Excellent import additions for better performance and type safety.**

The imports correctly add React hooks for memoization, Next.js optimized Image component, and centralized network constants for improved maintainability.

---

`18-18`: **Great type safety improvement.**

Changing the network prop from a generic string to `keyof typeof NETWORK_MAP` ensures compile-time validation and prevents invalid network identifiers from being passed.

---

`22-28`: **Well-implemented memoization for performance optimization.**

The useMemo hooks appropriately cache derived values and have correct dependencies. This prevents unnecessary recalculations when the component re-renders.

---

`32-41`: **Excellent use of Next.js Image components with proper attributes.**

The migration from regular img tags to Next.js Image components includes proper width/height specifications and meaningful alt text, which improves performance and accessibility.

</details>
<details>
<summary>apps/cow-fi/components/TokenDetails/index.tsx (2)</summary>

`1-12`: **Well-organized imports for the refactored component.**

The imports correctly include all necessary dependencies for the modularized component structure and performance optimizations.

---

`139-139`: **Excellent component modularization and type safety.**

The refactoring successfully extracts concerns into focused subcomponents while maintaining the original functionality. The explicit return type annotation improves type safety.



Also applies to: 147-147, 186-186, 191-191

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

const { network, platformData } = props
const { address, symbol, name } = platformData

const networkUrl = useMemo(() => `${NETWORK_URL_MAP[network]}/${address}`, [network, address])
const networkImage = useMemo(() => NETWORK_IMAGE_MAP[network], [network])
const networkName = useMemo(() => NETWORK_MAP[network], [network])
Copy link
Collaborator

Choose a reason for hiding this comment

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

useMemo is redundant here (in all 3 places)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

8000
xdai: 'Gnosis Chain',
}

export const NETWORK_IMAGE_MAP: Record<keyof typeof NETWORK_MAP, string> = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: to keep it short we could define a type:

type Network = keyof typeof NETWORK_MAP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, done

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you created the type Network but it's not here. Did you forget to change or doesn't apply in this part?

([network, platformData]) =>
platformData.contractAddress && (
<NetworkItem
key={`${network}-${platformData.contractAddress}`} // TODO: check if this is correct
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's correct

Copy link
Collaborator
@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Question:

  • Where are the COW tokens from Arb1 and Polygon? Maybe we need to add them to the CoW Swap token list for them to show up here? I honestly don't know, just asking.

image
For example, chainlink shows all the chains https://cowfi-git-feat-update-cowfi-tokens-cowswap.vercel.app/tokens/chainlink

  • Can you add the other networks to the dropdown as well (when applicable)
    image

Copy link
Contributor
@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Hey @cowdan , great!
However, some issues from my side:

  1. There are no chains in the tiny swap widget on each token page
    chains
  2. (nitpick) I think, 'Swap on' widgets should be displayed in the same order we display chains in the app. WDYT?
    sort order
    image
  3. I did not check everything, but noticed that chains info is still missing for some tokens:
  • COW: no polygon and Base
    image
  • DAI presents on Ethereum only?
    image
  • aave is missing on GC:
    image
    Could you please check why this is happening?

Thanks

@cowdan
Copy link
Contributor Author
cowdan commented Jun 26, 2025

Question:

  • Where are the COW tokens from Arb1 and Polygon? Maybe we need to add them to the CoW Swap token list for them to show up here? I honestly don't know, just asking.

This page is driven by https://files.cow.fi/tokens/cowFi-tokens.json, I'll need to address this issue in the token-lists repo

  • Can you add the other networks to the dropdown as well (when applicable)

Yes but I'd prefer to address it in a separate PR

@cowdan
Copy link
Contributor Author
cowdan commented Jun 26, 2025

Hey @cowdan , great! However, some issues from my side:

  1. There are no chains in the tiny swap widget on each token page

Yes, it'll be a separate PR

  1. (nitpick) I think, 'Swap on' widgets should be displayed in the same order we display chains in the app. WDYT?

Good suggestion, done

  1. I did not check everything, but noticed that chains info is still missing for some tokens:

As mentioned above, it's an issue that needs to be address in the token-lists repo, then it should be good here

@cowdan cowdan requested review from elena-zh and shoom3301 June 26, 2025 09:16
Copy link
Contributor
@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

del

Copy link
Contributor
@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Hey @cowdan , Approved.
I've opened #5893 and #5892 tasks for you to address issues I reported above in separate PRs.

Copy link
Collaborator
@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Approved. Just one nitpick comment

xdai: 'Gnosis Chain',
}

export const NETWORK_IMAGE_MAP: Record<keyof typeof NETWORK_MAP, string> = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you created the type Network but it's not here. Did you forget to change or doesn't apply in this part?

@cowdan cowdan merged commit c3d969d into develop Jun 26, 2025
14 of 15 checks passed
@cowdan cowdan deleted the feat/update-cowfi-tokens branch June 26, 2025 15:22
@github-actions github-actions bot locked and limited conversation to collaborators Jun 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0