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

feat: remove Solana #2120

Merged
merged 1 commit into from
Jul 31, 2023
Merged
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
17 changes: 5 additions & 12 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type SOLANA_NETWORK = ChainId.SOLANA | ChainId.SOLANA_DEVNET
type NETWORKS_INFO_CONFIG_TYPE = { [chainId in EVM_NETWORK]: EVMNetworkInfo } & {
[chainId in SOLANA_NETWORK]: SolanaNetworkInfo
}
export const NETWORKS_INFO_CONFIG: NETWORKS_INFO_CONFIG_TYPE = {
const NETWORKS_INFO_CONFIG: NETWORKS_INFO_CONFIG_TYPE = {
[ChainId.MAINNET]: ethereum,
[ChainId.GÖRLI]: görli,
[ChainId.MATIC]: matic,
Expand Down Expand Up @@ -65,7 +65,9 @@ export const NETWORKS_INFO = new Proxy(NETWORKS_INFO_CONFIG, {
},
})

export const SUPPORTED_NETWORKS = Object.keys(NETWORKS_INFO).map(Number) as ChainId[]
// temporary disable Solana
// todo: either enable back or completely remove Solana from codebase
export const SUPPORTED_NETWORKS = Object.keys(NETWORKS_INFO).map(Number).filter(isEVM) as ChainId[]

export const MAINNET_NETWORKS = [
ChainId.MAINNET,
Expand All @@ -74,7 +76,7 @@ export const MAINNET_NETWORKS = [
ChainId.AVAXMAINNET,
ChainId.ARBITRUM,
ChainId.OPTIMISM,
ChainId.SOLANA,
// ChainId.SOLANA,
ChainId.BTTC,
ChainId.OASIS,
ChainId.FANTOM,
Expand Down Expand Up @@ -180,15 +182,6 @@ export const ONLY_STATIC_FEE_CHAINS = [
// hardcode for unavailable subgraph
export const ONLY_DYNAMIC_FEE_CHAINS: ChainId[] = []

// Keys are present_on_chains' value.
export const TRENDING_SOON_SUPPORTED_NETWORKS: { [p: string]: ChainId } = {
eth: ChainId.MAINNET,
bsc: ChainId.BSCMAINNET,
polygon: ChainId.MATIC,
avax: ChainId.AVAXMAINNET,
fantom: ChainId.FANTOM,
}

export const CLAIM_REWARDS_DATA_URL: { [chainId: number]: string } = {
[ChainId.AVAXMAINNET]:
'https://raw.githubusercontent.com/KyberNetwork/avax-trading-contest-reward-distribution/develop/results/reward_proof.json',
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/kyberdao/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MigrateABI from 'constants/abis/kyberdao/migrate.json'
import RewardDistributorABI from 'constants/abis/kyberdao/reward_distributor.json'
import StakingABI from 'constants/abis/kyberdao/staking.json'
import { CONTRACT_NOT_FOUND_MSG } from 'constants/messages'
import { NETWORKS_INFO_CONFIG, isEVM } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS, isEVM } from 'constants/networks'
import ethereumInfo from 'constants/networks/ethereum'
import { EVMNetworkInfo } from 'constants/networks/type'
import { useActiveWeb3React } from 'hooks'
Expand All @@ -36,7 +36,7 @@ import {
} from './types'

export function isSupportKyberDao(chainId: ChainId) {
return isEVM(chainId) && NETWORKS_INFO_CONFIG[chainId].kyberDAO
return isEVM(chainId) && SUPPORTED_NETWORKS.includes(chainId) && NETWORKS_INFO[chainId].kyberDAO
}

export function useKyberDAOInfo() {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/web3/useWalletSupportedChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function useWalletSupportedChains() {
case walletConnectV2:
return [
...getChainsFromEIP155Accounts((connector as WalletConnectV2).provider?.session?.namespaces?.eip155?.accounts),
ChainId.SOLANA,
// ChainId.SOLANA,
]
default:
return SUPPORTED_NETWORKS
Expand Down
19 changes: 10 additions & 9 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Snowfall from 'components/Snowflake/Snowfall'
import Web3ReactManager from 'components/Web3ReactManager'
import { ENV_LEVEL } from 'constants/env'
import { APP_PATHS, BLACKLIST_WALLETS, CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index'
import { NETWORKS_INFO_CONFIG } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS } from 'constants/networks'
import { ENV_TYPE } from 'constants/type'
import { useActiveWeb3React } from 'hooks'
import { useAutoLogin } from 'hooks/useLogin'
Expand Down Expand Up @@ -121,12 +121,13 @@ const BodyWrapper = styled.div`
`

const preloadImages = () => {
const imageList: (string | null)[] = [
...Object.values(NETWORKS_INFO_CONFIG).map(network => network.icon),
...Object.values(NETWORKS_INFO_CONFIG)
.map(network => network.iconDark)
.filter(Boolean),
]
const imageList: string[] = SUPPORTED_NETWORKS.map(chainId => [
NETWORKS_INFO[chainId].icon,
NETWORKS_INFO[chainId].iconDark,
])
.flat()
.filter(Boolean) as string[]

imageList.forEach(image => {
if (image) {
new Image().src = image
Expand Down Expand Up @@ -181,11 +182,11 @@ const RoutesWithNetworkPrefix = () => {
return <Navigate to={`/${networkInfo.route}${location.pathname}`} replace />
}

if (network === NETWORKS_INFO_CONFIG[ChainId.SOLANA].route) {
if (network === NETWORKS_INFO[ChainId.SOLANA].route) {
return <Navigate to="/" />
}

const chainInfoFromParam = Object.values(NETWORKS_INFO_CONFIG).find(info => info.route === network)
const chainInfoFromParam = SUPPORTED_NETWORKS.find(chain => NETWORKS_INFO[chain].route === network)
if (!chainInfoFromParam) {
return <Navigate to={'/'} replace />
}
Expand Down
14 changes: 7 additions & 7 deletions src/pages/Bridge/BridgeTransferHistory/RouteCell.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { t } from '@lingui/macro'
import { ChevronRight } from 'react-feather'
import { Box, Flex } from 'rebass'
import { useTheme } from 'styled-components'

import QuestionHelper from 'components/QuestionHelper'
import { NETWORKS_INFO_CONFIG } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS } from 'constants/networks'
import { useIsDarkMode } from 'state/user/hooks'
import { includes } from 'utils/array'

type Props = {
fromChainID: number
Expand All @@ -16,9 +16,9 @@ const RouteCell: React.FC<Props> = ({ fromChainID, toChainID }) => {
const isDark = useIsDarkMode()
const theme = useTheme()

const renderChainIcon = (chainId: ChainId) => {
const chainInfo = NETWORKS_INFO_CONFIG[chainId]
if (chainInfo) {
const renderChainIcon = (chainId: number) => {
if (includes(SUPPORTED_NETWORKS, chainId)) {
const chainInfo = NETWORKS_INFO[chainId]
const src = isDark && chainInfo.iconDark ? chainInfo.iconDark : chainInfo.icon
return <img src={src} alt={chainInfo.name} style={{ width: '18px' }} />
}
Expand All @@ -41,7 +41,7 @@ const RouteCell: React.FC<Props> = ({ fromChainID, toChainID }) => {
alignItems: 'center',
}}
>
{renderChainIcon(fromChainID as ChainId)}
{renderChainIcon(fromChainID)}
<ChevronRight
style={{
marginLeft: '4px',
Expand All @@ -51,7 +51,7 @@ const RouteCell: React.FC<Props> = ({ fromChainID, toChainID }) => {
height="16px"
color={theme.subText}
/>
{renderChainIcon(toChainID as ChainId)}
{renderChainIcon(toChainID)}
</Flex>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { Trans, t } from '@lingui/macro'
import { ArrowDown } from 'react-feather'
import { Flex } from 'rebass'
import styled from 'styled-components'

import InfoHelper from 'components/InfoHelper'
import { NetworkLogo } from 'components/Logo'
import { NETWORKS_INFO_CONFIG } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS } from 'constants/networks'
import useTheme from 'hooks/useTheme'
import ActionCell from 'pages/Bridge/BridgeTransferHistory/ActionCell'
import StatusBadge from 'pages/Bridge/BridgeTransferHistory/StatusBadge'
import TimeStatusCell from 'pages/Bridge/BridgeTransferHistory/TimeStatusCell'
import TokenReceiveCell from 'pages/Bridge/BridgeTransferHistory/TokenReceiveCell'
import { includes } from 'utils/array'

import { Props } from './index'

Expand Down Expand Up @@ -58,9 +58,9 @@ const ChainWrapper = styled.div`

color: ${({ theme }) => theme.subText};
`
const ChainDisplay: React.FC<{ chainId: ChainId }> = ({ chainId }) => {
const chainInfo = NETWORKS_INFO_CONFIG[chainId]
if (chainInfo) {
const ChainDisplay: React.FC<{ chainId: number }> = ({ chainId }) => {
if (includes(SUPPORTED_NETWORKS, chainId)) {
const chainInfo = NETWORKS_INFO[chainId]
return (
<ChainWrapper>
<NetworkLogo chainId={chainId} style={{ width: 18, height: 18 }} />
Expand Down Expand Up @@ -125,7 +125,7 @@ const Mobile: React.FC<Props> = ({ transfers }) => {
justifyContent: 'space-between',
}}
>
<ChainDisplay chainId={Number(transfer.srcChainId) as ChainId} />
<ChainDisplay chainId={Number(transfer.srcChainId)} />
<TokenReceiveCell transfer={transfer} />
</Flex>

Expand All @@ -145,7 +145,7 @@ const Mobile: React.FC<Props> = ({ transfers }) => {
justifyContent: 'space-between',
}}
>
<ChainDisplay chainId={Number(transfer.dstChainId) as ChainId} />
<ChainDisplay chainId={Number(transfer.dstChainId)} />
<TimeStatusCell timestamp={transfer.createdAt * 1000} />
</Flex>
</Flex>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Bridge/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChainId } from '@kyberswap/ks-sdk-core'
import { t } from '@lingui/macro'
import axios from 'axios'

import { NETWORKS_INFO_CONFIG } from 'constants/networks'
import { SUPPORTED_NETWORKS } from 'constants/networks'
import { MultichainTransferStatus } from 'hooks/bridge/useGetBridgeTransfers'
import { PoolBridgeValue } from 'state/crossChain/reducer'
import { formatNumberWithPrecisionRange, isAddress } from 'utils'
Expand Down Expand Up @@ -74,7 +74,7 @@ const filterTokenList = (tokens: { [key: string]: MultiChainTokenInfo }) => {
delete destChains[chain][address]
}
})
if (NETWORKS_INFO_CONFIG[chain as unknown as keyof typeof NETWORKS_INFO_CONFIG]) {
if (SUPPORTED_NETWORKS.includes(Number(chain))) {
hasChainSupport = true
}
if (!Object.keys(destChains[chain]).length) {
Expand Down Expand Up @@ -133,7 +133,7 @@ export async function getChainlist(isStaleData: boolean) {
const tokens = await fetchListChainSupport()
const filter = Object.keys(tokens)
.map(Number)
.filter(id => !!NETWORKS_INFO_CONFIG[id as ChainId])
.filter(id => SUPPORTED_NETWORKS.includes(id))
setBridgeLocalstorage(BridgeLocalStorageKeys.CHAINS_SUPPORTED, filter)
return filter
} catch (e) {
Expand Down
13 changes: 7 additions & 6 deletions src/pages/CrossChain/TransfersHistory/HistoryTable/Mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import styled from 'styled-components'
import InfoHelper from 'components/InfoHelper'
import { NetworkLogo } from 'components/Logo'
import { RowBetween } from 'components/Row'
import { NETWORKS_INFO, NETWORKS_INFO_CONFIG } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS } from 'constants/networks'
import useTheme from 'hooks/useTheme'
import StatusBadge from 'pages/Bridge/BridgeTransferHistory/StatusBadge'
import TimeStatusCell from 'pages/Bridge/BridgeTransferHistory/TimeStatusCell'
import ActionButtons from 'pages/CrossChain/TransfersHistory/HistoryTable/ActionButons'
import { DetailTransaction } from 'pages/CrossChain/TransfersHistory/HistoryTable/DetailTransaction'
import { useGetTransactionStatus } from 'pages/CrossChain/TransfersHistory/HistoryTable/TransactionItem'
import { CrossChainTransfer } from 'pages/CrossChain/useTransferHistory'
import { includes } from 'utils/array'

import TokenReceiveCell from './TokenReceiveCell'
import { Props } from './index'
Expand Down Expand Up @@ -63,9 +64,9 @@ const ChainWrapper = styled.div`

color: ${({ theme }) => theme.subText};
`
const ChainDisplay: React.FC<{ chainId: ChainId }> = ({ chainId }) => {
const chainInfo = NETWORKS_INFO_CONFIG[chainId]
if (chainInfo) {
const ChainDisplay: React.FC<{ chainId: number }> = ({ chainId }) => {
if (includes(SUPPORTED_NETWORKS, chainId)) {
const chainInfo = NETWORKS_INFO[chainId]
return (
<ChainWrapper>
<NetworkLogo chainId={chainId} style={{ width: 18, height: 18 }} />
Expand Down Expand Up @@ -123,9 +124,9 @@ const TransactionItemMobile = ({ transfer }: { transfer: CrossChainTransfer }) =
gap: '4px',
}}
>
<ChainDisplay chainId={Number(transfer.srcChainId) as ChainId} />
<ChainDisplay chainId={Number(transfer.srcChainId)} />
<ArrowDown width="8px" height="8px" color={theme.subText} style={{ marginLeft: 5 }} />
<ChainDisplay chainId={Number(transfer.dstChainId) as ChainId} />
<ChainDisplay chainId={Number(transfer.dstChainId)} />
</Flex>

<Flex sx={{ flexDirection: 'column', alignItems: 'flex-end', justifyContent: 'space-between', gap: '6px' }}>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/CrossChain/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Squid } from '@0xsquid/sdk'
import { ChainId } from '@kyberswap/ks-sdk-core'
import { Trans } from '@lingui/macro'
import { memo, useEffect, useMemo, useRef } from 'react'
import { Navigate } from 'react-router-dom'
import { Flex, Text } from 'rebass'

import WarningIcon from 'components/Icons/WarningIcon'
import { CROSS_CHAIN_CONFIG } from 'constants/env'
import { NETWORKS_INFO_CONFIG } from 'constants/networks'
import { SUPPORTED_NETWORKS } from 'constants/networks'
import { NativeCurrencies } from 'constants/tokens'
import { useActiveWeb3React } from 'hooks'
import useTheme from 'hooks/useTheme'
Expand Down Expand Up @@ -56,7 +55,7 @@ function CrossChain({ visible }: { visible: boolean }) {
}
await squid.init()
const { chains = [], tokens = [] } = squid
const chainSupports = (chains.map(e => e.chainId) as ChainId[]).filter(id => !!NETWORKS_INFO_CONFIG[id])
const chainSupports = chains.map(e => Number(e.chainId)).filter(id => SUPPORTED_NETWORKS.includes(id))
const formattedTokens: WrappedTokenInfo[] = []
tokens.forEach(token => {
if (typeof token.chainId === 'string' || !chainSupports.includes(token.chainId)) return
Expand Down
7 changes: 4 additions & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Numeral from 'numeral'
import { GET_BLOCKS } from 'apollo/queries'
import { BLOCK_SERVICE_API, ENV_KEY } from 'constants/env'
import { DEFAULT_GAS_LIMIT_MARGIN, ZERO_ADDRESS } from 'constants/index'
import { NETWORKS_INFO, NETWORKS_INFO_CONFIG, isEVM } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS, isEVM } from 'constants/networks'
import { KNC, KNCL_ADDRESS } from 'constants/tokens'
import { EVMWalletInfo, SUPPORTED_WALLET, SolanaWalletInfo, WalletInfo } from 'constants/wallets'
import store from 'state'
Expand Down Expand Up @@ -519,8 +519,9 @@ export const isChristmasTime = () => {
return currentTime.month() === 11 && currentTime.date() >= 15
}

export const getLimitOrderContract = (chainId: ChainId) => {
const { production, development } = NETWORKS_INFO_CONFIG[chainId]?.limitOrder ?? {}
export const getLimitOrderContract = (chainId: ChainId): string | null => {
if (!SUPPORTED_NETWORKS.includes(chainId)) return null
const { production, development } = NETWORKS_INFO[chainId]?.limitOrder ?? {}
return ENV_KEY === 'production' || ENV_KEY === 'staging' ? production : development
}

Expand Down
8 changes: 4 additions & 4 deletions src/utils/string.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Currency, Token } from '@kyberswap/ks-sdk-core'
import { ChainId, Currency, Token } from '@kyberswap/ks-sdk-core'
import { parse } from 'querystring'

import { NETWORKS_INFO } from 'constants/networks'
import { NETWORKS_INFO, SUPPORTED_NETWORKS } from 'constants/networks'

/**
* ex: nguyen hoai danh => nguyen-hoai-danh
Expand Down Expand Up @@ -39,6 +39,6 @@ export const escapeScriptHtml = (str: string) => {

export const isEmailValid = (value: string | undefined) => value?.match(/^\w+([\.-]?\w)*@\w+([\.-]?\w)*(\.\w{2,10})+$/)

export const getChainIdFromSlug = (network: string | undefined) => {
return Object.values(NETWORKS_INFO).find(n => n.route === network)?.chainId
export const getChainIdFromSlug = (network: string | undefined): ChainId | undefined => {
return SUPPORTED_NETWORKS.find(chainId => NETWORKS_INFO[chainId].route === network)
}
Loading