diff --git a/src/components/Tokens/TokenDetails/index.tsx b/src/components/Tokens/TokenDetails/index.tsx index b4b798094c..ac4eb0e161 100644 --- a/src/components/Tokens/TokenDetails/index.tsx +++ b/src/components/Tokens/TokenDetails/index.tsx @@ -248,10 +248,8 @@ export default function TokenDetails({
diff --git a/src/pages/Swap/index.tsx b/src/pages/Swap/index.tsx index d0716b211e..bda2feb3c4 100644 --- a/src/pages/Swap/index.tsx +++ b/src/pages/Swap/index.tsx @@ -150,10 +150,8 @@ export default function SwapPage({ className }: { className?: string }) { @@ -172,13 +170,15 @@ export default function SwapPage({ className }: { className?: string }) { */ export function Swap({ className, - prefilledState = {}, + initialInputCurrencyId, + initialOutputCurrencyId, chainId, onCurrencyChange, disableTokenInputs = false, }: { className?: string - prefilledState?: Partial + initialInputCurrencyId?: string | null + initialOutputCurrencyId?: string | null chainId?: ChainId onCurrencyChange?: (selected: Pick) => void disableTokenInputs?: boolean @@ -187,8 +187,8 @@ export function Swap({ const trace = useTrace() // token warning stuff - const prefilledInputCurrency = useCurrency(prefilledState?.[Field.INPUT]?.currencyId) - const prefilledOutputCurrency = useCurrency(prefilledState?.[Field.OUTPUT]?.currencyId) + const prefilledInputCurrency = useCurrency(initialInputCurrencyId) + const prefilledOutputCurrency = useCurrency(initialOutputCurrencyId) const [loadedInputCurrency, setLoadedInputCurrency] = useState(prefilledInputCurrency) const [loadedOutputCurrency, setLoadedOutputCurrency] = useState(prefilledOutputCurrency) @@ -236,6 +236,13 @@ export function Swap({ const toggleWalletDrawer = useToggleAccountDrawer() // swap state + const prefilledState = useMemo( + () => ({ + [Field.INPUT]: { currencyId: initialInputCurrencyId }, + [Field.OUTPUT]: { currencyId: initialOutputCurrencyId }, + }), + [initialInputCurrencyId, initialOutputCurrencyId] + ) const [state, dispatch] = useReducer(swapReducer, { ...initialSwapState, ...prefilledState }) const { typedValue, recipient, independentField } = state