@@ -7,9 +7,12 @@ import { getBridgeCommonInfo } from '@/src/hooks/bridge/utils/getBridgeCommonInf
77import { Chains , ChainsValues } from '@/src/constants/config/types'
88import { useBridgeFee } from '@/src/hooks/bridge/useBridgeFee'
99import { formatUnits } from 'ethers/lib/utils'
10- import { ReceiveNativeTokenSwitcher } from '@/src/pagePartials/bridge/bridgeForm/ReceiveNativeTokenSwitcher '
10+ import { ReceiveTokenSwitcher } from '@/src/pagePartials/bridge/bridgeForm/ReceiveTokenSwitcher '
1111import { chainsConfig } from '@/src/constants/config/chains'
1212import { genericSuspense } from '@/src/components/safeSuspense'
13+ import { NATIVE_TOKEN_ADDRESS } from '@/src/constants/config/common'
14+ import { isSameString } from '@/src/utils/tools'
15+ import React , { useState } from 'react'
1316
1417const NoTokenSelected = styled . span `
1518 font-size: 1.5rem;
@@ -41,6 +44,19 @@ const wethOptions = [
4144 } ,
4245]
4346
47+ const xdaiOptions = [
48+ {
49+ icon : '/images/icons/dai.svg' ,
50+ label : 'DAI' ,
51+ name : 'xdai-types' ,
52+ } ,
53+ {
54+ icon : '/images/icons/usds.webp' ,
55+ label : 'USDS' ,
56+ name : 'xdai-types' ,
57+ } ,
58+ ]
59+
4460export const NoTokenOut : React . FC < { loading ?: boolean } > = ( { loading } ) => (
4561 < >
4662 < SkeletonLoading
@@ -61,6 +77,7 @@ export const TokenOut: React.FC<{
6177 amount : BigNumber
6278 fromChainId : ChainsValues
6379 setReceiveNativeToken : ( receiveNative : boolean ) => void
80+ setReceiveUsds : ( receiveUsds : boolean ) => void
6481 toChainId : ChainsValues
6582 token : Token
6683 tokenOut : Token
@@ -69,6 +86,7 @@ export const TokenOut: React.FC<{
6986 amount,
7087 fromChainId,
7188 setReceiveNativeToken : onReceiveNativeChange ,
89+ setReceiveUsds : onReceiveUsdsChange ,
7290 toChainId,
7391 token,
7492 tokenOut,
@@ -90,18 +108,37 @@ export const TokenOut: React.FC<{
90108 fromChainId == Chains . gnosis &&
91109 token . address == chainsConfig [ Chains . gnosis ] . bridge . wForeignNative
92110
111+ const showXDaiSwitcher =
112+ fromChainId === Chains . gnosis && isSameString ( token . address , NATIVE_TOKEN_ADDRESS )
113+
114+ // Add state for selected option
115+ const [ selectedNativeToken , setSelectedNativeToken ] = useState ( wethOptions [ 0 ] . label )
116+ const [ selectedXDaiToken , setSelectedXDaiToken ] = useState ( xdaiOptions [ 0 ] . label )
117+
93118 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
94119 const tokenOutAmount = formatUnits ( amount . sub ( feeInfo ! ) , tokenOut ?. decimals )
95120
96121 return (
97122 < >
98123 { showNativeTokenSwitcher ? (
99- < ReceiveNativeTokenSwitcher
100- onChange = { ( event : React . ChangeEvent < HTMLInputElement > ) =>
124+ < ReceiveTokenSwitcher
125+ onChange = { ( event : React . ChangeEvent < HTMLInputElement > ) => {
126+ setSelectedNativeToken ( event . target . value )
101127 onReceiveNativeChange ( event . target . value === 'ETH' )
102- }
128+ } }
103129 options = { wethOptions }
104130 optionsId = "ethOptions"
131+ value = { selectedNativeToken }
132+ />
133+ ) : showXDaiSwitcher ? (
134+ < ReceiveTokenSwitcher
135+ onChange = { ( event : React . ChangeEvent < HTMLInputElement > ) => {
136+ setSelectedXDaiToken ( event . target . value )
137+ onReceiveUsdsChange ( event . target . value === 'USDS' )
138+ } }
139+ options = { xdaiOptions }
140+ optionsId = "xdaiOptions"
141+ value = { selectedXDaiToken }
105142 />
106143 ) : (
107144 < >
0 commit comments