diff --git a/package.json b/package.json index 97cef075ff..fa3b14d4e7 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", diff --git a/src/assets/wallets-connect/phantom.svg b/src/assets/wallets-connect/phantom.svg deleted file mode 100644 index 211a33f507..0000000000 --- a/src/assets/wallets-connect/phantom.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/wallets-connect/slope.svg b/src/assets/wallets-connect/slope.svg deleted file mode 100644 index 8b27cd4a78..0000000000 --- a/src/assets/wallets-connect/slope.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/src/assets/wallets-connect/solflare.svg b/src/assets/wallets-connect/solflare.svg deleted file mode 100644 index 6187e01a79..0000000000 --- a/src/assets/wallets-connect/solflare.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/components/AddToMetamask/index.tsx b/src/components/AddToMetamask/index.tsx index f730ea9b7e..9dc039d60a 100644 --- a/src/components/AddToMetamask/index.tsx +++ b/src/components/AddToMetamask/index.tsx @@ -1,14 +1,11 @@ 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; @@ -16,8 +13,7 @@ const StyledLogo = styled.img` ` 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 @@ -25,35 +21,26 @@ export default function AddTokenToMetaMask({ token }: { token: Token }) { 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 ( diff --git a/src/components/AddressInputPanel/index.tsx b/src/components/AddressInputPanel/index.tsx index fce0ca5253..2b322696c8 100644 --- a/src/components/AddressInputPanel/index.tsx +++ b/src/components/AddressInputPanel/index.tsx @@ -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( @@ -155,7 +155,6 @@ export default function AddressInputPanel({ const theme = useTheme() const error = Boolean((value || '').length > 0 && !loading && !address) - if (!isEVM) return null return ( { const { networkInfo } = useActiveWeb3React() - const isZapAvailable = !!(networkInfo as EVMNetworkInfo).elastic.zap + const isZapAvailable = !!networkInfo.elastic.zap const theme = useTheme() const tmp = true @@ -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(null) diff --git a/src/components/FeeSelector/hook.ts b/src/components/FeeSelector/hook.ts index 7f5baec1e5..5d6570f030 100644 --- a/src/components/FeeSelector/hook.ts +++ b/src/components/FeeSelector/hook.ts @@ -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' @@ -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 @@ -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 } diff --git a/src/components/Header/groups/EarnNavGroup.tsx b/src/components/Header/groups/EarnNavGroup.tsx index 3baad2ee91..d0268ee58b 100644 --- a/src/components/Header/groups/EarnNavGroup.tsx +++ b/src/components/Header/groups/EarnNavGroup.tsx @@ -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 ( { )} {/* - !(isSolana || chainId === ChainId.LINEA_TESTNET) && ( + !(chainId === ChainId.LINEA_TESTNET) && ( void }) => { const theme = useTheme() - const { isWrongNetwork, walletSolana, walletEVM } = useActiveWeb3React() + const { isWrongNetwork, wallet } = useActiveWeb3React() const { changeNetwork } = useChangeNetwork() const [dragging, setDragging] = useState(false) const ref = useRef(null) @@ -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 }, ) diff --git a/src/components/Header/web3/SelectWallet.tsx b/src/components/Header/web3/SelectWallet.tsx index fe6fe28ef6..8693939b92 100644 --- a/src/components/Header/web3/SelectWallet.tsx +++ b/src/components/Header/web3/SelectWallet.tsx @@ -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() diff --git a/src/components/Header/web3/SignWallet/ProfileContent.tsx b/src/components/Header/web3/SignWallet/ProfileContent.tsx index 48c1f1315c..239180826d 100644 --- a/src/components/Header/web3/SignWallet/ProfileContent.tsx +++ b/src/components/Header/web3/SignWallet/ProfileContent.tsx @@ -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) @@ -230,7 +230,7 @@ const ProfileContent = ({ scroll, toggleModal }: { scroll?: boolean; toggleModal 1}> - {!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && isEVM && ( + {!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && ( { toggleModal() diff --git a/src/components/Header/web3/WalletModal/Option.tsx b/src/components/Header/web3/WalletModal/Option.tsx index 03df6ab5e8..19347e344c 100644 --- a/src/components/Header/web3/WalletModal/Option.tsx +++ b/src/components/Header/web3/WalletModal/Option.tsx @@ -1,15 +1,13 @@ import { Trans } from '@lingui/macro' -import { WalletReadyState } from '@solana/wallet-adapter-base' import { darken } from 'polished' import React from 'react' import styled, { css } from 'styled-components' import { MouseoverTooltip } from 'components/Tooltip' -import { SUPPORTED_WALLET, SUPPORTED_WALLETS } from 'constants/wallets' +import { SUPPORTED_WALLET, SUPPORTED_WALLETS, WalletReadyState } from 'constants/wallets' import { useActiveWeb3React } from 'hooks' import { useIsAcceptedTerm } from 'state/user/hooks' import { ExternalLink } from 'theme' -import { isEVMWallet, isSolanaWallet } from 'utils' import checkForBraveBrowser from 'utils/checkForBraveBrowser' import { C98OverrideGuide } from './WarningBox' @@ -106,19 +104,17 @@ const StyledLink = styled(ExternalLink)` const Option = ({ walletKey, readyState, - isSupportCurrentChain, installLink, isOverridden, onSelected, }: { walletKey: SUPPORTED_WALLET - isSupportCurrentChain: boolean readyState?: WalletReadyState installLink?: string isOverridden?: boolean onSelected?: (walletKey: SUPPORTED_WALLET) => any }) => { - const { walletKey: walletKeyConnected, isEVM, isSolana } = useActiveWeb3React() + const { walletKey: walletKeyConnected } = useActiveWeb3React() const isBraveBrowser = checkForBraveBrowser() const [isAcceptedTerm] = useIsAcceptedTerm() @@ -134,10 +130,8 @@ const Option = ({ onClick={ onSelected && !isConnected && - (readyState === WalletReadyState.Installed || - (readyState === WalletReadyState.Loadable && isSolanaWallet(wallet))) && + readyState === WalletReadyState.Installed && isAcceptedTerm && - isSupportCurrentChain && !isOverridden && !(walletKey === 'BRAVE' && !isBraveBrowser) ? () => onSelected(walletKey) @@ -157,13 +151,9 @@ const Option = ({ ) - if (!isSupportCurrentChain) { - return null - } - if (!isAcceptedTerm) return content - if (readyState === WalletReadyState.Loadable && isEVMWallet(wallet) && wallet.href) { + if (readyState === WalletReadyState.Loadable && wallet.href) { return {content} } @@ -193,7 +183,7 @@ const Option = ({ ) } // Brave wallet overrided by Metamask extension - if (isBraveBrowser && !window.ethereum?.isBraveWallet && isEVM) { + if (isBraveBrowser && !window.ethereum?.isBraveWallet) { return ( transparentize(0.8, theme.primary)}; - color: ${({ theme }) => theme.primary}; - width: 24px; - height: 24px; - border-radius: 50%; - margin: 0 8px !important; - font-size: 12px; -` - enum WALLET_VIEWS { CHANGE_WALLET = 'CHANGE_WALLET', ACCOUNT = 'account', @@ -130,16 +115,14 @@ enum WALLET_VIEWS { type WalletInfoExtended = WalletInfo & { key: SUPPORTED_WALLET - readyState: WalletReadyState | undefined - isSupportCurrentChain: boolean + readyStateResult: WalletReadyState | undefined isOverridden: boolean } export default function WalletModal() { - const { isWrongNetwork, account, isSolana, isEVM, walletKey } = useActiveWeb3React() + const { isWrongNetwork, account, walletKey } = useActiveWeb3React() // important that these are destructed from the account-specific web3-react context const { active, connector } = useWeb3React() - const { connected, connecting, wallet: solanaWallet } = useWallet() const { tryActivation } = useActivationWallet() const theme = useTheme() @@ -202,14 +185,6 @@ export default function WalletModal() { } }, [setWalletView, active, error, connector, walletModalOpen, activePrevious, connectorPrevious]) - useEffect(() => { - // If is there any issue when connecting wallet, solanaWallet will be cleared and set to null - // Use it to check is there any error after connecting - if (!connecting && !connected && !solanaWallet) { - setPendingError(true) - } - }, [connecting, connected, solanaWallet]) - const [, setIsConnectingWallet] = useIsConnectingWallet() const handleWalletChange = useCallback( async (walletKey: SUPPORTED_WALLET) => { @@ -236,19 +211,13 @@ export default function WalletModal() { // Generate list of wallets and states of it depend on current network const parsedWalletList: WalletInfoExtended[] = (Object.keys(SUPPORTED_WALLETS) as SUPPORTED_WALLET[]).map(k => { const wallet = SUPPORTED_WALLETS[k] - const readyState = (() => { - const readyStateEVM = isEVMWallet(wallet) ? wallet.readyState() : undefined - const readyStateSolana = isSolanaWallet(wallet) ? wallet.readyStateSolana() : undefined - return (isEVM && readyStateEVM) || (isSolana && readyStateSolana) || readyStateEVM || readyStateSolana - })() - const isSupportCurrentChain = (isEVMWallet(wallet) && isEVM) || (isSolanaWallet(wallet) && isSolana) || false + const readyState = wallet.readyState() const overridden = isOverriddenWallet(k) || (walletKey === 'COIN98' && !window.ethereum?.isCoin98) return { ...wallet, key: k, - readyState, - isSupportCurrentChain, + readyStateResult: readyState, isOverridden: overridden, installLink: readyState === WalletReadyState.NotDetected ? wallet.installLink : undefined, } @@ -262,23 +231,22 @@ export default function WalletModal() { } const sortWallets = (walletA: WalletInfoExtended, walletB: WalletInfoExtended): number => { return ( - sortPoint[walletB.readyState || WalletReadyState.Unsupported] - - sortPoint[walletA.readyState || WalletReadyState.Unsupported] + sortPoint[walletB.readyStateResult || WalletReadyState.Unsupported] - + sortPoint[walletA.readyStateResult || WalletReadyState.Unsupported] ) } return ( parsedWalletList .sort(sortWallets) // Filter Unsupported state wallets - .filter(wallet => wallet.readyState !== WalletReadyState.Unsupported) + .filter(wallet => wallet.readyStateResult !== WalletReadyState.Unsupported) .map(wallet => (