Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support deep link swap pairs and to tokenId #5216

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/navigator/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/swap/SwapScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading