Skip to content

Commit

Permalink
Merge branch 'remove-solana' of github.com:KyberNetwork/kyberswap-int…
Browse files Browse the repository at this point in the history
…erface into test-prod
  • Loading branch information
viet-nv committed Nov 29, 2023
2 parents 5e7c5eb + 3a65bb0 commit 21fe332
Show file tree
Hide file tree
Showing 201 changed files with 1,013 additions and 6,196 deletions.
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@
"@kybernetwork/oauth2": "1.0.1",
"@kyberswap/krystal-walletconnect-v2": "0.0.1",
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "1.0.13",
"@kyberswap/ks-sdk-core": "1.1.0-rc",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"@kyberswap/ks-sdk-solana": "^1.0.2",
"@lingui/loader": "~3.14.0",
"@lingui/macro": "~3.14.0",
"@lingui/react": "~3.14.0",
Expand All @@ -63,11 +62,6 @@
"@reduxjs/toolkit": "1.9.3",
"@sentry/react": "^7.18.0",
"@sentry/tracing": "^7.18.0",
"@solana/spl-token": "0.2.0",
"@solana/wallet-adapter-base": "~0.9.18",
"@solana/wallet-adapter-react": "0.15.18",
"@solana/wallet-adapter-wallets": "^0.19.5",
"@solana/web3.js": "^1.66.2",
"@use-gesture/react": "^10.2.27",
"@web3-react/coinbase-wallet": "8.2.0",
"@web3-react/core": "8.2.0",
Expand Down Expand Up @@ -198,7 +192,7 @@
"vite-tsconfig-paths": "^4.0.8"
},
"resolutions": {
"@kyberswap/ks-sdk-core": "1.0.13",
"@kyberswap/ks-sdk-core": "1.1.0-rc",
"babel-plugin-lodash/@babel/types": "~7.20.0",
"react-error-overlay": "6.0.9",
"@lingui/babel-plugin-extract-messages": "3.14.0",
Expand Down
1 change: 0 additions & 1 deletion src/assets/wallets-connect/phantom.svg

This file was deleted.

17 changes: 0 additions & 17 deletions src/assets/wallets-connect/slope.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/wallets-connect/solflare.svg

This file was deleted.

47 changes: 17 additions & 30 deletions src/components/AddToMetamask/index.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,46 @@
import { Token } from '@kyberswap/ks-sdk-core'
import { createUserAssociatedTokenAccount } from '@kyberswap/ks-sdk-solana'
import { PublicKey } from '@solana/web3.js'
import styled from 'styled-components'

import { ButtonEmpty } from 'components/Button'
import { RowFixed } from 'components/Row'
import { SUPPORTED_WALLETS } from 'constants/wallets'
import { useActiveWeb3React } from 'hooks'
import useProvider from 'hooks/solana/useProvider'
import { getTokenLogoURL, isAddress } from 'utils'
import { getTokenLogoURL } from 'utils'

const StyledLogo = styled.img`
height: 16px;
width: 16px;
`

export default function AddTokenToMetaMask({ token }: { token: Token }) {
const { chainId, walletKey, account, isEVM } = useActiveWeb3React()
const provider = useProvider()
const { chainId, walletKey } = useActiveWeb3React()

async function addToMetaMask() {
const tokenAddress = token.address
const tokenSymbol = token.symbol
const tokenDecimals = token.decimals
const tokenImage = getTokenLogoURL(token.address, chainId)

if (isEVM) {
try {
await window.ethereum?.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: tokenAddress,
symbol: tokenSymbol,
decimals: tokenDecimals,
image: tokenImage,
},
try {
await window.ethereum?.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: tokenAddress,
symbol: tokenSymbol,
decimals: tokenDecimals,
image: tokenImage,
},
})
} catch (error) {
console.error(error)
}
} else {
if (!account || !provider || !isAddress(chainId, tokenAddress)) return
try {
await createUserAssociatedTokenAccount(provider, new PublicKey(tokenAddress), new PublicKey(account))
} catch (error) {
console.error(error)
}
},
})
} catch (error) {
console.error(error)
}
}
if (!walletKey) return null
if (walletKey === 'WALLET_CONNECT') return null
if (isEVM && walletKey === 'COINBASE') return null // Coinbase wallet no need to add since it automatically track token
if (walletKey === 'COINBASE') return null // Coinbase wallet no need to add since it automatically track token
return (
<ButtonEmpty mt="12px" padding="0" width="fit-content" onClick={addToMetaMask}>
<RowFixed>
Expand Down
3 changes: 1 addition & 2 deletions src/components/AddressInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default function AddressInputPanel({
// triggers whenever the typed value changes
onChange: (value: string | null) => void
}) {
const { chainId, networkInfo, isEVM } = useActiveWeb3React()
const { chainId, networkInfo } = useActiveWeb3React()
const { address, loading, name } = useENS(value)

const handleInput = useCallback(
Expand All @@ -155,7 +155,6 @@ export default function AddressInputPanel({
const theme = useTheme()

const error = Boolean((value || '').length > 0 && !loading && !address)
if (!isEVM) return null
return (
<AutoColumn gap="4px">
<Flex
Expand Down
1 change: 0 additions & 1 deletion src/components/Announcement/Popups/TransactionPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ const SUMMARY: { [type in TRANSACTION_TYPE]: SummaryFunction } = {
[TRANSACTION_TYPE.ELASTIC_WITHDRAW_LIQUIDITY]: summaryTypeOnly,
[TRANSACTION_TYPE.ELASTIC_FORCE_WITHDRAW_LIQUIDITY]: summaryTypeOnly,

[TRANSACTION_TYPE.SETUP_SOLANA_SWAP]: summaryTypeOnly,
[TRANSACTION_TYPE.CANCEL_LIMIT_ORDER]: summaryCancelLimitOrder,
[TRANSACTION_TYPE.TRANSFER_TOKEN]: summaryTransferToken,

Expand Down
5 changes: 2 additions & 3 deletions src/components/ElasticZap/QuickZap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
import WarningNote from 'components/WarningNote'
import { abi } from 'constants/abis/v2/ProAmmPoolState.json'
import { APP_PATHS } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { useActiveWeb3React } from 'hooks'
import { useToken } from 'hooks/Tokens'
import { useZapInAction, useZapInPoolResult } from 'hooks/elasticZap'
Expand Down Expand Up @@ -93,7 +92,7 @@ export const QuickZapButton = ({
size?: 'small' | 'medium'
}) => {
const { networkInfo } = useActiveWeb3React()
const isZapAvailable = !!(networkInfo as EVMNetworkInfo).elastic.zap
const isZapAvailable = !!networkInfo.elastic.zap
const theme = useTheme()

const tmp = true
Expand Down Expand Up @@ -135,7 +134,7 @@ export default function QuickZap(props: Props) {

function QuickZapModal({ isOpen, onDismiss, poolAddress, tokenId, expectedChainId }: Props) {
const { chainId, networkInfo, account } = useActiveWeb3React()
const zapInContractAddress = (networkInfo as EVMNetworkInfo).elastic.zap?.router
const zapInContractAddress = networkInfo.elastic.zap?.router
const { changeNetwork } = useChangeNetwork()
const theme = useTheme()
const [selectedRange, setSelectedRange] = useState<RANGE | FARMING_RANGE | null>(null)
Expand Down
5 changes: 1 addition & 4 deletions src/components/FeeSelector/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { FeeAmount } from '@kyberswap/ks-sdk-elastic'
import { useEffect, useState } from 'react'

import { POOL_POSITION_COUNT } from 'apollo/queries/promm'
import { useActiveWeb3React } from 'hooks'
import { useProAmmPoolInfos } from 'hooks/useProAmmPoolInfo'
import { useKyberSwapConfig } from 'state/application/hooks'

Expand All @@ -29,14 +28,12 @@ export const useFeeTierDistribution = (
currencyA: Currency | undefined,
currencyB: Currency | undefined,
): { [key in FeeAmount]: number } => {
const { isEVM } = useActiveWeb3React()
const { elasticClient } = useKyberSwapConfig()
const poolIds = useProAmmPoolInfos(currencyA, currencyB, FEE_AMOUNTS).filter(Boolean)

const [feeTierDistribution, setFeeTierDistribution] = useState<{ [key in FeeAmount]: number }>(initState)

useEffect(() => {
if (!isEVM) return
if (!poolIds.length) return
setFeeTierDistribution(initState)
elasticClient
Expand Down Expand Up @@ -69,7 +66,7 @@ export const useFeeTierDistribution = (
})
.catch(err => console.warn({ err }))
// eslint-disable-next-line
}, [JSON.stringify(poolIds), isEVM, elasticClient])
}, [JSON.stringify(poolIds), elasticClient])

return feeTierDistribution
}
6 changes: 1 addition & 5 deletions src/components/Header/groups/EarnNavGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ import { DropdownTextAnchor, StyledNavLink } from '../styleds'
import NavGroup from './NavGroup'

const EarnNavGroup = () => {
const { isEVM, networkInfo } = useActiveWeb3React()
const { networkInfo } = useActiveWeb3React()
const upTo420 = useMedia('(max-width: 420px)')
const { pathname } = useLocation()
const { mixpanelHandler } = useMixpanel()
const isActive = [APP_PATHS.POOLS, APP_PATHS.FARMS, APP_PATHS.MY_POOLS].some(path => pathname.includes(path))

if (!isEVM) {
return null
}

return (
<NavGroup
dropdownAlign={upTo420 ? 'right' : 'left'}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/groups/SwapNavGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const SwapNavGroup = () => {
)}

{/*
!(isSolana || chainId === ChainId.LINEA_TESTNET) && (
!(chainId === ChainId.LINEA_TESTNET) && (
<StyledNavLink
id="bridge-nav-link"
to={APP_PATHS.BRIDGE}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId, getChainType } from '@kyberswap/ks-sdk-core'
import { ChainId } from '@kyberswap/ks-sdk-core'
import { Trans, t } from '@lingui/macro'
import { motion, useAnimationControls, useDragControls } from 'framer-motion'
import { rgba } from 'polished'
Expand Down Expand Up @@ -131,7 +131,7 @@ const DraggableNetworkButton = ({
onFavoriteClick?: () => void
}) => {
const theme = useTheme()
const { isWrongNetwork, walletSolana, walletEVM } = useActiveWeb3React()
const { isWrongNetwork, wallet } = useActiveWeb3React()
const { changeNetwork } = useChangeNetwork()
const [dragging, setDragging] = useState(false)
const ref = useRef<HTMLDivElement>(null)
Expand All @@ -143,29 +143,18 @@ const DraggableNetworkButton = ({
const isMaintenance = state === ChainState.MAINTENANCE
const disabled = (activeChainIds ? !activeChainIds?.includes(chainId) : false) || isMaintenance
const selected = isSelected && !isWrongNetwork
const walletKey =
chainId === ChainId.SOLANA ? walletSolana.walletKey : walletEVM.chainId === chainId ? walletEVM.walletKey : null
const walletKey = wallet.chainId === chainId ? wallet.walletKey : null

const handleChainSelect = () => {
if (disabled) return
customToggleModal?.()
if (customOnSelectNetwork) {
customOnSelectNetwork(chainId)
} else if (getChainType(chainId) === getChainType(chainId)) {
changeNetwork(chainId, () => {
navigate(
{
search: stringify(qs),
},
{ replace: true },
)
onChangedNetwork?.()
})
} else {
changeNetwork(chainId, () => {
navigate(
{
search: '',
search: stringify(qs),
},
{ replace: true },
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/web3/SelectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ const AccountElement = styled.div`
`

function Web3StatusInner() {
const { chainId, account, walletKey, isEVM, isWrongNetwork } = useActiveWeb3React()
const { chainId, account, walletKey, isWrongNetwork } = useActiveWeb3React()
const { mixpanelHandler } = useMixpanel()
const uptoMedium = useMedia(`(max-width: ${MEDIA_WIDTHS.upToMedium}px)`)
const { signIn } = useLogin()
const { ENSName } = useENSName(isEVM ? account ?? undefined : undefined)
const { ENSName } = useENSName(account ?? undefined)
const theme = useTheme()

const allTransactions = useAllTransactions()
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/web3/SignWallet/ProfileContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const ProfileItem = ({
const ProfileContent = ({ scroll, toggleModal }: { scroll?: boolean; toggleModal: () => void }) => {
const { signIn, signOutAll } = useLogin()
const { profiles, totalGuest } = useProfileInfo()
const { account, isEVM } = useActiveWeb3React()
const { account } = useActiveWeb3React()

if (!profiles.length) return null
const listNotActive = profiles.slice(1)
Expand All @@ -230,7 +230,7 @@ const ProfileContent = ({ scroll, toggleModal }: { scroll?: boolean; toggleModal
</ListProfile>
</Column>
<ActionWrapper hasBorder={profiles.length > 1}>
{!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && isEVM && (
{!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && (
<ActionItem
onClick={() => {
toggleModal()
Expand Down
Loading

0 comments on commit 21fe332

Please sign in to comment.