Skip to content

Commit eea585d

Browse files
committed
fix same token bridge
1 parent aca32eb commit eea585d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

widget/src/util/enso.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ import { formatNumber, normalizeValue } from ".";
2929

3030
let ensoClient: EnsoClient | null = null;
3131

32+
type CrosschainParams = RouteParams & {
33+
destinationChainId?: number;
34+
};
35+
3236
export const setApiKey = (apiKey: string) => {
3337
ensoClient = new EnsoClient({
3438
// baseURL: "http://localhost:3000/api/v1",
@@ -265,11 +269,12 @@ const useBridgeBundle = (
265269
};
266270
};
267271

268-
const useEnsoRouterData = (params: RouteParams, enabled = true) =>
272+
const useEnsoRouterData = (params: CrosschainParams, enabled = true) =>
269273
useQuery({
270274
queryKey: [
271275
"enso-router",
272276
params.chainId,
277+
params.destinationChainId,
273278
params.fromAddress,
274279
params.tokenIn,
275280
params.tokenOut,
@@ -282,7 +287,9 @@ const useEnsoRouterData = (params: RouteParams, enabled = true) =>
282287
isAddress(params.fromAddress) &&
283288
isAddress(params.tokenIn) &&
284289
isAddress(params.tokenOut) &&
285-
params.tokenIn !== params.tokenOut,
290+
(params.tokenIn !== params.tokenOut ||
291+
(params.destinationChainId &&
292+
params.chainId !== params.destinationChainId)),
286293
retry: 2,
287294
});
288295

@@ -318,7 +325,7 @@ export const useEnsoData = (
318325
const { address = VITALIK_ADDRESS } = useAccount();
319326
const chainId = usePriorityChainId();
320327
const outChainId = useOutChainId();
321-
const routerParams: RouteParams = {
328+
const routerParams: CrosschainParams = {
322329
amountIn,
323330
tokenIn,
324331
tokenOut,
@@ -341,7 +348,6 @@ export const useEnsoData = (
341348
let isCrosschain = outChainId !== chainId;
342349

343350
if (isCrosschain) {
344-
// @ts-ignore
345351
routerParams.destinationChainId = outChainId;
346352
}
347353

0 commit comments

Comments
 (0)