From 19ca1f320d70e767f46d4360cc85a8b6208d57cc Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Wed, 28 Feb 2024 13:34:51 +0100 Subject: [PATCH] feat: use shouldUseCrossChainProvider --- .../BuyWithCryptoModal/BuyWithCryptoModal.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx b/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx index dd1ab2570..bbc55b0b8 100644 --- a/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx +++ b/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx @@ -404,17 +404,9 @@ export const BuyWithCryptoModal = (props: Props) => { const renderBuyNowButton = useCallback(() => { // if L1 asset and paying with ETH MANA // or if L2 asset and paying with MATIC MANA => native buy - let onClick: () => Promise | unknown = handleCrossChainBuy - if (selectedToken?.symbol === 'MANA') { - if ( - (asset.chainId === ChainId.ETHEREUM_MAINNET && - selectedChain === ChainId.ETHEREUM_MAINNET) || - (asset.chainId === ChainId.MATIC_MAINNET && - selectedChain === ChainId.MATIC_MAINNET) - ) { - onClick = onBuyNatively - } - } + const onClick = shouldUseCrossChainProvider + ? handleCrossChainBuy + : onBuyNatively return ( <> @@ -452,7 +444,8 @@ export const BuyWithCryptoModal = (props: Props) => { isFetchingBalance, isLoading, onBuyNatively, - handleCrossChainBuy + handleCrossChainBuy, + shouldUseCrossChainProvider ]) const renderMainActionButton = useCallback(() => {