ci(release): publish latest release

parent 2c7635f6
IPFS hash of the deployment: IPFS hash of the deployment:
- CIDv0: `Qmba9yfwsUsVcbQA6CAkQCxqFCoLJapvjV7RQsp26zJvBh` - CIDv0: `QmccrxuuPdXnhgCm2377DmcpBZtS36JK2kHNhGcutyYCfC`
- CIDv1: `bafybeigetwjqz26or3og65klvf2oefze44ct4oukkncojpcb5wocbc6x7a` - CIDv1: `bafybeiguflcfu2p2lxehliz5wutxlmqtjfeg7qk4pw2ifw24xbbhjhcf5m`
The latest release is always mirrored at [app.uniswap.org](https://app.uniswap.org). The latest release is always mirrored at [app.uniswap.org](https://app.uniswap.org).
...@@ -10,15 +10,16 @@ You can also access the Uniswap Interface from an IPFS gateway. ...@@ -10,15 +10,16 @@ You can also access the Uniswap Interface from an IPFS gateway.
Your Uniswap settings are never remembered across different URLs. Your Uniswap settings are never remembered across different URLs.
IPFS gateways: IPFS gateways:
- https://bafybeigetwjqz26or3og65klvf2oefze44ct4oukkncojpcb5wocbc6x7a.ipfs.dweb.link/ - https://bafybeiguflcfu2p2lxehliz5wutxlmqtjfeg7qk4pw2ifw24xbbhjhcf5m.ipfs.dweb.link/
- https://bafybeigetwjqz26or3og65klvf2oefze44ct4oukkncojpcb5wocbc6x7a.ipfs.cf-ipfs.com/ - https://bafybeiguflcfu2p2lxehliz5wutxlmqtjfeg7qk4pw2ifw24xbbhjhcf5m.ipfs.cf-ipfs.com/
- [ipfs://Qmba9yfwsUsVcbQA6CAkQCxqFCoLJapvjV7RQsp26zJvBh/](ipfs://Qmba9yfwsUsVcbQA6CAkQCxqFCoLJapvjV7RQsp26zJvBh/) - [ipfs://QmccrxuuPdXnhgCm2377DmcpBZtS36JK2kHNhGcutyYCfC/](ipfs://QmccrxuuPdXnhgCm2377DmcpBZtS36JK2kHNhGcutyYCfC/)
### 5.27.6 (2024-05-16) ### 5.27.7 (2024-05-16)
### Bug Fixes ### Bug Fixes
* **web:** Allow viewing pool mgmt pages when disconnected - prod (#8248) f7cce8f * **web:** support multichain input params 272661d
* **web:** support multichain input params 8620c6c
web/5.27.6 web/5.27.7
\ No newline at end of file \ No newline at end of file
...@@ -89,7 +89,7 @@ export default memo(function CurrencySearchModal({ ...@@ -89,7 +89,7 @@ export default memo(function CurrencySearchModal({
if (warningToken) { if (warningToken) {
content = ( content = (
<TokenSafety <TokenSafety
tokenAddress={warningToken.address} token0={warningToken}
onContinue={() => handleCurrencySelect(warningToken)} onContinue={() => handleCurrencySelect(warningToken)}
onCancel={() => setModalView(CurrencyModalView.search)} onCancel={() => setModalView(CurrencyModalView.search)}
showCancel={true} showCancel={true}
......
...@@ -7,8 +7,8 @@ interface TokenSafetyModalProps extends TokenSafetyProps { ...@@ -7,8 +7,8 @@ interface TokenSafetyModalProps extends TokenSafetyProps {
export default function TokenSafetyModal({ export default function TokenSafetyModal({
isOpen, isOpen,
tokenAddress, token0,
secondTokenAddress, token1,
onContinue, onContinue,
onCancel, onCancel,
onBlocked, onBlocked,
...@@ -17,8 +17,8 @@ export default function TokenSafetyModal({ ...@@ -17,8 +17,8 @@ export default function TokenSafetyModal({
return ( return (
<Modal isOpen={isOpen} onDismiss={onCancel}> <Modal isOpen={isOpen} onDismiss={onCancel}>
<TokenSafety <TokenSafety
tokenAddress={tokenAddress} token0={token0}
secondTokenAddress={secondTokenAddress} token1={token1}
onContinue={onContinue} onContinue={onContinue}
onBlocked={onBlocked} onBlocked={onBlocked}
onCancel={onCancel} onCancel={onCancel}
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
useTokenWarning, useTokenWarning,
Warning, Warning,
} from 'constants/tokenSafety' } from 'constants/tokenSafety'
import { useToken } from 'hooks/Tokens'
import { Trans } from 'i18n' import { Trans } from 'i18n'
import { ExternalLink as LinkIconFeather } from 'react-feather' import { ExternalLink as LinkIconFeather } from 'react-feather'
import { Text } from 'rebass' import { Text } from 'rebass'
...@@ -196,59 +195,50 @@ const StyledExternalLink = styled(ExternalLink)` ...@@ -196,59 +195,50 @@ const StyledExternalLink = styled(ExternalLink)`
` `
export interface TokenSafetyProps { export interface TokenSafetyProps {
tokenAddress?: string token0?: Token
secondTokenAddress?: string token1?: Token
onContinue: () => void onContinue: () => void
onCancel: () => void onCancel: () => void
onBlocked?: () => void onBlocked?: () => void
showCancel?: boolean showCancel?: boolean
} }
export default function TokenSafety({ export default function TokenSafety({ token0, token1, onContinue, onCancel, onBlocked, showCancel }: TokenSafetyProps) {
tokenAddress,
secondTokenAddress,
onContinue,
onCancel,
onBlocked,
showCancel,
}: TokenSafetyProps) {
const logos = [] const logos = []
const urls = [] const urls = []
const token1 = useToken(tokenAddress) const token0Warning = useTokenWarning(token0?.address, token0?.chainId)
const token1Warning = useTokenWarning(tokenAddress, token1?.chainId) const token1Warning = useTokenWarning(token1?.address, token1?.chainId)
const token2 = useToken(secondTokenAddress)
const token2Warning = useTokenWarning(secondTokenAddress, token2?.chainId)
const token0Unsupported = !token0Warning?.canProceed
const token1Unsupported = !token1Warning?.canProceed const token1Unsupported = !token1Warning?.canProceed
const token2Unsupported = !token2Warning?.canProceed
// Logic for only showing the 'unsupported' warning if one is supported and other isn't // Logic for only showing the 'unsupported' warning if one is supported and other isn't
if (token1 && token1Warning && (token1Unsupported || !(token2Warning && token2Unsupported))) { if (token0 && token0Warning && (token0Unsupported || !(token1Warning && token1Unsupported))) {
logos.push(<CurrencyLogo key={token0.address} currency={token0} size={48} />)
urls.push(<ExplorerView token={token0} />)
}
if (token1 && token1Warning && (token1Unsupported || !(token0Warning && token0Unsupported))) {
logos.push(<CurrencyLogo key={token1.address} currency={token1} size={48} />) logos.push(<CurrencyLogo key={token1.address} currency={token1} size={48} />)
urls.push(<ExplorerView token={token1} />) urls.push(<ExplorerView token={token1} />)
} }
if (token2 && token2Warning && (token2Unsupported || !(token1Warning && token1Unsupported))) {
logos.push(<CurrencyLogo key={token2.address} currency={token2} size={48} />)
urls.push(<ExplorerView token={token2} />)
}
const plural = logos.length > 1 const plural = logos.length > 1
// Show higher level warning if two are present // Show higher level warning if two are present
let displayWarning = token1Warning let displayWarning = token0Warning
if (!token1Warning || (token2Warning && token2Unsupported && !token1Unsupported)) { if (!token0Warning || (token1Warning && token1Unsupported && !token0Unsupported)) {
displayWarning = token2Warning displayWarning = token1Warning
} }
// If a warning is acknowledged, import these tokens // If a warning is acknowledged, import these tokens
const addToken = useAddUserToken() const addToken = useAddUserToken()
const acknowledge = () => { const acknowledge = () => {
if (token0) {
addToken(token0)
}
if (token1) { if (token1) {
addToken(token1) addToken(token1)
} }
if (token2) {
addToken(token2)
}
onContinue() onContinue()
} }
......
...@@ -148,7 +148,7 @@ function TDPSwapComponent() { ...@@ -148,7 +148,7 @@ function TDPSwapComponent() {
{warning && <TokenSafetyMessage tokenAddress={address} warning={warning} />} {warning && <TokenSafetyMessage tokenAddress={address} warning={warning} />}
<TokenSafetyModal <TokenSafetyModal
isOpen={openTokenSafetyModal || !!continueSwap} isOpen={openTokenSafetyModal || !!continueSwap}
tokenAddress={address} token0={currency.isToken ? currency : undefined}
onContinue={() => onResolveSwap(true)} onContinue={() => onResolveSwap(true)}
onBlocked={() => { onBlocked={() => {
setOpenTokenSafetyModal(false) setOpenTokenSafetyModal(false)
......
...@@ -14,7 +14,7 @@ function getChainIdFromName(name: string) { ...@@ -14,7 +14,7 @@ function getChainIdFromName(name: string) {
return chainId ? parseInt(chainId) : undefined return chainId ? parseInt(chainId) : undefined
} }
function getParsedChainId(parsedQs?: ParsedQs) { export function getParsedChainId(parsedQs?: ParsedQs) {
const chain = parsedQs?.chain const chain = parsedQs?.chain
if (!chain || typeof chain !== 'string') return if (!chain || typeof chain !== 'string') return
...@@ -44,8 +44,8 @@ export default function useSyncChainQuery() { ...@@ -44,8 +44,8 @@ export default function useSyncChainQuery() {
const [searchParams, setSearchParams] = useSearchParams() const [searchParams, setSearchParams] = useSearchParams()
useEffect(() => { useEffect(() => {
// Change a user's chain on pageload if the connected chainId does not match the query param chain // Change a page chain on pageload if the app chainId does not match the query param chain
if (isConnected && urlChainId && chainIdRef.current === chainId && chainId !== urlChainId) { if (urlChainId && chainIdRef.current === chainId && chainId !== urlChainId) {
selectChain(urlChainId) selectChain(urlChainId)
} }
// If a user has a connected wallet and has manually changed their chain, update the query parameter if it's supported // If a user has a connected wallet and has manually changed their chain, update the query parameter if it's supported
......
...@@ -25,11 +25,9 @@ import { ArrowContainer, ArrowWrapper, OutputSwapSection, SwapSection } from 'co ...@@ -25,11 +25,9 @@ import { ArrowContainer, ArrowWrapper, OutputSwapSection, SwapSection } from 'co
import { CHAIN_INFO, useIsSupportedChainId } from 'constants/chains' import { CHAIN_INFO, useIsSupportedChainId } from 'constants/chains'
import { useIsSwapUnsupported } from 'hooks/useIsSwapUnsupported' import { useIsSwapUnsupported } from 'hooks/useIsSwapUnsupported'
import { useMaxAmountIn } from 'hooks/useMaxAmountIn' import { useMaxAmountIn } from 'hooks/useMaxAmountIn'
import useParsedQueryString from 'hooks/useParsedQueryString'
import usePermit2Allowance, { AllowanceState } from 'hooks/usePermit2Allowance' import usePermit2Allowance, { AllowanceState } from 'hooks/usePermit2Allowance'
import usePrevious from 'hooks/usePrevious' import usePrevious from 'hooks/usePrevious'
import { SwapResult, useSwapCallback } from 'hooks/useSwapCallback' import { SwapResult, useSwapCallback } from 'hooks/useSwapCallback'
import { useSwitchChain } from 'hooks/useSwitchChain'
import { useUSDPrice } from 'hooks/useUSDPrice' import { useUSDPrice } from 'hooks/useUSDPrice'
import useWrapCallback, { WrapErrorText, WrapType } from 'hooks/useWrapCallback' import useWrapCallback, { WrapErrorText, WrapType } from 'hooks/useWrapCallback'
import { Trans } from 'i18n' import { Trans } from 'i18n'
...@@ -42,12 +40,7 @@ import { Text } from 'rebass' ...@@ -42,12 +40,7 @@ import { Text } from 'rebass'
import { useAppSelector } from 'state/hooks' import { useAppSelector } from 'state/hooks'
import { InterfaceTrade, RouterPreference, TradeState } from 'state/routing/types' import { InterfaceTrade, RouterPreference, TradeState } from 'state/routing/types'
import { isClassicTrade } from 'state/routing/utils' import { isClassicTrade } from 'state/routing/utils'
import { import { useSwapActionHandlers, useSwapAndLimitContext, useSwapContext } from 'state/swap/hooks'
queryParametersToCurrencyState,
useSwapActionHandlers,
useSwapAndLimitContext,
useSwapContext,
} from 'state/swap/hooks'
import { useTheme } from 'styled-components' import { useTheme } from 'styled-components'
import { ExternalLink, ThemedText } from 'theme/components' import { ExternalLink, ThemedText } from 'theme/components'
import { maybeLogFirstSwapAction } from 'tracing/swapFlowLoggers' import { maybeLogFirstSwapAction } from 'tracing/swapFlowLoggers'
...@@ -61,6 +54,7 @@ import { didUserReject } from 'utils/swapErrorToUserReadableMessage' ...@@ -61,6 +54,7 @@ import { didUserReject } from 'utils/swapErrorToUserReadableMessage'
import Error from 'components/Icons/Error' import Error from 'components/Icons/Error'
import Row from 'components/Row' import Row from 'components/Row'
import { useCurrencyInfo } from 'hooks/Tokens' import { useCurrencyInfo } from 'hooks/Tokens'
import useSelectChain from 'hooks/useSelectChain'
import { CurrencyState } from 'state/swap/types' import { CurrencyState } from 'state/swap/types'
import { SafetyLevel } from 'uniswap/src/data/graphql/uniswap-data-api/__generated__/types-and-hooks' import { SafetyLevel } from 'uniswap/src/data/graphql/uniswap-data-api/__generated__/types-and-hooks'
import { CurrencyInfo } from 'uniswap/src/features/dataApi/types' import { CurrencyInfo } from 'uniswap/src/features/dataApi/types'
...@@ -88,14 +82,8 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF ...@@ -88,14 +82,8 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF
const { typedValue, independentField } = swapState const { typedValue, independentField } = swapState
// token warning stuff // token warning stuff
const parsedQs = useParsedQueryString() const prefilledInputCurrencyInfo = useCurrencyInfo(prefilledState.inputCurrency)
const prefilledCurrencies = useMemo(() => { const prefilledOutputCurrencyInfo = useCurrencyInfo(prefilledState.outputCurrency)
return queryParametersToCurrencyState(parsedQs)
}, [parsedQs])
const prefilledInputCurrencyInfo = useCurrencyInfo(prefilledCurrencies?.inputCurrencyId, chainId)
const prefilledOutputCurrencyInfo = useCurrencyInfo(prefilledCurrencies?.outputCurrencyId, chainId)
const [dismissTokenWarning, setDismissTokenWarning] = useState<boolean>(false) const [dismissTokenWarning, setDismissTokenWarning] = useState<boolean>(false)
const [showPriceImpactModal, setShowPriceImpactModal] = useState<boolean>(false) const [showPriceImpactModal, setShowPriceImpactModal] = useState<boolean>(false)
...@@ -463,7 +451,8 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF ...@@ -463,7 +451,8 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF
) )
const inputCurrency = currencies[Field.INPUT] ?? undefined const inputCurrency = currencies[Field.INPUT] ?? undefined
const switchChain = useSwitchChain() const selectChain = useSelectChain()
const switchingChain = useAppSelector((state) => state.wallets.switchingChain) const switchingChain = useAppSelector((state) => state.wallets.switchingChain)
const targetChain = switchingChain ? switchingChain : undefined const targetChain = switchingChain ? switchingChain : undefined
const switchingChainIsSupported = useIsSupportedChainId(targetChain) const switchingChainIsSupported = useIsSupportedChainId(targetChain)
...@@ -474,8 +463,8 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF ...@@ -474,8 +463,8 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF
<> <>
<TokenSafetyModal <TokenSafetyModal
isOpen={urlTokensNotInDefault.length > 0 && !dismissTokenWarning} isOpen={urlTokensNotInDefault.length > 0 && !dismissTokenWarning}
tokenAddress={urlTokensNotInDefault[0]?.address} token0={urlTokensNotInDefault[0]}
secondTokenAddress={urlTokensNotInDefault[1]?.address} token1={urlTokensNotInDefault[1]}
onContinue={handleConfirmTokenWarning} onContinue={handleConfirmTokenWarning}
onCancel={handleDismissTokenWarning} onCancel={handleDismissTokenWarning}
showCancel={true} showCancel={true}
...@@ -624,7 +613,7 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF ...@@ -624,7 +613,7 @@ export function SwapForm({ disableTokenInputs = false, onCurrencyChange }: SwapF
$borderRadius="16px" $borderRadius="16px"
onClick={async () => { onClick={async () => {
try { try {
await switchChain(chainId) await selectChain(chainId)
} catch (error) { } catch (error) {
if (didUserReject(error)) { if (didUserReject(error)) {
// Ignore error, which keeps the user on the previous chain. // Ignore error, which keeps the user on the previous chain.
......
...@@ -7,19 +7,16 @@ import SwapHeader from 'components/swap/SwapHeader' ...@@ -7,19 +7,16 @@ import SwapHeader from 'components/swap/SwapHeader'
import { SwapTab } from 'components/swap/constants' import { SwapTab } from 'components/swap/constants'
import { PageWrapper, SwapWrapper } from 'components/swap/styled' import { PageWrapper, SwapWrapper } from 'components/swap/styled'
import { useSupportedChainId } from 'constants/chains' import { useSupportedChainId } from 'constants/chains'
import { useCurrency } from 'hooks/Tokens'
import useParsedQueryString from 'hooks/useParsedQueryString'
import { useScreenSize } from 'hooks/useScreenSize' import { useScreenSize } from 'hooks/useScreenSize'
import { SendForm } from 'pages/Swap/Send/SendForm' import { SendForm } from 'pages/Swap/Send/SendForm'
import { ReactNode, useMemo } from 'react' import { ReactNode } from 'react'
import { useLocation } from 'react-router-dom' import { useLocation } from 'react-router-dom'
import { InterfaceTrade, TradeState } from 'state/routing/types' import { InterfaceTrade, TradeState } from 'state/routing/types'
import { isPreviewTrade } from 'state/routing/utils' import { isPreviewTrade } from 'state/routing/utils'
import { SwapAndLimitContextProvider, SwapContextProvider } from 'state/swap/SwapContext' import { SwapAndLimitContextProvider, SwapContextProvider } from 'state/swap/SwapContext'
import { queryParametersToCurrencyState } from 'state/swap/hooks' import { useInitialCurrencyState } from 'state/swap/hooks'
import { CurrencyState, SwapAndLimitContext } from 'state/swap/types' import { CurrencyState, SwapAndLimitContext } from 'state/swap/types'
import { useChainId } from 'wagmi' import { useChainId } from 'wagmi'
import { useIsDarkMode } from '../../theme/components/ThemeToggle' import { useIsDarkMode } from '../../theme/components/ThemeToggle'
import { LimitFormWrapper } from './Limit/LimitForm' import { LimitFormWrapper } from './Limit/LimitForm'
import { SwapForm } from './SwapForm' import { SwapForm } from './SwapForm'
...@@ -39,16 +36,8 @@ export function getIsReviewableQuote( ...@@ -39,16 +36,8 @@ export function getIsReviewableQuote(
export default function SwapPage({ className }: { className?: string }) { export default function SwapPage({ className }: { className?: string }) {
const location = useLocation() const location = useLocation()
const supportedChainId = useSupportedChainId(useChainId()) const { initialInputCurrency, initialOutputCurrency, chainId } = useInitialCurrencyState()
const chainId = supportedChainId || ChainId.MAINNET const shouldDisableTokenInputs = useSupportedChainId(useChainId()) === undefined
const parsedQs = useParsedQueryString()
const parsedCurrencyState = useMemo(() => {
return queryParametersToCurrencyState(parsedQs)
}, [parsedQs])
const initialInputCurrency = useCurrency(parsedCurrencyState.inputCurrencyId, chainId)
const initialOutputCurrency = useCurrency(parsedCurrencyState.outputCurrencyId, chainId)
return ( return (
<Trace page={InterfacePageName.SWAP_PAGE} shouldLogImpression> <Trace page={InterfacePageName.SWAP_PAGE} shouldLogImpression>
...@@ -56,7 +45,7 @@ export default function SwapPage({ className }: { className?: string }) { ...@@ -56,7 +45,7 @@ export default function SwapPage({ className }: { className?: string }) {
<Swap <Swap
className={className} className={className}
chainId={chainId} chainId={chainId}
disableTokenInputs={supportedChainId === undefined} disableTokenInputs={shouldDisableTokenInputs}
initialInputCurrency={initialInputCurrency} initialInputCurrency={initialInputCurrency}
initialOutputCurrency={initialOutputCurrency} initialOutputCurrency={initialOutputCurrency}
syncTabToUrl={true} syncTabToUrl={true}
......
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { Field } from 'components/swap/constants' import { Field } from 'components/swap/constants'
import useAutoSlippageTolerance from 'hooks/useAutoSlippageTolerance' import useAutoSlippageTolerance from 'hooks/useAutoSlippageTolerance'
...@@ -13,9 +13,13 @@ import { isClassicTrade, isSubmittableTrade, isUniswapXTrade } from 'state/routi ...@@ -13,9 +13,13 @@ import { isClassicTrade, isSubmittableTrade, isUniswapXTrade } from 'state/routi
import { useUserSlippageToleranceWithDefault } from 'state/user/hooks' import { useUserSlippageToleranceWithDefault } from 'state/user/hooks'
import { isAddress } from 'utilities/src/addresses' import { isAddress } from 'utilities/src/addresses'
import { useSupportedChainId } from 'constants/chains'
import { useCurrency } from 'hooks/Tokens'
import useParsedQueryString from 'hooks/useParsedQueryString'
import { getParsedChainId } from 'hooks/useSyncChainQuery'
import useNativeCurrency from 'lib/hooks/useNativeCurrency' import useNativeCurrency from 'lib/hooks/useNativeCurrency'
import { InterfaceTrade, RouterPreference, TradeState } from 'state/routing/types' import { InterfaceTrade, RouterPreference, TradeState } from 'state/routing/types'
import { useAccount } from 'wagmi' import { useAccount, useChainId } from 'wagmi'
import { useCurrencyBalance, useCurrencyBalances } from '../connection/hooks' import { useCurrencyBalance, useCurrencyBalances } from '../connection/hooks'
import { import {
CurrencyState, CurrencyState,
...@@ -280,6 +284,7 @@ export function queryParametersToCurrencyState(parsedQs: ParsedQs): SerializedCu ...@@ -280,6 +284,7 @@ export function queryParametersToCurrencyState(parsedQs: ParsedQs): SerializedCu
let inputCurrency = parseCurrencyFromURLParameter(parsedQs.inputCurrency ?? parsedQs.inputcurrency) let inputCurrency = parseCurrencyFromURLParameter(parsedQs.inputCurrency ?? parsedQs.inputcurrency)
let outputCurrency = parseCurrencyFromURLParameter(parsedQs.outputCurrency ?? parsedQs.outputcurrency) let outputCurrency = parseCurrencyFromURLParameter(parsedQs.outputCurrency ?? parsedQs.outputcurrency)
const independentField = parseIndependentFieldURLParameter(parsedQs.exactField) const independentField = parseIndependentFieldURLParameter(parsedQs.exactField)
const chainId = getParsedChainId(parsedQs)
if (inputCurrency === '' && outputCurrency === '' && independentField === Field.INPUT) { if (inputCurrency === '' && outputCurrency === '' && independentField === Field.INPUT) {
// Defaults to having the native currency selected // Defaults to having the native currency selected
...@@ -292,5 +297,25 @@ export function queryParametersToCurrencyState(parsedQs: ParsedQs): SerializedCu ...@@ -292,5 +297,25 @@ export function queryParametersToCurrencyState(parsedQs: ParsedQs): SerializedCu
return { return {
inputCurrencyId: inputCurrency === '' ? undefined : inputCurrency ?? undefined, inputCurrencyId: inputCurrency === '' ? undefined : inputCurrency ?? undefined,
outputCurrencyId: outputCurrency === '' ? undefined : outputCurrency ?? undefined, outputCurrencyId: outputCurrency === '' ? undefined : outputCurrency ?? undefined,
chainId,
} }
} }
export function useInitialCurrencyState(): {
initialInputCurrency?: Currency
initialOutputCurrency?: Currency
chainId: ChainId
} {
const parsedQs = useParsedQueryString()
const parsedCurrencyState = useMemo(() => {
return queryParametersToCurrencyState(parsedQs)
}, [parsedQs])
const connectedChainId = useChainId()
const chainId = useSupportedChainId(parsedCurrencyState.chainId ?? connectedChainId) ?? ChainId.MAINNET
const initialInputCurrency = useCurrency(parsedCurrencyState.inputCurrencyId, chainId)
const initialOutputCurrency = useCurrency(parsedCurrencyState.outputCurrencyId, chainId)
return { initialInputCurrency, initialOutputCurrency, chainId }
}
...@@ -100,6 +100,7 @@ export const SwapAndLimitContext = createContext<SwapAndLimitContextType>({ ...@@ -100,6 +100,7 @@ export const SwapAndLimitContext = createContext<SwapAndLimitContextType>({
export interface SerializedCurrencyState { export interface SerializedCurrencyState {
inputCurrencyId?: string inputCurrencyId?: string
outputCurrencyId?: string outputCurrencyId?: string
chainId?: number
} }
// shared state between Swap and Limit // shared state between Swap and Limit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment