Skip to content

Commit

Permalink
support linea
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Aug 6, 2023
1 parent 228287f commit ff13b5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
22 changes: 2 additions & 20 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,27 +317,9 @@ export const CHAINS_SUPPORT_CROSS_CHAIN =
ChainId.ARBITRUM,
ChainId.OPTIMISM,
ChainId.FANTOM,
ChainId.LINEA,
]
: [
ChainId.MAINNET,
ChainId.GÖRLI,
ChainId.MATIC,
ChainId.MUMBAI,
ChainId.BSCTESTNET,
ChainId.BSCMAINNET,
ChainId.AVAXTESTNET,
ChainId.AVAXMAINNET,
ChainId.FANTOM,
ChainId.CRONOS,
ChainId.ARBITRUM,
ChainId.BTTC,
ChainId.VELAS,
ChainId.AURORA,
ChainId.OASIS,
ChainId.OPTIMISM,
ChainId.ZKSYNC,
ChainId.SOLANA,
]
: SUPPORTED_NETWORKS

export const TYPE_AND_SWAP_NOT_SUPPORTED_CHAINS: ChainId[] = [ChainId.ZKSYNC, ChainId.LINEA_TESTNET, ChainId.LINEA]

Expand Down
10 changes: 5 additions & 5 deletions src/pages/CrossChain/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Squid } from '@0xsquid/sdk'
import { Trans } from '@lingui/macro'
import { memo, useEffect, useMemo, useRef } from 'react'
import { memo, useEffect, useRef } from 'react'
import { Navigate } from 'react-router-dom'
import { Flex, Text } from 'rebass'

Expand All @@ -21,8 +21,7 @@ export const getAxelarScanUrl = (srcTxHash: string) => `${CROSS_CHAIN_CONFIG.AXE
function CrossChain({ visible }: { visible: boolean }) {
const theme = useTheme()
const { chainId, isSolana } = useActiveWeb3React()
const [{ squidInstance, chainIdOut, chains }, setCrossChainState] = useCrossChainState()
const listChainOut = useMemo(() => chains.filter(e => e !== chainId), [chains, chainId])
const [{ squidInstance, chainIdOut, listChainOut }, setCrossChainState] = useCrossChainState()

const curChainId = useRef(chainId)

Expand All @@ -48,10 +47,11 @@ function CrossChain({ visible }: { visible: boolean }) {
let squid = squidInstance
if (loading.current) return
loading.current = true
const config = { baseUrl: CROSS_CHAIN_CONFIG.API_DOMAIN, integratorId: CROSS_CHAIN_CONFIG.INTEGRATOR_ID }
if (!squid) {
squid = new Squid({ baseUrl: CROSS_CHAIN_CONFIG.API_DOMAIN, integratorId: CROSS_CHAIN_CONFIG.INTEGRATOR_ID })
squid = new Squid(config)
} else {
squid.setConfig({ baseUrl: CROSS_CHAIN_CONFIG.API_DOMAIN, integratorId: CROSS_CHAIN_CONFIG.INTEGRATOR_ID })
squid.setConfig(config)
}
await squid.init()
const { chains = [], tokens = [] } = squid
Expand Down
6 changes: 5 additions & 1 deletion src/state/crossChain/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ChainId, NativeCurrency } from '@kyberswap/ks-sdk-core'
import { useCallback, useMemo } from 'react'
import { useDispatch, useSelector } from 'react-redux'

import { CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
import { MultiChainTokenInfo } from 'pages/Bridge/type'
import { AppDispatch, AppState } from 'state'
Expand Down Expand Up @@ -100,7 +101,10 @@ export function useCrossChainState(): [
const { chainId } = useActiveWeb3React()
const setState = useCallback((data: CrossChainStateParams) => dispatch(setCrossChainState(data)), [dispatch])

const listChainOut = useMemo(() => chains.filter(e => e !== chainId), [chains, chainId])
const listChainOut = useMemo(
() => chains.filter(e => e !== chainId && CHAINS_SUPPORT_CROSS_CHAIN.includes(e)),
[chains, chainId],
)
const listTokenOut = useMemo(() => tokens.filter(e => e.chainId === chainIdOut), [tokens, chainIdOut])
const listTokenIn = useMemo(() => tokens.filter(e => e.chainId === chainId), [tokens, chainId])

Expand Down

0 comments on commit ff13b5b

Please sign in to comment.