Skip to content

Commit

Permalink
fix: network
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Oct 27, 2023
1 parent 065397e commit 13dd14b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export default function App() {
<Routes>
{/* From react-router-dom@6.5.0, :fromCurrency-to-:toCurrency no long works, need to manually parse the params */}
<Route path={`${APP_PATHS.SWAP}/:network/:currency?`} element={<SwapPage />} />
<Route path={`${APP_PATHS.PARTNER_SWAP}/:network`} element={<PartnerSwap />} />
<Route path={`${APP_PATHS.PARTNER_SWAP}`} element={<PartnerSwap />} />
{CHAINS_SUPPORT_CROSS_CHAIN.includes(chainId) && (
<Route path={`${APP_PATHS.CROSS_CHAIN}`} element={<SwapV3 />} />
)}
Expand Down
19 changes: 16 additions & 3 deletions src/pages/PartnerSwap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import {
SwapFormWrapper,
highlight,
} from 'components/swapv2/styleds'
import { SUPPORTED_NETWORKS } from 'constants/networks'
import { useActiveWeb3React } from 'hooks'
import { useAllTokens, useIsLoadedTokenDefault } from 'hooks/Tokens'
import useTheme from 'hooks/useTheme'
import { useSyncNetworkParamWithStore } from 'hooks/web3/useSyncNetworkParamWithStore'
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
import { BodyWrapper } from 'pages/AppBody'
import CrossChain from 'pages/CrossChain'
import CrossChainLink from 'pages/CrossChain/CrossChainLink'
Expand Down Expand Up @@ -80,10 +81,22 @@ export const RoutingIconWrapper = styled(RoutingIcon)`
`

export default function Swap() {
useSyncNetworkParamWithStore()
const { chainId } = useActiveWeb3React()
const isShowTradeRoutes = useShowTradeRoutes()
const [searchParams, setSearchParams] = useSearchParams()

const requestChainId = searchParams.get('chainId')
const { changeNetwork } = useChangeNetwork()

useEffect(() => {
if (requestChainId && SUPPORTED_NETWORKS.includes(+requestChainId) && chainId !== +requestChainId) {
changeNetwork(+requestChainId)
} else {
searchParams.delete('chainId')
setSearchParams(searchParams)
}
}, [chainId, requestChainId, changeNetwork, searchParams, setSearchParams])

const isShowTradeRoutes = useShowTradeRoutes()
const [routeSummary, setRouteSummary] = useState<DetailedRouteSummary>()
const [isSelectCurrencyManually, setIsSelectCurrencyManually] = useState(false) // true when: select token input, output manually or click rotate token.

Expand Down

0 comments on commit 13dd14b

Please sign in to comment.