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: relax the last mile check for ethflow and improve message #5409

Merged
merged 1 commit into from
Feb 7, 2025
Merged
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
13 changes: 11 additions & 2 deletions apps/cowswap-frontend/src/modules/swap/services/ethFlow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,17 @@ export async function ethFlow(
throw new Error('Quote expired. Please refresh.')
}

if (contract.address !== getEthFlowContractAddresses(ethFlowEnv, useNewEthFlowContracts, chainId)) {
throw new Error('EthFlow contract address mismatch. Please refresh the page and try again.')
// Last check before signing the order of the actual eth flow contract address (sending ETH to the wrong contract could lead to loss of funds)
const actualContractAddress = contract.address.toLowerCase()
const expectedContractAddress = getEthFlowContractAddresses(
ethFlowEnv,
useNewEthFlowContracts,
chainId,
).toLowerCase()
if (actualContractAddress !== expectedContractAddress) {
throw new Error(
`EthFlow contract (${actualContractAddress}) address don't match the expected address for chain ${chainId} (${expectedContractAddress}). Please refresh the page and try again.`,
)
}

logTradeFlow('ETH FLOW', 'STEP 4: sign order')
Expand Down
Loading