8000 fix: Buy COW link by elena-zh · Pull Request #5899 · cowprotocol/cowswap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Buy COW link #5899

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 4 commits into from
Jun 30, 2025
Merged

fix: Buy COW link #5899

merged 4 commits into from
Jun 30, 2025

Conversation

elena-zh
Copy link
Contributor
@elena-zh elena-zh commented Jun 27, 2025

Summary

It appeared that the way how 'Buy COW' link is build is deprecated

In this PR I gave a try to fix it.

Steps:

  1. Open https://swap-dev-git-fix-buy-cow-link-cowswap-dev.vercel.app/#/account
  2. Press on the 'Buy COW link on the COW widget
    image

AR: it should navigate to the Swap widget with [native token]/COW tokens in the fields.
image

  1. Check in all chains.

Summary by CodeRabbit

  • New Features
    • Updated the "Buy COW" link to use a new URL format that includes the current network and token addresses for improved clarity and accuracy when navigating to the swap page.

Copy link
vercel bot commented Jun 27, 2025

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

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

Copy link
Contributor
coderabbitai bot commented Jun 27, 2025

Walkthrough

The change updates the construction of the "Buy COW" link in the Profile component by switching from a query parameter-based URL to a path-based format that explicitly includes the chain ID, the wrapped native token address, and the COW contract address. The wrapped native currency is now dynamically determined based on the current chain ID.

Changes

File(s) Change Summary
apps/cowswap-frontend/src/pages/Account/Balances.tsx Added import for wrapped native currencies, derived the wrapped token using chain ID, and updated the "Buy COW" link to use a path-based URL format with explicit addresses.

Suggested reviewers

  • cowdan

Poem

