-
Notifications
You must be signed in to change notification settings - Fork 149
Main -> Develop #6116
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
Main -> Develop #6116
Conversation
…ge (#6108) * chore: remove Cow token from Polygon's favorite tokens and Account page * chore: address CR comment
* chore: bump cow-sdk version * chore: bump to latest app-data * test: update snapshot * refactor: use default appData instead of hardcoded
chore: release 2025-08-06
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
WalkthroughThis update modifies environment variable handling for app data, refactors related TypeScript utilities, updates wallet connection logic, adjusts the default favorite tokens for Polygon, adds a new Ethereum token list source, and bumps dependencies. Several exported functions now have explicit return types, and some imports are cleaned up or added. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ConnectWalletOptions
participant MetaMaskSdkOption
participant InjectedOptions
User->>ConnectWalletOptions: Render wallet options
ConnectWalletOptions->>InjectedOptions: Render injected providers
InjectedOptions-->>ConnectWalletOptions: Render all providers (including MetaMask)
alt No injected MetaMask & not mobile
ConnectWalletOptions->>MetaMaskSdkOption: Render MetaMask SDK option
else
ConnectWalletOptions->>MetaMaskSdkOption: Render null
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Suggested labels
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (15)
✅ Files skipped from review due to trivial changes (15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
There was a problem hiding this 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)
libs/wallet/src/web3-react/Web3Provider/hooks/useEagerlyConnect.ts (1)
35-35: LGTM! Consider applying consistent typing to other functions.The explicit
voidreturn type annotation improves type safety and aligns with TypeScript best practices.However, for consistency, consider adding explicit return type annotations to the
connectfunction (lines 18-32) as well, which currently has a TODO comment indicating this need.-// TODO: Add proper return type annotation -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -async function connect(connector: Connector) { +async function connect(connector: Connector): Promise<void> {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
apps/cowswap-frontend/src/modules/twap/services/__snapshots__/createTwapOrderTxs.test.ts.snapis excluded by!**/*.snapyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (8)
apps/cowswap-frontend/.env(1 hunks)apps/cowswap-frontend/src/modules/appData/utils/fullAppData.ts(1 hunks)apps/cowswap-frontend/src/modules/wallet/containers/ConnectWalletOptions.tsx(3 hunks)libs/tokens/src/const/defaultFavoriteTokens.ts(1 hunks)libs/tokens/src/const/tokensList.json(1 hunks)libs/wallet/src/web3-react/Web3Provider/hooks/useEagerlyConnect.ts(1 hunks)libs/wallet/src/web3-react/connection/metaMaskSdk.tsx(2 hunks)package.json(1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: alfetopito
PR: cowprotocol/cowswap#5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.
📚 Learning: the swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in pr #5444 as par...
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.
Applied to files:
apps/cowswap-frontend/.env
📚 Learning: the team accepts using native_currency_address as a temporary placeholder for cow token contract add...
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.
Applied to files:
libs/tokens/src/const/defaultFavoriteTokens.ts
📚 Learning: token lists for cow swap are maintained in a separate repository at https://github.com/cowprotocol/t...
Learnt from: alfetopito
PR: cowprotocol/cowswap#5992
File: libs/tokens/src/const/tokensList.json:135-167
Timestamp: 2025-07-18T08:07:55.497Z
Learning: Token lists for CoW Swap are maintained in a separate repository at https://github.com/cowprotocol/token-lists, not in the main cowswap repository. Issues related to missing token lists should be tracked in the token-lists repository.
Applied to files:
libs/tokens/src/const/defaultFavoriteTokens.tslibs/tokens/src/const/tokensList.json
📚 Learning: on polygon, the native usdc address is 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359, while 0x2791bca1f...
Learnt from: cowdan
PR: cowprotocol/cowswap#5715
File: libs/common-const/src/tokens.ts:378-407
Timestamp: 2025-05-26T12:45:05.113Z
Learning: On Polygon, the native USDC address is 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359, while 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 is the bridged USDC. The native USDC should be preferred over the bridged version for token definitions.
Applied to files:
libs/tokens/src/const/defaultFavoriteTokens.ts
📚 Learning: in libs/wallet/src/web3-react/utils/switchchain.ts, the team prefers using record
Learnt from: alfetopito
PR: cowprotocol/cowswap#5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.
Applied to files:
libs/wallet/src/web3-react/Web3Provider/hooks/useEagerlyConnect.ts
apps/cowswap-frontend/src/modules/wallet/containers/ConnectWalletOptions.tsx
apps/cowswap-frontend/src/modules/appData/utils/fullAppData.ts
libs/wallet/src/web3-react/connection/metaMaskSdk.tsx
Learnt from: alfetopito
PR: cowprotocol/cowswap#5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.
libs/wallet/src/web3-react/Web3Provider/hooks/useEagerlyConnect.tsapps/cowswap-frontend/src/modules/wallet/containers/ConnectWalletOptions.tsxapps/cowswap-frontend/src/modules/appData/utils/fullAppData.tslibs/wallet/src/web3-react/connection/metaMaskSdk.tsx📚 Learning: jsx can be imported as a named export from react in modern react versions (react 17+). the import `i...
Learnt from: alfetopito
PR: cowprotocol/cowswap#5830
File: apps/cowswap-frontend/src/modules/trade/containers/TradeWidget/index.tsx:1-2
Timestamp: 2025-06-16T15:58:00.268Z
Learning: JSX can be imported as a named export from React in modern React versions (React 17+). The import `import { JSX } from 'react'` is valid and does not cause compilation errors.
Applied to files:
libs/wallet/src/web3-react/connection/metaMaskSdk.tsx
🧬 Code Graph Analysis (2)
apps/cowswap-frontend/src/modules/wallet/containers/ConnectWalletOptions.tsx (3)
libs/common-utils/src/userAgent.ts (1)
isMobile(40-40)libs/wallet/src/web3-react/connection/metaMaskSdk.tsx (1)
MetaMaskSdkOption(45-56)libs/wallet/src/index.ts (1)
MetaMaskSdkOption(53-53)
apps/cowswap-frontend/src/modules/appData/utils/fullAppData.ts (2)
libs/common-utils/src/environments.ts (2)
EnvironmentName(77-77)environmentName(79-97)apps/cowswap-frontend/src/modules/appData/types.ts (1)
AppDataInfo(4-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Setup
- GitHub Check: Cypress
🔇 Additional comments (16)
libs/wallet/src/web3-react/connection/metaMaskSdk.tsx (2)
1-1: LGTM! Proper ReactNode import added.The ReactNode import is correctly added to support the explicit return type annotation.
45-45: LGTM! Explicit return type improves type safety.The explicit
ReactNodereturn type annotation enhances type safety and aligns with TypeScript best practices for React components.apps/cowswap-frontend/src/modules/wallet/containers/ConnectWalletOptions.tsx (3)
26-26: LGTM! Explicit return type improves type safety.The explicit
ReactNodereturn type annotation enhances type safety and maintains consistency with other React components in the codebase.
38-42: LGTM! Improved MetaMask SDK option logic.The conditional rendering logic correctly prevents duplicate MetaMask options by:
- Checking for existing injected MetaMask providers (
hasInjectedMetaMask)- Avoiding SDK option on mobile devices where it's not needed
- Only showing the SDK option when no native MetaMask injection is detected
This provides a better user experience by avoiding redundant wallet connection options.
88-88: LGTM! Consistent return type annotation.The explicit
ReactNodereturn type maintains consistency with the parent component and improves type safety.package.json (2)
77-77: LGTM!The minor version bump from
^3.2.0to^3.3.0aligns with the app data refactoring seen in the codebase.
81-81: LGTM!The SDK version update from
6.0.0-RC.80to6.1.0-RC.0appears to be a coordinated update with the app data changes.libs/tokens/src/const/tokensList.json (1)
16-20: Ondo Protocol Token List URL Verified
- File:
libs/tokens/src/const/tokensList.json(lines 16–20)
The URL responds with HTTP 200 and returns valid JSON as expected.
No further changes needed.libs/tokens/src/const/defaultFavoriteTokens.ts (1)
96-102: LGTM!Good decision to remove
COW_TOKEN_POLYGONfrom default favorites due to lack of liquidity. The explanatory comment provides helpful context for future maintainers.apps/cowswap-frontend/.env (1)
63-69: LGTM!Clearing the app data environment variables aligns well with the refactoring in
fullAppData.tswhere app data is now managed programmatically with proper fallbacks. This approach is more maintainable than embedding JSON strings in environment variables.apps/cowswap-frontend/src/modules/appData/utils/fullAppData.ts (6)
1-1: LGTM!Good addition of the import for
LATEST_APP_DATA_VERSIONfrom the updated@cowprotocol/app-datapackage, replacing hardcoded version values.
4-4: LGTM!The relative import path suggests proper file organization.
26-28: Good addition of explicit return type.Adding
AppDataInforeturn type annotation improves code clarity and follows TypeScript best practices.
30-34: Good addition of explicit return type.Adding
voidreturn type annotation for this side-effect function is appropriate and follows TypeScript best practices.
36-38: LGTM!The simplified lookup using the
APP_DATA_PER_ENVrecord with fallback toDEFAULT_FULL_APP_DATAis clean and efficient.
40-44: Well-designed helper function.The
addEnvToDefaultAppDatafunction properly extends the default app data object with environment information and returns a properly serialized JSON string. The shallow copy with spread operator is appropriate here.
| const DEFAULT_FULL_APP_DATA_OBJ = { version: LATEST_APP_DATA_VERSION, appCode: 'CoW Swap', metadata: {} } | ||
| const DEFAULT_FULL_APP_DATA = JSON.stringify(DEFAULT_FULL_APP_DATA_OBJ) | ||
|
|
||
| const APP_DATA_PER_ENV: Record<EnvironmentName, string> = { | ||
| production: process.env.REACT_APP_FULL_APP_DATA_PRODUCTION || addEnvToDefaultAppData('production'), | ||
| ens: process.env.REACT_APP_FULL_APP_DATA_ENS || addEnvToDefaultAppData('ens'), | ||
| barn: process.env.REACT_APP_FULL_APP_DATA_BARN || addEnvToDefaultAppData('barn'), | ||
| staging: process.env.REACT_APP_FULL_APP_DATA_STAGING || addEnvToDefaultAppData('staging'), | ||
| pr: process.env.REACT_APP_FULL_APP_DATA_PR || addEnvToDefaultAppData('pr'), | ||
| development: process.env.REACT_APP_FULL_APP_DATA_DEVELOPMENT || addEnvToDefaultAppData('development'), | ||
| local: process.env.REACT_APP_FULL_APP_DATA_LOCAL || addEnvToDefaultAppData('local'), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Excellent refactoring using Record type for environment mapping.
The replacement of the switch statement with APP_DATA_PER_ENV record is much cleaner and more maintainable. The use of Record<EnvironmentName, string> ensures compile-time completeness checking, which aligns with the team's preference for explicit type coverage (as seen in previous learnings about Record<SupportedChainId, string | null>).
The fallback mechanism with addEnvToDefaultAppData provides robust default behavior when environment variables are not set.
🤖 Prompt for AI Agents
In apps/cowswap-frontend/src/modules/appData/utils/fullAppData.ts around lines 8
to 19, the code is already well-refactored by replacing the switch statement
with a Record type mapping for environment data, ensuring type safety and
maintainability. No changes are needed as the current implementation meets the
team's standards and includes a proper fallback mechanism.
* chore: release main * fix: permit-utils package version --------- Co-authored-by: daniele <[email protected]>
Summary by CodeRabbit
New Features
Bug Fixes
Improvements
Chores