diff --git a/components/brave_wallet/browser/brave_wallet_utils_unittest.cc b/components/brave_wallet/browser/brave_wallet_utils_unittest.cc index fdb5ec74334d..1259d6ba4f0d 100644 --- a/components/brave_wallet/browser/brave_wallet_utils_unittest.cc +++ b/components/brave_wallet/browser/brave_wallet_utils_unittest.cc @@ -978,7 +978,7 @@ TEST_F(BraveWalletUtilsUnitTest, GetChain) { EXPECT_EQ(GetChain(&prefs, "f", mojom::CoinType::FIL), fil_mainnet.Clone()); } -TEST(BraveWalletUtilsUnitTest, GetAllKnownEthNetworkIds) { +TEST_F(BraveWalletUtilsUnitTest, GetAllKnownEthNetworkIds) { const std::vector expected_network_ids( {"mainnet", mojom::kPolygonMainnetChainId, mojom::kBinanceSmartChainMainnetChainId, mojom::kCeloMainnetChainId, diff --git a/components/brave_wallet_ui/common/hardware/types.ts b/components/brave_wallet_ui/common/hardware/types.ts index 5dd16f5c59a8..159f4092d6fa 100644 --- a/components/brave_wallet_ui/common/hardware/types.ts +++ b/components/brave_wallet_ui/common/hardware/types.ts @@ -61,13 +61,5 @@ export type GetAccountsHardwareOperationResult = HardwareOperationResult & { payload?: BraveWallet.HardwareWalletAccount[] } -// Did not create a string for these yet since it is -// likely these names will be returned from another service -// that will be localized. -export const FilecoinNetworkLocaleMapping = { - [BraveWallet.FILECOIN_MAINNET]: 'Filecoin Mainnet', - [BraveWallet.FILECOIN_TESTNET]: 'Filecoin Testnet' -} - // Batch size of accounts imported from the device in one step. export const DerivationBatchSize = 4 diff --git a/components/brave_wallet_ui/components/desktop/network-filter-selector/index.tsx b/components/brave_wallet_ui/components/desktop/network-filter-selector/index.tsx index ebd57392f326..2e3d5507fd0f 100644 --- a/components/brave_wallet_ui/components/desktop/network-filter-selector/index.tsx +++ b/components/brave_wallet_ui/components/desktop/network-filter-selector/index.tsx @@ -91,7 +91,8 @@ function NetworkFilterSelector () { selectedNetwork={selectedNetworkFilter} isSubItem={isTestNetworksEnabled ? !SupportedTopLevelChainIds.includes(network.chainId) : true} > - {isTestNetworksEnabled && + {/* Disabled Filecoin Submenu until testnetworks are enabled */} + {isTestNetworksEnabled && network.coin !== BraveWallet.CoinType.FIL && {sortedNetworks.filter((n) => n.coin === network.coin && diff --git a/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/add-imported-account-modal.tsx b/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/add-imported-account-modal.tsx index 7b410d79031a..1298c1116520 100644 --- a/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/add-imported-account-modal.tsx +++ b/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/add-imported-account-modal.tsx @@ -16,7 +16,6 @@ import { CreateAccountOptions } from '../../../../options/create-account-options // types import { BraveWallet, CreateAccountOptionsType, PageState, WalletRoutes, WalletState } from '../../../../constants/types' -import { FilecoinNetworkTypes, FilecoinNetworkLocaleMapping, FilecoinNetwork } from '../../../../common/hardware/types' // actions import { WalletPageActions } from '../../../../page/actions' @@ -74,8 +73,11 @@ export const ImportAccountModal = () => { }, [accountTypeName, isFilecoinEnabled, isSolanaEnabled]) // state + const selectedFilecoinNetwork = useSelector(({ wallet }: { wallet: WalletState }) => { + return wallet.defaultNetworks.find((network) => { return network.coin === BraveWallet.CoinType.FIL }) +}) const [accountName, setAccountName] = React.useState('') - const [filecoinNetwork, setFilecoinNetwork] = React.useState('f') + const networkSymbol = selectedFilecoinNetwork?.chainId.toLowerCase() === BraveWallet.FILECOIN_MAINNET.toLowerCase() ? BraveWallet.FILECOIN_MAINNET : BraveWallet.FILECOIN_TESTNET const [importOption, setImportOption] = React.useState('key') const [privateKey, setPrivateKey] = React.useState('') const [file, setFile] = React.useState() @@ -112,10 +114,6 @@ export const ImportAccountModal = () => { setImportError(false) }, [setImportError]) - const onChangeFilecoinNetwork = React.useCallback((network: FilecoinNetwork) => { - setFilecoinNetwork(network) - }, []) - const handlePrivateKeyChanged = React.useCallback((event: React.ChangeEvent) => { setPrivateKey(event.target.value) setImportError(false) @@ -141,7 +139,7 @@ export const ImportAccountModal = () => { const onClickCreateAccount = React.useCallback(() => { if (importOption === 'key') { if (selectedAccountType?.coin === BraveWallet.CoinType.FIL) { - importFilecoinAccount(accountName, privateKey, filecoinNetwork) + importFilecoinAccount(accountName, privateKey, networkSymbol) } else { importAccount(accountName, privateKey, selectedAccountType?.coin || BraveWallet.CoinType.ETH) } @@ -208,23 +206,6 @@ export const ImportAccountModal = () => { {getLocale('braveWalletImportAccountDisclaimer')} - {selectedAccountType?.coin === BraveWallet.CoinType.FIL && - <> - - - - - } - {selectedAccountType?.coin === BraveWallet.CoinType.ETH && {Object.keys(derivationPathsEnum).map((path, index) => { const pathValue = derivationPathsEnum[path] @@ -127,17 +122,6 @@ export default function (props: Props) { ) })} - ) : ( - )} diff --git a/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/hardware-wallet-connect/index.tsx b/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/hardware-wallet-connect/index.tsx index ddf13199ec2c..006fba23bae2 100644 --- a/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/hardware-wallet-connect/index.tsx +++ b/components/brave_wallet_ui/components/desktop/popup-modals/add-account-modal/hardware-wallet-connect/index.tsx @@ -32,7 +32,7 @@ import { // Custom types import { ErrorMessage, HardwareWalletDerivationPathsMapping } from './types' -import { HardwareDerivationScheme, LedgerDerivationPaths, FilecoinNetwork, DerivationBatchSize } from '../../../../../common/hardware/types' +import { HardwareDerivationScheme, LedgerDerivationPaths, DerivationBatchSize } from '../../../../../common/hardware/types' import { HardwareVendor } from '../../../../../common/api/hardware_keyrings' import { WalletPageActions } from '../../../../../page/actions' import { BraveWallet, CreateAccountOptionsType, WalletState } from '../../../../../constants/types' @@ -68,6 +68,9 @@ export const HardwareWalletConnect = ({ onSuccess, selectedAccountType }: Props) // redux const dispatch = useDispatch() const selectedNetwork = useSelector(({ wallet }: { wallet: WalletState }) => wallet.selectedNetwork) + const selectedFilecoinNetwork = useSelector(({ wallet }: { wallet: WalletState }) => { + return wallet.defaultNetworks.find((network) => { return network.coin === BraveWallet.CoinType.FIL }) +}) const savedAccounts = useSelector(({ wallet }: { wallet: WalletState }) => wallet.accounts) // state @@ -79,28 +82,11 @@ export const HardwareWalletConnect = ({ onSuccess, selectedAccountType }: Props) const [selectedDerivationScheme, setSelectedDerivationScheme] = React.useState( LedgerDerivationPaths.LedgerLive ) + const [showAccountsList, setShowAccountsList] = React.useState(false) - const [filecoinNetwork, setFilecoinNetwork] = React.useState('f') + const filecoinNetwork = selectedFilecoinNetwork?.chainId.toLowerCase() === BraveWallet.FILECOIN_MAINNET.toLowerCase() ? BraveWallet.FILECOIN_MAINNET : BraveWallet.FILECOIN_TESTNET // methods - const onFilecoinNetworkChanged = React.useCallback((network: FilecoinNetwork) => { - setFilecoinNetwork(network) - onConnectHardwareWallet({ - hardware: BraveWallet.LEDGER_HARDWARE_VENDOR, - startIndex: 0, - stopIndex: DerivationBatchSize, - network: network, - coin: BraveWallet.CoinType.FIL - }).then((result) => { - setAccounts(result) - }).catch((error) => { - setConnectionError(getErrorMessage(error, selectedAccountType.name)) - setShowAccountsList(false) - }).finally( - () => setIsConnecting(false) - ) - }, [onConnectHardwareWallet, selectedAccountType]) - const onAddHardwareAccounts = React.useCallback((selected: BraveWallet.HardwareWalletAccount[]) => { dispatch(WalletPageActions.addHardwareAccounts(selected)) onSuccess() @@ -215,7 +201,6 @@ export const HardwareWalletConnect = ({ onSuccess, selectedAccountType }: Props) getBalance={getBalance} selectedNetwork={selectedNetwork} filecoinNetwork={filecoinNetwork} - onChangeFilecoinNetwork={onFilecoinNetworkChanged} selectedAccountType={selectedAccountType} /> )