Skip to content

Commit

Permalink
fix: display error when unable to fetch transaction fee
Browse files Browse the repository at this point in the history
  • Loading branch information
josheleonard committed Jan 17, 2024
1 parent 0b8c9ae commit 27cf88c
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions components/brave_wallet_ui/common/hooks/use-pending-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getPriceIdForToken } from '../../utils/api-utils'
import { isHardwareAccount } from '../../utils/account-utils'
import { getLocale } from '../../../common/locale'
import { getCoinFromTxDataUnion } from '../../utils/network-utils'
import { UISelectors, WalletSelectors } from '../selectors'
import { UISelectors } from '../selectors'
import {
accountHasInsufficientFundsForGas,
accountHasInsufficientFundsForTransaction,
Expand All @@ -35,7 +35,7 @@ import { makeNetworkAsset } from '../../options/asset-options'
import useTokenInfo from './token'
import { useLib } from './useLib'
import { useAccountOrb, useAddressOrb } from './use-orb'
import { useSafeUISelector, useSafeWalletSelector } from './use-safe-selector'
import { useSafeUISelector } from './use-safe-selector'
import {
useGetAccountInfosRegistryQuery,
useGetAccountTokenCurrentBalanceQuery,
Expand Down Expand Up @@ -94,9 +94,6 @@ export const usePendingTransactions = () => {
const selectedPendingTransactionId = useSafeUISelector(
UISelectors.selectedPendingTransactionId
)
const hasFeeEstimatesError = useSafeWalletSelector(
WalletSelectors.hasFeeEstimatesError
)

// queries
const { data: defaultFiat } = useGetDefaultFiatCurrencyQuery()
Expand Down Expand Up @@ -153,18 +150,22 @@ export const usePendingTransactions = () => {
querySubscriptionOptions60s
)

const { data: gasEstimates, isLoading: isLoadingGasEstimates } =
useGetGasEstimation1559Query(
transactionInfo && txCoinType === BraveWallet.CoinType.ETH
? transactionInfo.chainId
: skipToken,
defaultQuerySubscriptionOptions
)
const {
data: gasEstimates,
isLoading: isLoadingGasEstimates,
isError: hasEvmFeeEstimatesError
} = useGetGasEstimation1559Query(
transactionInfo && txCoinType === BraveWallet.CoinType.ETH
? transactionInfo.chainId
: skipToken,
defaultQuerySubscriptionOptions
)

const {
data: solFeeEstimate,
isLoading: isLoadingSolFeeEstimates = txCoinType ===
BraveWallet.CoinType.SOL
BraveWallet.CoinType.SOL,
isError: hasSolFeeEstimatesError
} = useGetSolanaEstimatedFeeQuery(
txCoinType === BraveWallet.CoinType.SOL &&
transactionInfo?.chainId &&
Expand Down Expand Up @@ -503,6 +504,11 @@ export const usePendingTransactions = () => {
isLoadingGasEstimates
])

const hasFeeEstimatesError =
txCoinType === BraveWallet.CoinType.SOL
? hasSolFeeEstimatesError
: hasEvmFeeEstimatesError

const isConfirmButtonDisabled = React.useMemo(() => {
if (hasFeeEstimatesError || isLoadingGasFee) {
return true
Expand Down

0 comments on commit 27cf88c

Please sign in to comment.