diff --git a/components/brave_wallet_ui/common/actions/wallet_actions.ts b/components/brave_wallet_ui/common/actions/wallet_actions.ts index 033c50020dae..f3f614464d5b 100644 --- a/components/brave_wallet_ui/common/actions/wallet_actions.ts +++ b/components/brave_wallet_ui/common/actions/wallet_actions.ts @@ -28,15 +28,12 @@ export const { removeUserAsset, setAllTokensList, setAssetAutoDiscoveryCompleted, - setGasEstimates, - setHasFeeEstimatesError, selectOnRampAssetId, setPasswordAttempts, setSelectedAccountFilterItem, setSelectedAssetFilterItem, setSelectedGroupAssetsByItem, setSelectedNetworkFilter, - setSolFeeEstimates, setUserAssetVisible, setVisibleTokensInfo, unlocked, diff --git a/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts b/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts index 7fe68edcab2c..2248f2fd6f8b 100644 --- a/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts +++ b/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts @@ -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, @@ -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, @@ -96,9 +96,6 @@ export const usePendingTransactions = () => { const selectedPendingTransactionId = useSafeUISelector( UISelectors.selectedPendingTransactionId ) - const hasFeeEstimatesError = useSafeWalletSelector( - WalletSelectors.hasFeeEstimatesError - ) // mutations const [rejectTransactions] = useRejectTransactionsMutation() @@ -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 && @@ -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 diff --git a/components/brave_wallet_ui/common/selectors/wallet-selectors.ts b/components/brave_wallet_ui/common/selectors/wallet-selectors.ts index 5127cf0efe38..018ad647da78 100644 --- a/components/brave_wallet_ui/common/selectors/wallet-selectors.ts +++ b/components/brave_wallet_ui/common/selectors/wallet-selectors.ts @@ -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) => @@ -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) => diff --git a/components/brave_wallet_ui/common/slices/wallet.slice.ts b/components/brave_wallet_ui/common/slices/wallet.slice.ts index 46b343770e66..baec1d37a84d 100644 --- a/components/brave_wallet_ui/common/slices/wallet.slice.ts +++ b/components/brave_wallet_ui/common/slices/wallet.slice.ts @@ -14,7 +14,6 @@ import { BraveWallet, WalletState, WalletInitializedPayload, - SolFeeEstimates, NetworkFilterType, RefreshOpts } from '../../constants/types' @@ -52,7 +51,6 @@ const defaultState: WalletState = { eTldPlusOne: '', originSpec: '' }, - gasEstimates: undefined, selectedNetworkFilter: parseJSONFromLocalStorage( 'PORTFOLIO_NETWORK_FILTER_OPTION', AllNetworksOptionDefault @@ -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, @@ -213,14 +210,6 @@ export const createWalletSlice = (initialState: WalletState = defaultState) => { state.selectedDepositAssetId = payload }, - setGasEstimates( - state: WalletState, - { payload }: PayloadAction - ) { - state.hasFeeEstimatesError = false - state.gasEstimates = payload - }, - setPasswordAttempts( state: WalletState, { payload }: PayloadAction @@ -326,21 +315,6 @@ export const createWalletSlice = (initialState: WalletState = defaultState) => { state.hidePortfolioNFTsTab = payload }, - setSolFeeEstimates( - state: WalletState, - { payload }: PayloadAction - ) { - state.hasFeeEstimatesError = false - state.solFeeEstimates = payload - }, - - setHasFeeEstimatesError: ( - state: WalletState, - { payload }: PayloadAction - ) => { - state.hasFeeEstimatesError = payload - }, - setVisibleTokensInfo: ( state: WalletState, { payload }: PayloadAction diff --git a/components/brave_wallet_ui/constants/types.ts b/components/brave_wallet_ui/constants/types.ts index 10e89d902bec..60dd040840c5 100644 --- a/components/brave_wallet_ui/constants/types.ts +++ b/components/brave_wallet_ui/constants/types.ts @@ -180,10 +180,6 @@ export interface ImportWalletError { errorMessage?: string } -export interface SolFeeEstimates { - fee: bigint -} - export interface TokenRegistry { [chainID: string]: BraveWallet.BlockchainToken[] } @@ -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 diff --git a/components/brave_wallet_ui/stories/mock-data/mock-parsed-transaction-info.ts b/components/brave_wallet_ui/stories/mock-data/mock-parsed-transaction-info.ts deleted file mode 100644 index 7e2f86a3b301..000000000000 --- a/components/brave_wallet_ui/stories/mock-data/mock-parsed-transaction-info.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2022 The Brave Authors. All rights reserved. -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this file, -// You can obtain one at https://mozilla.org/MPL/2.0/. - -// utils -import { getCoinFromTxDataUnion } from '../../utils/network-utils' -import { parseTransactionWithPrices } from '../../utils/tx-utils' - -// mocks -import { mockWalletState } from './mock-wallet-state' -import { - mockedErc20ApprovalTransaction, - mockTransactionInfo -} from './mock-transaction-info' -import { mockNetworks } from './mock-networks' - -export const mockParsedTransactionInfo = parseTransactionWithPrices({ - accounts: mockWalletState.accounts, - tokensList: [ - ...mockWalletState.userVisibleTokensInfo, - ...mockWalletState.fullTokenList - ], - spotPriceRegistry: {}, - tx: mockTransactionInfo, - gasFee: mockWalletState.solFeeEstimates?.fee.toString() ?? '', - transactionNetwork: mockNetworks.find( - (n) => - n.chainId === mockTransactionInfo.chainId && - n.coin === getCoinFromTxDataUnion(mockTransactionInfo.txDataUnion) - ) -}) - -export const mockedParsedErc20ApprovalTransaction = parseTransactionWithPrices({ - accounts: mockWalletState.accounts, - tokensList: [ - ...mockWalletState.userVisibleTokensInfo, - ...mockWalletState.fullTokenList - ], - spotPriceRegistry: {}, - tx: mockedErc20ApprovalTransaction, - gasFee: mockWalletState.solFeeEstimates?.fee.toString() ?? '', - transactionNetwork: mockNetworks.find( - (n) => - n.chainId === mockedErc20ApprovalTransaction.chainId && - n.coin === - getCoinFromTxDataUnion(mockedErc20ApprovalTransaction.txDataUnion) - ) -}) diff --git a/components/brave_wallet_ui/stories/mock-data/mock-wallet-state.ts b/components/brave_wallet_ui/stories/mock-data/mock-wallet-state.ts index 275d38ee72a1..2c1fd9d63cec 100644 --- a/components/brave_wallet_ui/stories/mock-data/mock-wallet-state.ts +++ b/components/brave_wallet_ui/stories/mock-data/mock-wallet-state.ts @@ -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' @@ -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,