diff --git a/package.json b/package.json index 039885d022..55d9b8e18f 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,7 @@ "@reach/dialog": "^0.17.0", "@reach/portal": "^0.17.0", "@reduxjs/toolkit": "1.9.3", - "@sentry/react": "^7.18.0", - "@sentry/tracing": "^7.18.0", + "@sentry/react": "^8.34.0", "@tanstack/react-query": "^5.52.1", "@use-gesture/react": "^10.2.27", "@zkmelabs/widget": "^0.1.3", diff --git a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx index ffb62a72c2..5380344cae 100644 --- a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx +++ b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx @@ -96,7 +96,6 @@ type Props = { defaultOutputAmount?: string defaultActiveMakingAmount?: string defaultExpire?: Date - setIsSelectCurrencyManual?: (val: boolean) => void note?: string orderInfo?: LimitOrder flowState: TransactionFlowState @@ -146,7 +145,6 @@ const LimitOrderForm = forwardRef(function LimitOrd defaultActiveMakingAmount = '', defaultExpire, defaultRate = { rate: '', invertRate: '', invert: false }, - setIsSelectCurrencyManual, note = '', orderInfo, flowState, @@ -341,10 +339,9 @@ const LimitOrderForm = forwardRef(function LimitOrd return } setCurrencyIn(currency) - setIsSelectCurrencyManual?.(true) resetRate && setRateInfo(rateInfo => ({ ...rateInfo, invertRate: '', rate: '', rateFraction: undefined })) }, - [currencyOut, setCurrencyIn, setIsSelectCurrencyManual, switchCurrency], + [currencyOut, setCurrencyIn, switchCurrency], ) const switchToWeth = useCallback(() => { @@ -359,7 +356,6 @@ const LimitOrderForm = forwardRef(function LimitOrd return } setCurrencyOut(currency) - setIsSelectCurrencyManual?.(true) setRateInfo({ ...rateInfo, invertRate: '', rate: '', rateFraction: undefined }) } @@ -368,7 +364,6 @@ const LimitOrderForm = forwardRef(function LimitOrd if (isEdit) return setRotate(prev => !prev) switchCurrency() - setIsSelectCurrencyManual?.(true) } const parseInputAmount = tryParseAmount(inputAmount, currencyIn ?? undefined) diff --git a/src/components/swapv2/LimitOrder/index.tsx b/src/components/swapv2/LimitOrder/index.tsx index f7e7f3c9b4..3c82fd436d 100644 --- a/src/components/swapv2/LimitOrder/index.tsx +++ b/src/components/swapv2/LimitOrder/index.tsx @@ -4,24 +4,14 @@ import { memo, useState } from 'react' import { TutorialKeys } from 'components/Tutorial/TutorialSwap' import Tutorial from 'components/swapv2/LimitOrder/Tutorial' import { TRANSACTION_STATE_DEFAULT } from 'constants/index' -import useSyncTokenSymbolToUrl from 'hooks/useSyncTokenSymbolToUrl' -import { useLimitActionHandlers, useLimitState } from 'state/limit/hooks' +import { useLimitState } from 'state/limit/hooks' import { TransactionFlowState } from 'types/TransactionFlowState' import LimitOrderForm from './LimitOrderForm' -type Props = { - setIsSelectCurrencyManual: (v: boolean) => void - isSelectCurrencyManual: boolean -} - -function LimitOrderComp({ setIsSelectCurrencyManual, isSelectCurrencyManual }: Props) { - const { onSelectPair } = useLimitActionHandlers() - +function LimitOrderComp() { const { currencyIn, currencyOut } = useLimitState() - useSyncTokenSymbolToUrl(currencyIn, currencyOut, onSelectPair, isSelectCurrencyManual) - const [showTutorial, setShowTutorial] = useState(!localStorage.getItem(TutorialKeys.SHOWED_LO_GUIDE)) // modal and loading @@ -46,7 +36,6 @@ function LimitOrderComp({ setIsSelectCurrencyManual, isSelectCurrencyManual }: P setFlowState={setFlowState} currencyIn={currencyIn} currencyOut={currencyOut} - setIsSelectCurrencyManual={setIsSelectCurrencyManual} note={ currencyOut?.isNative ? t`Note: Once your order is filled, you will receive ${name} (${symbol})` : undefined } diff --git a/src/hooks/useSyncTokenSymbolToUrl.ts b/src/hooks/useSyncTokenSymbolToUrl.ts index 9499dc686d..e28cd0ddd9 100644 --- a/src/hooks/useSyncTokenSymbolToUrl.ts +++ b/src/hooks/useSyncTokenSymbolToUrl.ts @@ -1,17 +1,14 @@ -import { ChainId, Currency } from '@kyberswap/ks-sdk-core' +import { Currency } from '@kyberswap/ks-sdk-core' import { stringify } from 'querystring' -import { useCallback, useEffect, useMemo, useRef } from 'react' -import { Params, useLocation, useNavigate, useParams } from 'react-router-dom' +import { useCallback, useEffect } from 'react' +import { Params, useLocation, useNavigate } from 'react-router-dom' import { APP_PATHS } from 'constants/index' import { NETWORKS_INFO } from 'constants/networks' -import { NativeCurrencies } from 'constants/tokens' import { useActiveWeb3React } from 'hooks' -import { filterTokensWithExactKeyword } from 'utils/filtering' import { convertToSlug, getSymbolSlug } from 'utils/string' -import { convertSymbol } from 'utils/tokenInfo' -import { useAllTokens, useIsLoadedTokenDefault } from './Tokens' +import { useIsLoadedTokenDefault } from './Tokens' import useParsedQueryString from './useParsedQueryString' type TokenSymbolParams = { @@ -43,16 +40,11 @@ export default function useSyncTokenSymbolToUrl( isSelectCurrencyManual: boolean, disabled = false, ) { - const params = useParams() - const { fromCurrency, toCurrency, network } = getUrlMatchParams(params) - const { chainId } = useActiveWeb3React() const navigate = useNavigate() const qs = useParsedQueryString() const { pathname } = useLocation() const isLoadedTokenDefault = useIsLoadedTokenDefault() - const allTokens = useAllTokens() - const firstTokenChainId = useMemo(() => Object.values(allTokens)[0]?.chainId, [allTokens]) const currentPath = [APP_PATHS.SWAP, APP_PATHS.LIMIT].find(path => pathname.startsWith(path)) || APP_PATHS.SWAP @@ -64,17 +56,6 @@ export default function useSyncTokenSymbolToUrl( [navigate, qs, currentPath], ) - const findTokenBySymbol = useCallback( - (keyword: string, chainId: ChainId) => { - const nativeToken = NativeCurrencies[chainId] - if (keyword === getSymbolSlug(nativeToken)) { - return nativeToken - } - return filterTokensWithExactKeyword(chainId, Object.values(allTokens), keyword)[0] - }, - [allTokens], - ) - const syncTokenSymbolToUrl = useCallback( (currencyIn: Currency | undefined, currencyOut: Currency | undefined) => { const symbolIn = getSymbolSlug(currencyIn) @@ -86,54 +67,6 @@ export default function useSyncTokenSymbolToUrl( [redirect, chainId], ) - const findTokenPairFromUrl = useCallback( - (chainId: ChainId) => { - if (!fromCurrency || !network) return - // net/symbol - const isSame = fromCurrency && fromCurrency === toCurrency - if (!toCurrency || isSame) { - const fromToken = findTokenBySymbol(fromCurrency, chainId) - if (fromToken) { - onCurrencySelection(fromToken) - if (isSame) redirect(`${network}/${fromCurrency}`) - } else { - redirect(network) - } - return - } - - // net/sym-to-sym - const fromToken = findTokenBySymbol(convertSymbol(network, fromCurrency), chainId) - const toToken = findTokenBySymbol(convertSymbol(network, toCurrency), chainId) - - if (!toToken || !fromToken) { - redirect(network) - return - } - onCurrencySelection(fromToken, toToken) - }, - [findTokenBySymbol, redirect, onCurrencySelection, fromCurrency, network, toCurrency], - ) - - const checkedTokenFromUrlWhenInit = useRef(false) - useEffect(() => { - checkedTokenFromUrlWhenInit.current = false - }, [chainId]) - - useEffect(() => { - if ( - !checkedTokenFromUrlWhenInit.current && - isLoadedTokenDefault && - chainId === firstTokenChainId && - network === NETWORKS_INFO[chainId].route && - !disabled - ) { - // call once - // setTimeout(() => findTokenPairFromUrl(chainId)) - checkedTokenFromUrlWhenInit.current = true - } - }, [isLoadedTokenDefault, firstTokenChainId, chainId, network, disabled, findTokenPairFromUrl]) - // when token change, sync symbol to url useEffect(() => { if (isLoadedTokenDefault && isSelectCurrencyManual && !disabled) { diff --git a/src/index.tsx b/src/index.tsx index a6245e7069..efdb0d8048 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,6 @@ /* eslint-disable prettier/prettier */ // Ordering is intentional and must be preserved: styling, polyfilling, tracing, and then functionality. import * as Sentry from '@sentry/react' -import { BrowserTracing } from '@sentry/tracing' import '@zkmelabs/widget/dist/style.css' import AOS from 'aos' import 'aos/dist/aos.css' @@ -50,14 +49,14 @@ if (ENV_LEVEL > ENV_TYPE.LOCAL) { dsn: SENTRY_DNS, environment: 'production', ignoreErrors: ['AbortError'], - integrations: [new BrowserTracing()], + integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], tracesSampleRate: 0.1, normalizeDepth: 5, + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, }) - Sentry.configureScope(scope => { - scope.setTag('request_id', sentryRequestId) - scope.setTag('version', TAG) - }) + Sentry.setTag('request_id', sentryRequestId) + Sentry.setTag('version', TAG) if (GTM_ID) { TagManager.initialize({ diff --git a/src/pages/SwapV3/index.tsx b/src/pages/SwapV3/index.tsx index 67f13e3d3a..b02b3f72db 100644 --- a/src/pages/SwapV3/index.tsx +++ b/src/pages/SwapV3/index.tsx @@ -95,7 +95,6 @@ export default function Swap() { const qs = useParsedQueryString<{ highlightBox: string }>() const [{ show: isShowTutorial = false }] = useTutorialSwapGuide() const [routeSummary, setRouteSummary] = useState() - const [isSelectCurrencyManually, setIsSelectCurrencyManually] = useState(false) // true when: select token input, output manually or click rotate token. const { pathname } = useLocation() const [searchParams, setSearchParams] = useSearchParams() @@ -181,12 +180,7 @@ export default function Swap() { {activeTab === TAB.LIQUIDITY_SOURCES && ( setActiveTab(TAB.SETTINGS)} /> )} - {activeTab === TAB.LIMIT && ( - - )} + {activeTab === TAB.LIMIT && } {isCrossChainPage && } {activeTab === TAB.GAS_TOKEN && setActiveTab(TAB.SWAP)} />} diff --git a/src/state/limit/hooks.ts b/src/state/limit/hooks.ts index c65f5cd8d2..445a15fc4b 100644 --- a/src/state/limit/hooks.ts +++ b/src/state/limit/hooks.ts @@ -53,17 +53,6 @@ export function useLimitActionHandlers() { [onCurrencySelection], ) - const onSelectPair = useCallback( - (currencyIn: Currency | undefined, currencyOut: Currency | undefined, inputAmount?: string) => { - setCurrencyIn(currencyIn) - setCurrencyOut(currencyOut) - if (inputAmount !== undefined) { - setInputValue(inputAmount) - } - }, - [setInputValue, setCurrencyIn, setCurrencyOut], - ) - const pushOrderNeedCreated = useCallback( (order: CreateOrderParam) => { dispatch(pushOrderNeedCreatedAction(order)) @@ -89,7 +78,6 @@ export function useLimitActionHandlers() { switchCurrency: onSwitchTokensV2, setCurrencyIn, setCurrencyOut, - onSelectPair, pushOrderNeedCreated, removeOrderNeedCreated, setOrderEditing, diff --git a/yarn.lock b/yarn.lock index 6d1abb2957..e58d78dabb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4895,15 +4895,56 @@ "@noble/hashes" "~1.4.0" "@scure/base" "~1.1.6" -"@sentry/browser@7.24.2": - version "7.24.2" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.24.2.tgz#1e514448cd07ff7da78d02797149ecc1922ffcc2" - integrity sha512-X6NbQT0Dp+h54j73TPLgWf3yyLyTZGJI5WQSGEsNIroqhVzD3UF8M+E+3roYpSJDDyYdfuM+WBme+MYkmeqHIw== - dependencies: - "@sentry/core" "7.24.2" - "@sentry/types" "7.24.2" - "@sentry/utils" "7.24.2" - tslib "^1.9.3" +"@sentry-internal/browser-utils@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.34.0.tgz#36a50d503ad4ad51fce22e80670f8fd6fd195a27" + integrity sha512-4AcYOzPzD1tL5eSRQ/GpKv5enquZf4dMVUez99/Bh3va8qiJrNP55AcM7UzZ7WZLTqKygIYruJTU5Zu2SpEAPQ== + dependencies: + "@sentry/core" "8.34.0" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" + +"@sentry-internal/feedback@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.34.0.tgz#ff0db65c36f13665db99e3e22f2032bfdda98731" + integrity sha512-aYSM2KPUs0FLPxxbJCFSwCYG70VMzlT04xepD1Y/tTlPPOja/02tSv2tyOdZbv8Uw7xslZs3/8Lhj74oYcTBxw== + dependencies: + "@sentry/core" "8.34.0" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" + +"@sentry-internal/replay-canvas@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.34.0.tgz#10acadaef74e982dee2b9842a3eb6fec73f032ed" + integrity sha512-x8KhZcCDpbKHqFOykYXiamX6x0LRxv6N1OJHoH+XCrMtiDBZr4Yo30d/MaS6rjmKGMtSRij30v+Uq+YWIgxUrg== + dependencies: + "@sentry-internal/replay" "8.34.0" + "@sentry/core" "8.34.0" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" + +"@sentry-internal/replay@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.34.0.tgz#b730919a174cc5ae8a77f79fb24a5ffb18e44db5" + integrity sha512-EoMh9NYljNewZK1quY23YILgtNdGgrkzJ9TPsj6jXUG0LZ0Q7N7eFWd0xOEDBvFxrmI3cSXF1i4d1sBb+eyKRw== + dependencies: + "@sentry-internal/browser-utils" "8.34.0" + "@sentry/core" "8.34.0" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" + +"@sentry/browser@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.34.0.tgz#d2dfc2dbbfa9132d5c3e951f0a4b467805bc4c75" + integrity sha512-3HHG2NXxzHq1lVmDy2uRjYjGNf9NsJsTPlOC70vbQdOb+S49EdH/XMPy+J3ruIoyv6Cu0LwvA6bMOM6rHZOgNQ== + dependencies: + "@sentry-internal/browser-utils" "8.34.0" + "@sentry-internal/feedback" "8.34.0" + "@sentry-internal/replay" "8.34.0" + "@sentry-internal/replay-canvas" "8.34.0" + "@sentry/core" "8.34.0" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" "@sentry/core@7.24.2": version "7.24.2" @@ -4914,16 +4955,24 @@ "@sentry/utils" "7.24.2" tslib "^1.9.3" -"@sentry/react@^7.18.0": - version "7.24.2" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.24.2.tgz#cc471cd75727c518f8942d8cf9a7777752fcf4b5" - integrity sha512-NK4/SDIWyQVYdi/EPfHfp7d0+flGNHbBuqV/GG/+CLSekUCuACsczSEWgMSyEad4ptbF9850yt5WN15oL5vAXg== +"@sentry/core@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.34.0.tgz#92efe1cc8ced843beee636c344e66086d8915563" + integrity sha512-adrXCTK/zsg5pJ67lgtZqdqHvyx6etMjQW3P82NgWdj83c8fb+zH+K79Z47pD4zQjX0ou2Ws5nwwi4wJbz4bfA== dependencies: - "@sentry/browser" "7.24.2" - "@sentry/types" "7.24.2" - "@sentry/utils" "7.24.2" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" + +"@sentry/react@^8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-8.34.0.tgz#f131d3b7168469617722474a3465a16cdcd77cb4" + integrity sha512-gIgzhj7h67C+Sdq2ul4fOSK142Gf0uV99bqHRdtIiUlXw9yjzZQY5TKTtzbOaevn7qBJ0xrRKtIRUbOBMl0clw== + dependencies: + "@sentry/browser" "8.34.0" + "@sentry/core" "8.34.0" + "@sentry/types" "8.34.0" + "@sentry/utils" "8.34.0" hoist-non-react-statics "^3.3.2" - tslib "^1.9.3" "@sentry/tracing@^7.18.0": version "7.24.2" @@ -4940,6 +4989,11 @@ resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.24.2.tgz#2ef728db8eea14de8ba916896837d0cbeb3d28da" integrity sha512-x2LEnKBPzUVzTGspvB0CjZmt1dWeJsLVHGeDKPUMUm004nIscFCxJsmYefqaJQdaIUMqDit5ApwcmKchuK6VKQ== +"@sentry/types@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.34.0.tgz#b02da72d1be67df5246aa9a97ca661ee71569372" + integrity sha512-zLRc60CzohGCo6zNsNeQ9JF3SiEeRE4aDCP9fDDdIVCOKovS+mn1rtSip0qd0Vp2fidOu0+2yY0ALCz1A3PJSQ== + "@sentry/utils@7.24.2": version "7.24.2" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.24.2.tgz#7120a8d36bd1d05043c902a0f22fbc2012fe2116" @@ -4948,6 +5002,13 @@ "@sentry/types" "7.24.2" tslib "^1.9.3" +"@sentry/utils@8.34.0": + version "8.34.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.34.0.tgz#5ba543381a9de0ada1196df1fc5cde3b891de41e" + integrity sha512-W1KoRlFUjprlh3t86DZPFxLfM6mzjRzshVfMY7vRlJFymBelJsnJ3A1lPeBZM9nCraOSiw6GtOWu6k5BAkiGIg== + dependencies: + "@sentry/types" "8.34.0" + "@servie/events@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@servie/events/-/events-1.0.0.tgz#8258684b52d418ab7b86533e861186638ecc5dc1"