Skip to content

Commit c17fbf3

Browse files
brunobar79ibrahimtaveras00
authored andcommitted
prevent quotes from the wrong type being passed to the wrong fn (#6436)
1 parent d3485bb commit c17fbf3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/raps/actions/crosschainSwap.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Signer } from '@ethersproject/abstract-signer';
2-
import { CrosschainQuote, fillCrosschainQuote } from '@rainbow-me/swaps';
2+
import { CrosschainQuote, fillCrosschainQuote, SwapType } from '@rainbow-me/swaps';
33
import { Address } from 'viem';
44
import { estimateGasWithPadding, getProvider, toHex } from '@/handlers/web3';
55
import { add } from '@/helpers/utilities';
@@ -155,7 +155,7 @@ export const executeCrosschainSwap = async ({
155155
wallet: Signer;
156156
referrer?: ReferrerType;
157157
}) => {
158-
if (!wallet || !quote) return null;
158+
if (!wallet || !quote || quote.swapType !== SwapType.crossChain) return null;
159159

160160
const transactionParams = {
161161
gasLimit: toHex(gasLimit) || undefined,

src/raps/actions/swap.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ export const executeSwap = async ({
290290
} else if (quote.swapType === SwapType.unwrap) {
291291
return unwrapNativeAsset(quote.sellAmount, wallet, getWrappedAssetAddress(quote), transactionParams);
292292
// Swap
293-
} else {
293+
} else if (quote.swapType === SwapType.normal) {
294294
return fillQuote(quote, transactionParams, wallet, permit, chainId as number, REFERRER);
295295
}
296+
return null;
296297
};
297298

298299
export const swap = async ({

0 commit comments

Comments
 (0)