diff --git a/src/navigator/types.tsx b/src/navigator/types.tsx index 180e36148d6..3b10f6a0c32 100644 --- a/src/navigator/types.tsx +++ b/src/navigator/types.tsx @@ -283,7 +283,12 @@ export type StackParamList = { prefilledText: string } | undefined - [Screens.SwapScreenWithBack]: { fromTokenId: string } | undefined + [Screens.SwapScreenWithBack]: + | { + fromTokenId?: string + toTokenId?: string + } + | undefined [Screens.TabDiscover]: { isTabNavigator?: boolean } | undefined [Screens.TabHome]: { isTabNavigator?: boolean } | undefined [Screens.TabWallet]: { activeAssetTab?: AssetTabType; isWalletTab?: boolean } | undefined diff --git a/src/swap/SwapScreen.tsx b/src/swap/SwapScreen.tsx index 6320ad3d4ca..c3ccdae6612 100644 --- a/src/swap/SwapScreen.tsx +++ b/src/swap/SwapScreen.tsx @@ -84,10 +84,10 @@ interface SwapState { switchedToNetworkId: NetworkId | null } -function getInitialState(fromTokenId?: string): SwapState { +function getInitialState(fromTokenId?: string, toTokenId?: string): SwapState { return { fromTokenId, - toTokenId: undefined, + toTokenId, inputSwapAmount: DEFAULT_INPUT_SWAP_AMOUNT, updatedField: Field.FROM, selectingField: null, @@ -253,7 +253,11 @@ export function SwapScreen({ route }: Props) { ) const initialFromTokenId = route.params?.fromTokenId - const [state, localDispatch] = useReducer(swapStateReducer, getInitialState(initialFromTokenId)) + const initialToTokenId = route.params?.toTokenId + const [state, localDispatch] = useReducer( + swapStateReducer, + getInitialState(initialFromTokenId, initialToTokenId) + ) const { fromTokenId, toTokenId,