chore: add getAccountType util

This commit is contained in:
Josh Leonard
2022-11-01 14:37:04 -06:00
parent c0e64ddad8
commit 8e186c1e29
@@ -3,7 +3,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
import { BraveWallet, WalletAccountType } from '../constants/types'
import { AccountInfo, BraveWallet, WalletAccountType } from '../constants/types'
export const sortAccountsByName = (accounts: WalletAccountType[]) => {
return [...accounts].sort(function (a: WalletAccountType, b: WalletAccountType) {
@@ -37,3 +37,10 @@ export const findAccountName = (accounts: WalletAccountType[], address: string)
export const createTokenBalanceRegistryKey = (token: BraveWallet.BlockchainToken) => {
return token.isErc721 ? `${token.contractAddress.toLowerCase()}#${token.tokenId}` : token.contractAddress.toLowerCase()
}
export const getAccountType = (info: AccountInfo) => {
if (info.hardware) {
return info.hardware.vendor
}
return info.isImported ? 'Secondary' : 'Primary'
}