Skip to content

Commit 9108a7a

Browse files
authored
fix: Add query check to swap state and reset to origin (#12456)
<!-- Before opening a pull request, please read the [contributing guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md) first --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the `handleOnClick` function in the `SentryErrorBoundary` component across two files to reload the current page using the `origin` of the window location. Additionally, it modifies the logic for determining `inputChainId` and `outputChainId` in the `hooks.ts` file. ### Detailed summary - In `apps/web/src/components/ErrorBoundary/SentryErrorBoundary.tsx`: - Updated `handleOnClick` to reload the page using `window.location.href = origin`. - In `apps/solana/src/components/SentryErrorBoundary.tsx`: - Updated `handleOnClick` similarly to reload the page using `window.location.href = origin`. - In `apps/web/src/state/swap/hooks.ts`: - Removed duplicate import of `NonEVMChainId` and `UnifiedChainId`. - Updated logic for `inputChainId` and `outputChainId` to exclude `Aptos` chains. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 76d29a4 commit 9108a7a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

apps/solana/src/components/SentryErrorBoundary.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import Page from './Layout/Page'
66

77
export function SentryErrorBoundary({ children }: PropsWithChildren) {
88
const { t } = useTranslation()
9-
const handleOnClick = useCallback(() => window.open('https://pancakeswap.finance', '_self'), [])
9+
const handleOnClick = useCallback(() => {
10+
const { origin } = window.location
11+
window.location.href = origin
12+
}, [])
1013
return (
1114
<SErrorBoundary
1215
beforeCapture={(scope) => {

apps/web/src/components/ErrorBoundary/SentryErrorBoundary.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { useCallback } from 'react'
66

77
export function SentryErrorBoundary({ children }) {
88
const { t } = useTranslation()
9-
const handleOnClick = useCallback(() => window.location.reload(), [])
9+
const handleOnClick = useCallback(() => {
10+
const { origin } = window.location
11+
window.location.href = origin
12+
}, [])
1013
return (
1114
<SErrorBoundary
1215
beforeCapture={(scope) => {

apps/web/src/state/swap/hooks.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Currency, Native, SOL, Trade, TradeType, UnifiedNativeCurrency } from '@pancakeswap/sdk'
22
import { CAKE, STABLE_COIN, USDC, USDT } from '@pancakeswap/tokens'
33
import { PairDataTimeWindowEnum } from '@pancakeswap/uikit'
4+
import { isAptos, NonEVMChainId, UnifiedChainId } from '@pancakeswap/chains'
45
import { useQuery } from '@tanstack/react-query'
56
import { getChainId } from 'config/chains'
67
import { DEFAULT_INPUT_CURRENCY } from 'config/constants/exchange'
@@ -14,7 +15,6 @@ import { ParsedUrlQuery } from 'querystring'
1415
import { useCallback, useEffect, useState } from 'react'
1516
import { ChartPeriod, chainIdToExplorerInfoChainName, explorerApiClient } from 'state/info/api/client'
1617
import { isAddressEqual, safeGetAddress, safeGetUnifiedAddress } from 'utils'
17-
import { NonEVMChainId, UnifiedChainId } from '@pancakeswap/chains'
1818
import { useBridgeAvailableChains } from 'views/Swap/Bridge/hooks'
1919
import { Field, replaceSwapState } from './actions'
2020
import { SwapState, swapReducerAtom } from './reducer'
@@ -82,8 +82,10 @@ export function queryParametersToSwapState(
8282
// NOTE: if chainOut is not provided, means user want to swap on the same chain
8383
const outputChain = parsedQs.chainOut || inputChain
8484

85-
const inputChainId = typeof inputChain === 'string' ? getChainId(inputChain) : undefined
86-
const outputChainId = typeof outputChain === 'string' ? getChainId(outputChain) : undefined
85+
const inputChainId =
86+
typeof inputChain === 'string' && !isAptos(getChainId(inputChain)) ? getChainId(inputChain) : undefined
87+
const outputChainId =
88+
typeof outputChain === 'string' && !isAptos(getChainId(outputChain)) ? getChainId(outputChain) : undefined
8789

8890
const recipient = validatedRecipient(parsedQs.recipient)
8991

0 commit comments

Comments
 (0)