Skip to content
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

Network selector #5264

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/cowswap-frontend/src/common/pure/NetworksList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { getChainInfo } from '@cowprotocol/common-const'
import { getExplorerBaseUrl } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { ExternalLink } from '@cowprotocol/ui'
import { Badge, BadgeTypes, Color, ExternalLink } from '@cowprotocol/ui'

import { Trans } from '@lingui/macro'

import * as styledEl from './styled'
import { AlertCircle } from 'react-feather'

const NEW_NETWORK_ID = 8453

export interface NetworksListProps {
currentChainId: SupportedChainId | null
Expand All @@ -25,11 +28,17 @@ export function NetworksList(props: NetworksListProps) {

const isActive = targetChainId === currentChainId
const logoUrl = getLogo(isDarkMode, isActive, logo.dark, logo.light)
const isNewNetwork = targetChainId === NEW_NETWORK_ID

const rowContent = (
<styledEl.FlyoutRow key={targetChainId} onClick={() => onSelectChain(targetChainId)} active={isActive}>
<styledEl.Logo src={logoUrl} />
<styledEl.NetworkLabel>{label}</styledEl.NetworkLabel>
{isNewNetwork && (
<Badge type={BadgeTypes.ALERT} style={{ marginLeft: 'auto' }}>
NEW
</Badge>
)}
{isActive && <styledEl.FlyoutRowActiveIndicator active />}
</styledEl.FlyoutRow>
)
Expand Down
19 changes: 9 additions & 10 deletions libs/common-hooks/src/useAvailableChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { useMemo } from 'react'
import { getAvailableChains } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'

import { useFeatureFlags } from './useFeatureFlags'

/**
* Hook to get a list of SupportedChainId currently available/enabled
*
Expand All @@ -13,13 +11,14 @@ import { useFeatureFlags } from './useFeatureFlags'
* Set the flag in this hook.
*/
export function useAvailableChains(): SupportedChainId[] {
// 1. Load feature flag for chain being enabled
const { isBaseEnabled } = useFeatureFlags()
// // 1. Load feature flag for chain being enabled
// const { isBaseEnabled } = useFeatureFlags()

// return useMemo(
// // 2. Conditionally build a list of chain ids to exclude
// () => getAvailableChains(isBaseEnabled ? undefined : [SupportedChainId.BASE]),
// [isBaseEnabled],
// )
Comment on lines -16 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why again? #5234

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see..., I did it in main branch. This is not in prod?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, it was merged to develop only and not yet released


return useMemo(
// 2. Conditionally build a list of chain ids to exclude
// () => getAvailableChains(isArbitrumOneEnabled ? undefined : [SupportedChainId.ARBITRUM_ONE]),
() => getAvailableChains(isBaseEnabled ? undefined : [SupportedChainId.BASE]),
[isBaseEnabled],
)
return getAvailableChains()
}
Loading