diff --git a/src/constants/networks.ts b/src/constants/networks.ts
index af5dd1e457..ccd0b4de22 100644
--- a/src/constants/networks.ts
+++ b/src/constants/networks.ts
@@ -31,7 +31,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,
@@ -63,7 +63,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,
@@ -72,7 +74,7 @@ export const MAINNET_NETWORKS = [
ChainId.AVAXMAINNET,
ChainId.ARBITRUM,
ChainId.OPTIMISM,
- ChainId.SOLANA,
+ // ChainId.SOLANA,
ChainId.BTTC,
ChainId.OASIS,
ChainId.FANTOM,
@@ -179,15 +181,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',
diff --git a/src/hooks/kyberdao/index.tsx b/src/hooks/kyberdao/index.tsx
index bf6613808a..9055283770 100644
--- a/src/hooks/kyberdao/index.tsx
+++ b/src/hooks/kyberdao/index.tsx
@@ -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'
@@ -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() {
diff --git a/src/hooks/web3/useWalletSupportedChains.ts b/src/hooks/web3/useWalletSupportedChains.ts
index 5fc2c25e6e..946bb0acf8 100644
--- a/src/hooks/web3/useWalletSupportedChains.ts
+++ b/src/hooks/web3/useWalletSupportedChains.ts
@@ -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
diff --git a/src/pages/App.tsx b/src/pages/App.tsx
index d306a5e500..2dc3a90c7a 100644
--- a/src/pages/App.tsx
+++ b/src/pages/App.tsx
@@ -25,7 +25,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'
@@ -103,12 +103,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
@@ -163,11 +164,11 @@ const RoutesWithNetworkPrefix = () => {
return
}
- if (network === NETWORKS_INFO_CONFIG[ChainId.SOLANA].route) {
+ if (network === NETWORKS_INFO[ChainId.SOLANA].route) {
return
}
- 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
}
diff --git a/src/pages/Bridge/BridgeTransferHistory/RouteCell.tsx b/src/pages/Bridge/BridgeTransferHistory/RouteCell.tsx
index de7a562913..192bccca34 100644
--- a/src/pages/Bridge/BridgeTransferHistory/RouteCell.tsx
+++ b/src/pages/Bridge/BridgeTransferHistory/RouteCell.tsx
@@ -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
@@ -16,9 +16,9 @@ const RouteCell: React.FC = ({ 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
}
@@ -41,7 +41,7 @@ const RouteCell: React.FC = ({ fromChainID, toChainID }) => {
alignItems: 'center',
}}
>
- {renderChainIcon(fromChainID as ChainId)}
+ {renderChainIcon(fromChainID)}
= ({ fromChainID, toChainID }) => {
height="16px"
color={theme.subText}
/>
- {renderChainIcon(toChainID as ChainId)}
+ {renderChainIcon(toChainID)}
)
}
diff --git a/src/pages/Bridge/BridgeTransferHistory/TransferHistoryTable/Mobile.tsx b/src/pages/Bridge/BridgeTransferHistory/TransferHistoryTable/Mobile.tsx
index 66de5a760d..1375d8a27b 100644
--- a/src/pages/Bridge/BridgeTransferHistory/TransferHistoryTable/Mobile.tsx
+++ b/src/pages/Bridge/BridgeTransferHistory/TransferHistoryTable/Mobile.tsx
@@ -1,4 +1,3 @@
-import { ChainId } from '@kyberswap/ks-sdk-core'
import { Trans, t } from '@lingui/macro'
import { ArrowDown } from 'react-feather'
import { Flex } from 'rebass'
@@ -6,12 +5,13 @@ 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'
@@ -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 (
@@ -125,7 +125,7 @@ const Mobile: React.FC = ({ transfers }) => {
justifyContent: 'space-between',
}}
>
-
+
@@ -145,7 +145,7 @@ const Mobile: React.FC = ({ transfers }) => {
justifyContent: 'space-between',
}}
>
-
+
diff --git a/src/pages/Bridge/helpers.ts b/src/pages/Bridge/helpers.ts
index a0aac99cc4..f96a3219fe 100644
--- a/src/pages/Bridge/helpers.ts
+++ b/src/pages/Bridge/helpers.ts
@@ -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'
@@ -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) {
@@ -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) {
diff --git a/src/pages/CrossChain/TransfersHistory/HistoryTable/Mobile.tsx b/src/pages/CrossChain/TransfersHistory/HistoryTable/Mobile.tsx
index 2c4b84ac9e..3fdaeacaa9 100644
--- a/src/pages/CrossChain/TransfersHistory/HistoryTable/Mobile.tsx
+++ b/src/pages/CrossChain/TransfersHistory/HistoryTable/Mobile.tsx
@@ -8,7 +8,7 @@ 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'
@@ -16,6 +16,7 @@ import ActionButtons from 'pages/CrossChain/TransfersHistory/HistoryTable/Action
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'
@@ -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 (
@@ -123,9 +124,9 @@ const TransactionItemMobile = ({ transfer }: { transfer: CrossChainTransfer }) =
gap: '4px',
}}
>
-
+
-
+
diff --git a/src/pages/CrossChain/index.tsx b/src/pages/CrossChain/index.tsx
index 269da34a18..5d6c17a7bb 100644
--- a/src/pages/CrossChain/index.tsx
+++ b/src/pages/CrossChain/index.tsx
@@ -1,5 +1,4 @@
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'
@@ -7,7 +6,7 @@ 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'
@@ -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
diff --git a/src/utils/index.ts b/src/utils/index.ts
index fba70d104b..d6fda70c1c 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -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'
@@ -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
}
diff --git a/src/utils/string.ts b/src/utils/string.ts
index 30d527cc8b..dbfb2b8153 100644
--- a/src/utils/string.ts
+++ b/src/utils/string.ts
@@ -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
@@ -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)
}