Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: display error when transaction fee estimate fails (Uplift to 1.63.x) #21672

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/brave_wallet_ui/common/actions/wallet_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ export const {
removeUserAsset,
setAllTokensList,
setAssetAutoDiscoveryCompleted,
setGasEstimates,
setHasFeeEstimatesError,
selectOnRampAssetId,
setPasswordAttempts,
setSelectedAccountFilterItem,
setSelectedAssetFilterItem,
setSelectedGroupAssetsByItem,
setSelectedNetworkFilter,
setSolFeeEstimates,
setUserAssetVisible,
setVisibleTokensInfo,
unlocked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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'
// Custom Hooks
import useGetTokenInfo from './use-get-token-info'
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 @@ -96,9 +96,6 @@ export const usePendingTransactions = () => {
const selectedPendingTransactionId = useSafeUISelector(
UISelectors.selectedPendingTransactionId
)
const hasFeeEstimatesError = useSafeWalletSelector(
WalletSelectors.hasFeeEstimatesError
)

// mutations
const [rejectTransactions] = useRejectTransactionsMutation()
Expand Down Expand Up @@ -158,18 +155,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 @@ -519,6 +520,11 @@ export const usePendingTransactions = () => {
assertNotReached(`Unknown coin ${txCoinType}`)
}, [txCoinType, isLoadingSolFeeEstimates, gasFee, isLoadingGasEstimates])

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

const isConfirmButtonDisabled = React.useMemo(() => {
if (hasFeeEstimatesError || isLoadingGasFee) {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export const isWalletLocked = ({ wallet }: State) => wallet.isWalletLocked
export const passwordAttempts = ({ wallet }: State) => wallet.passwordAttempts
export const assetAutoDiscoveryCompleted = ({ wallet }: State) =>
wallet.assetAutoDiscoveryCompleted
export const hasFeeEstimatesError = ({ wallet }: State) =>
wallet.hasFeeEstimatesError
export const isNftPinningFeatureEnabled = ({ wallet }: State) =>
wallet.isNftPinningFeatureEnabled
export const hidePortfolioGraph = ({ wallet }: State) =>
Expand Down Expand Up @@ -48,14 +46,12 @@ export const allowedNewWalletAccountTypeNetworkIds = ({ wallet }: State) =>
// and lists)
export const activeOrigin = ({ wallet }: State) => wallet.activeOrigin
export const fullTokenList = ({ wallet }: State) => wallet.fullTokenList
export const gasEstimates = ({ wallet }: State) => wallet.gasEstimates
export const selectedAssetFilter = ({ wallet }: State) =>
wallet.selectedAssetFilter
export const selectedGroupAssetsByItem = ({ wallet }: State) =>
wallet.selectedGroupAssetsByItem
export const selectedNetworkFilter = ({ wallet }: State) =>
wallet.selectedNetworkFilter
export const solFeeEstimates = ({ wallet }: State) => wallet.solFeeEstimates
export const userVisibleTokensInfo = ({ wallet }: State) =>
wallet.userVisibleTokensInfo
export const selectedAccountFilter = ({ wallet }: State) =>
Expand Down
26 changes: 0 additions & 26 deletions components/brave_wallet_ui/common/slices/wallet.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
BraveWallet,
WalletState,
WalletInitializedPayload,
SolFeeEstimates,
NetworkFilterType,
RefreshOpts
} from '../../constants/types'
Expand Down Expand Up @@ -52,7 +51,6 @@ const defaultState: WalletState = {
eTldPlusOne: '',
originSpec: ''
},
gasEstimates: undefined,
selectedNetworkFilter: parseJSONFromLocalStorage(
'PORTFOLIO_NETWORK_FILTER_OPTION',
AllNetworksOptionDefault
Expand All @@ -65,7 +63,6 @@ const defaultState: WalletState = {
window.localStorage.getItem(LOCAL_STORAGE_KEYS.GROUP_PORTFOLIO_ASSETS_BY) ||
NoneGroupByOption.id,
selectedAccountFilter: AllAccountsOptionUniqueKey,
solFeeEstimates: undefined,
selectedDepositAssetId: undefined,
passwordAttempts: 0,
assetAutoDiscoveryCompleted: true,
Expand Down Expand Up @@ -213,14 +210,6 @@ export const createWalletSlice = (initialState: WalletState = defaultState) => {
state.selectedDepositAssetId = payload
},

setGasEstimates(
state: WalletState,
{ payload }: PayloadAction<BraveWallet.GasEstimation1559>
) {
state.hasFeeEstimatesError = false
state.gasEstimates = payload
},

setPasswordAttempts(
state: WalletState,
{ payload }: PayloadAction<number>
Expand Down Expand Up @@ -326,21 +315,6 @@ export const createWalletSlice = (initialState: WalletState = defaultState) => {
state.hidePortfolioNFTsTab = payload
},

setSolFeeEstimates(
state: WalletState,
{ payload }: PayloadAction<SolFeeEstimates>
) {
state.hasFeeEstimatesError = false
state.solFeeEstimates = payload
},

setHasFeeEstimatesError: (
state: WalletState,
{ payload }: PayloadAction<boolean>
) => {
state.hasFeeEstimatesError = payload
},

setVisibleTokensInfo: (
state: WalletState,
{ payload }: PayloadAction<BraveWallet.BlockchainToken[]>
Expand Down
7 changes: 0 additions & 7 deletions components/brave_wallet_ui/constants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ export interface ImportWalletError {
errorMessage?: string
}

export interface SolFeeEstimates {
fee: bigint
}

export interface TokenRegistry {
[chainID: string]: BraveWallet.BlockchainToken[]
}
Expand All @@ -206,9 +202,6 @@ export interface WalletState {
fullTokenList: BraveWallet.BlockchainToken[]
addUserAssetError: boolean
activeOrigin: BraveWallet.OriginInfo
solFeeEstimates?: SolFeeEstimates
hasFeeEstimatesError?: boolean
gasEstimates?: BraveWallet.GasEstimation1559
selectedNetworkFilter: NetworkFilterType
selectedAssetFilter: string
selectedGroupAssetsByItem: string
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { AllAccountsOptionUniqueKey } from '../../options/account-filter-options
import { AccountsGroupByOption } from '../../options/group-assets-by-options'

// mocks
import { LAMPORTS_PER_SOL } from '../../common/constants/solana'
import { mockMoonCatNFT, mockErc20TokensList } from './mock-asset-options'
import { networkEntityAdapter } from '../../common/slices/entities/network.entity'

Expand All @@ -25,14 +24,10 @@ export const mockWalletState: WalletState = {
},
addUserAssetError: false,
fullTokenList: mockErc20TokensList,
gasEstimates: undefined,
hasInitialized: true,
isBitcoinEnabled: false,
isZCashEnabled: false,
isAnkrBalancesFeatureEnabled: false,
solFeeEstimates: {
fee: (0.000005 * LAMPORTS_PER_SOL) as unknown as bigint
},
allowedNewWalletAccountTypeNetworkIds: [
networkEntityAdapter.selectId({
chainId: BraveWallet.FILECOIN_MAINNET,
Expand Down