Skip to content

Commit a74cee9

Browse files
fix: switch to sell order if wallet changed from safe to EOA
1 parent 88ab93e commit a74cee9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apps/cowswap-frontend/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"executor": "@nx/vite:dev-server",
3636
"defaultConfiguration": "development",
3737
"options": {
38-
"buildTarget": "cowswap-frontend:build"
38+
"buildTarget": "cowswap-frontend:build",
39+
"host": true
3940
},
4041
"configurations": {
4142
"dev": {

apps/cowswap-frontend/src/modules/swap/containers/SwapWidget/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import { useHooksEnabledManager } from 'legacy/state/user/hooks'
1212
import { useTryFindIntermediateToken } from 'modules/bridge'
1313
import { TradeApproveWithAffectedOrderList } from 'modules/erc20Approve'
1414
import { EthFlowModal, EthFlowProps } from 'modules/ethFlow'
15+
import { SELL_ETH_RESET_STATE } from 'modules/swap/consts'
1516
import { AddIntermediateTokenModal } from 'modules/tokensList'
1617
import {
1718
TradeWidget,
1819
TradeWidgetSlots,
1920
useGetReceiveAmountInfo,
21+
useIsEoaEthFlow,
2022
useTradePriceImpact,
2123
useWrapNativeFlow,
2224
} from 'modules/trade'
@@ -97,12 +99,19 @@ export function SwapWidget({ topContent, bottomContent }: SwapWidgetProps): Reac
9799
const [isHydrated, setIsHydrated] = useState(false)
98100
const handleUnlock = useCallback(() => updateSwapState({ isUnlocked: true }), [updateSwapState])
99101
const isPrimaryValidationPassed = useIsTradeFormValidationPassed()
102+
const isEoaEthFlow = useIsEoaEthFlow()
100103

101104
useEffect(() => {
102105
// Hydration guard: defer lock-screen until persisted state (isUnlocked) loads to prevent initial flash.
103106
setIsHydrated(true)
104107
}, [])
105108

109+
useEffect(() => {
110+
if (isEoaEthFlow && !isSellOrder(orderKind)) {
111+
updateSwapState(SELL_ETH_RESET_STATE)
112+
}
113+
}, [isEoaEthFlow, orderKind, updateSwapState])
114+
106115
const isSellTrade = isSellOrder(orderKind)
107116

108117
const ethFlowProps: EthFlowProps = useSafeMemoObject({

0 commit comments

Comments
 (0)