From a4ff192799944beecb75c9b294989f72b0a3faf5 Mon Sep 17 00:00:00 2001 From: Alexander Kolberg Date: Tue, 2 Dec 2025 23:48:42 +0200 Subject: [PATCH 1/2] skip balance and swap route queries for free items --- .../PayWithCrypto/useInitialBalanceCheck.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/useInitialBalanceCheck.tsx b/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/useInitialBalanceCheck.tsx index 792d8cde1..321635db2 100644 --- a/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/useInitialBalanceCheck.tsx +++ b/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/useInitialBalanceCheck.tsx @@ -26,6 +26,7 @@ export const useInitialBalanceCheck = ({ isInsufficientBalance, tokenBalancesIsLoading }: UseInitialBalanceCheckArgs) => { + const isFree = BigInt(price) === 0n const { navigation, setNavigation } = useNavigationCheckout() const isInitialBalanceChecked = (navigation.params as PaymentMethodSelectionParams).isInitialBalanceChecked @@ -42,7 +43,7 @@ export const useInitialBalanceCheck = ({ chainId: chainId }, { - disabled: isInitialBalanceChecked || !isInsufficientBalance + disabled: isInitialBalanceChecked || !isInsufficientBalance || isFree } ) @@ -65,7 +66,7 @@ export const useInitialBalanceCheck = ({ omitMetadata: true }, { - disabled: isInitialBalanceChecked || !isInsufficientBalance || swapRoutesIsLoading + disabled: isInitialBalanceChecked || !isInsufficientBalance || swapRoutesIsLoading || isFree } ) From 416b7dd11e4bc3e8a51ce150ae0caa7b43280c1c Mon Sep 17 00:00:00 2001 From: Alexander Kolberg Date: Tue, 2 Dec 2025 23:48:59 +0200 Subject: [PATCH 2/2] fix insufficient balance check to skip validation for free items --- .../PaymentMethodSelect/PayWithCrypto/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/index.tsx b/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/index.tsx index a590ba254..0952a3e21 100644 --- a/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/index.tsx +++ b/packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/index.tsx @@ -80,7 +80,7 @@ export const PayWithCryptoTab = ({ skipOnCloseCallback, isSwitchingChainRef }: P onSuccessChecker } = selectPaymentSettings - const isFree = Number(price) == 0 + const isFree = BigInt(price) === 0n const network = findSupportedNetwork(chain) const chainId = network?.chainId || 137 @@ -204,16 +204,16 @@ export const PayWithCryptoTab = ({ skipOnCloseCallback, isSwitchingChainRef }: P compareAddress(balance.contractAddress, selectedCurrency.address) ) - const isInsufficientBalance = - tokenBalance === undefined || - (tokenBalance?.balance && tokenBalance.balance !== '' && BigInt(tokenBalance.balance) < BigInt(selectedCurrencyPrice)) + const userBalance = BigInt(tokenBalance?.balance || '0') + const requiredBalance = BigInt(selectedCurrencyPrice) + const isInsufficientBalance = !isFree && userBalance < requiredBalance useInitialBalanceCheck({ userAddress: userAddress || '', buyCurrencyAddress, price, chainId, - isInsufficientBalance: isInsufficientBalance as boolean, + isInsufficientBalance, tokenBalancesIsLoading })