Skip to content

Commit

Permalink
feat: use shouldUseCrossChainProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Feb 28, 2024
1 parent 58b3860 commit 19ca1f3
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> | 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 (
<>
Expand Down Expand Up @@ -452,7 +444,8 @@ export const BuyWithCryptoModal = (props: Props) => {
isFetchingBalance,
isLoading,
onBuyNatively,
handleCrossChainBuy
handleCrossChainBuy,
shouldUseCrossChainProvider
])

const renderMainActionButton = useCallback(() => {
Expand Down

0 comments on commit 19ca1f3

Please sign in to comment.