A hop and a skip through the code I go,
Updating the link so the path will show,
Wrapped tokens and COW, now clear in the route,
With chain IDs in place, there’s never a doubt.
🐇✨

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:24426) [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 05d60a9 and 2153572.

📒 Files selected for processing (1)
  • apps/cowswap-frontend/src/pages/Account/Balances.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/cowswap-frontend/src/pages/Account/Balances.tsx
⏰ 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 8000 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.

@vercel vercel bot temporarily deployed to Preview – explorer-dev June 27, 2025 14:25 Inactive
@vercel vercel bot temporarily deployed to Preview – cosmos June 27, 2025 14:25 Inactive
@vercel vercel bot temporarily deployed to Preview – widget-configurator June 27, 2025 14:25 Inactive
@vercel vercel bot temporarily deployed to Preview – sdk-tools June 27, 2025 14:25 Inactive
@elena-zh elena-zh marked this pull request as ready for review June 27, 2025 14:50
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

🧹 Nitpick comments (1)
apps/cowswap-frontend/src/pages/Account/Balances.tsx (1)

61-61: Add runtime safety check for wrapped native token.

While the current implementation accesses WETH[chainId] directly, consider adding a safety check to handle cases where the wrapped native token might be undefined for unsupported chains.

-  const nativeWrappedToken = WETH[chainId]
+  const nativeWrappedToken = WETH[chainId]
+  
+  if (!nativeWrappedToken) {
+    console.warn(`No wrapped native token found for chain ${chainId}`)
+  }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 195ef8f and 05d60a9.

📒 Files selected for processing (1)
  • apps/cowswap-frontend/src/pages/Account/Balances.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: shoom3301
PR: cowprotocol/cowswap#5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.
Learnt from: cowdan
PR: cowprotocol/cowswap#5715
File: libs/common-const/src/tokens.ts:539-555
Timestamp: 2025-05-26T12:39:29.009Z
Learning: The team accepts using NATIVE_CURRENCY_ADDRESS as a temporary placeholder for COW token contract addresses on new networks (Polygon, Avalanche) until actual COW contracts are deployed.
Learnt from: fairlighteth
PR: cowprotocol/cowswap#5768
File: apps/cow-fi/components/LearnPageComponent.tsx:184-185
Timestamp: 2025-05-28T16:50:12.273Z
Learning: In apps/cow-fi/components/LearnPageComponent.tsx, the user prefers to keep the inconsistent link behavior where featured articles always open in new tabs (target="_blank") while media coverage links conditionally open in new tabs based on the linkExternal flag. This inconsistency should not be flagged as an issue in future reviews.
apps/cowswap-frontend/src/pages/Account/Balances.tsx (4)
Learnt from: cowdan
PR: cowprotocol/cowswap#5715
File: libs/common-const/src/tokens.ts:539-555
Timestamp: 2025-05-26T12:39:29.009Z
Learning: The team accepts using NATIVE_CURRENCY_ADDRESS as a temporary placeholder for COW token contract addresses on new networks (Polygon, Avalanche) until actual COW contracts are deployed.
Learnt from: shoom3301
PR: cowprotocol/cowswap#5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.
Learnt from: fairlighteth
PR: cowprotocol/cowswap#5768
File: apps/cow-fi/components/LearnPageComponent.tsx:184-185
Timestamp: 2025-05-28T16:50:12.273Z
Learning: In apps/cow-fi/components/LearnPageComponent.tsx, the user prefers to keep the inconsistent link behavior where featured articles always open in new tabs (target="_blank") while media coverage links conditionally open in new tabs based on the linkExternal flag. This inconsistency should not be flagged as an issue in future reviews.
Learnt from: shoom3301
PR: cowprotocol/cowswap#5549
File: apps/cowswap-frontend/src/modules/tradeFlow/services/safeBundleFlow/safeBundleEthFlow.ts:152-152
Timestamp: 2025-04-02T09:58:29.374Z
Learning: In the `safeBundleEthFlow` function, `account` is guaranteed to be truthy based on the type system (`PostOrderParams` defines it as a required string) and the context in which the function is called, so additional runtime checks are unnecessary.
🧬 Code Graph Analysis (1)
apps/cowswap-frontend/src/pages/Account/Balances.tsx (2)
apps/cowswap-frontend/src/modules/trade/containers/TradeWidgetLinks/styled.ts (1)
  • Link (33-47)
libs/common-const/src/common.ts (1)
  • COW_CONTRACT_ADDRESS (71-80)
🪛 GitHub Actions: CI
apps/cowswap-frontend/src/pages/Account/Balances.tsx

[error] 46-46: ESLint: There should be at least one empty line between import groups (import/order)


[error] 47-47: ESLint: '@cowprotocol/common-const' import should occur before import of '@cowprotocol/common-hooks' (import/order)

🔇 Additional comments (1)
apps/cowswap-frontend/src/pages/Account/Balances.tsx (1)

303-303: ```shell
#!/bin/bash

Locate WRAPPED_NATIVE_CURRENCIES and COW_CONTRACT_ADDRESS definitions

Search for WRAPPED_NATIVE_CURRENCIES occurrences with context

rg --context 3 "WRAPPED_NATIVE_CURRENCIES" -n

Search for COW_CONTRACT_ADDRESS occurrences with context

rg --context 3 "COW_CONTRACT_ADDRESS" -n


</details>

</blockquote></details>

</details>

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

@vercel vercel bot temporarily deployed to Preview – explorer-dev June 27, 2025 15:09 Inactive
@vercel vercel bot temporarily deployed to Preview – widget-configurator June 27, 2025 15:09 Inactive
@elena-zh elena-zh requested a review from a team June 27, 2025 15:13
Copy link
Collaborator
@shoom3301 shoom3301 left a comment

Choose a reason for hiding this comment

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

Great job!

@shoom3301 shoom3301 merged commit 52f917e into develop Jun 30, 2025
12 of 15 checks passed
@shoom3301 shoom3301 deleted the fix-buy-cow-link branch June 30, 2025 06:19
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2025
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.

👍

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.

3 participants
0