Commit 2b85852a authored by eddie's avatar eddie Committed by GitHub

fix: fail UR transaction if chain IDs don't match (#7150)

* fix: verify UR deployed

* fix: dont fallback to 1

* fix: dont instantiate contract

* fix: use chainId instead

* fix: compare chainIds
parent 94015b27
......@@ -58,6 +58,8 @@ export function useUniversalRouterSwapCallback(
if (!chainId) throw new Error('missing chainId')
if (!provider) throw new Error('missing provider')
if (!trade) throw new Error('missing trade')
const connectedChainId = await provider.getSigner().getChainId()
if (chainId !== connectedChainId) throw new Error('signer chainId does not match')
setTraceData('slippageTolerance', options.slippageTolerance.toFixed(2))
const { calldata: data, value } = SwapRouter.swapERC20CallParameters(trade, {
......@@ -66,6 +68,7 @@ export function useUniversalRouterSwapCallback(
inputTokenPermit: options.permit,
fee: options.feeOptions,
})
const tx = {
from: account,
to: UNIVERSAL_ROUTER_ADDRESS(chainId),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment