Skip to content

Commit dc8e273

Browse files
Attempt to fix swap from native (#515)
1 parent 9a9f6f4 commit dc8e273

File tree

1 file changed

+5
-3
lines changed
  • packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto

1 file changed

+5
-3
lines changed

packages/checkout/src/views/Checkout/PaymentMethodSelect/PayWithCrypto/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export const PayWithCryptoTab = ({ skipOnCloseCallback, isSwitchingChainRef }: P
8181
chainId: chain
8282
}
8383

84+
// Check if the target currency (what the item is priced in) is native
8485
const isNativeToken = compareAddress(currencyAddress, zeroAddress)
86+
// Check if the selected currency (what the user is paying with) is native
8587
const isNativeTokenSelectedCurrency = compareAddress(selectedCurrency.address, zeroAddress)
8688

8789
const { data: tokenBalancesData, isLoading: tokenBalancesIsLoading } = useGetTokenBalancesSummary({
@@ -163,14 +165,14 @@ export const PayWithCryptoTab = ({ skipOnCloseCallback, isSwitchingChainRef }: P
163165
address: currencyAddress as Hex,
164166
args: [userAddress, approvedSpenderAddress || targetContractAddress],
165167
query: {
166-
enabled: !!userAddress && !isNativeTokenSelectedCurrency
168+
enabled: !!userAddress && !isNativeToken
167169
}
168170
})
169171

170172
const isLoading =
171173
isLoadingCoinPrice ||
172174
isLoadingCurrencyInfo ||
173-
(allowanceIsLoading && !isNativeTokenSelectedCurrency) ||
175+
(allowanceIsLoading && !isNativeToken) ||
174176
isLoadingSwapQuote ||
175177
tokenBalancesIsLoading ||
176178
isLoadingSelectedCurrencyInfo
@@ -352,7 +354,7 @@ export const PayWithCryptoTab = ({ skipOnCloseCallback, isSwitchingChainRef }: P
352354
: {})
353355
},
354356
// Actual transaction optional approve step
355-
...(isApproved || isNativeTokenSelectedCurrency
357+
...(isApproved || isNativeToken
356358
? []
357359
: [
358360
{

0 commit comments

Comments
 (0)