diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index 2696f69e..df4508bd 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -12,6 +12,7 @@ import type { Tx } from 'api/Ethereum' import { getDerivations } from 'helpers/derivations' import getAddressCommand from 'commands/getAddress' import signTransactionCommand from 'commands/signTransaction' +import { getAccountPlaceholderName, getNewAccountPlaceholderName } from 'helpers/accountName' import type { EditProps, WalletBridge } from './types' // TODO in future it would be neat to support eip55 @@ -192,7 +193,7 @@ const EthereumBridge: WalletBridge = { xpub: '', freshAddress, freshAddressPath, - name: 'New Account', + name: getNewAccountPlaceholderName(currency, index), balance, blockHeight: currentBlock.height, index, @@ -215,7 +216,7 @@ const EthereumBridge: WalletBridge = { xpub: '', freshAddress, freshAddressPath, - name: `Account ${index}`, + name: getAccountPlaceholderName(currency, index, !isStandard), balance, blockHeight: currentBlock.height, index, diff --git a/src/bridge/RippleJSBridge.js b/src/bridge/RippleJSBridge.js index f02b9052..b34faf83 100644 --- a/src/bridge/RippleJSBridge.js +++ b/src/bridge/RippleJSBridge.js @@ -16,6 +16,7 @@ import { } from 'api/Ripple' import FeesRippleKind from 'components/FeesField/RippleKind' import AdvancedOptionsRippleKind from 'components/AdvancedOptions/RippleKind' +import { getAccountPlaceholderName, getNewAccountPlaceholderName } from 'helpers/accountName' import type { WalletBridge, EditProps } from './types' type Transaction = { @@ -279,7 +280,7 @@ const RippleJSBridge: WalletBridge = { next({ id: accountId, xpub: '', - name: 'New Account', + name: getNewAccountPlaceholderName(currency, index), freshAddress, freshAddressPath, balance: 0, @@ -310,7 +311,7 @@ const RippleJSBridge: WalletBridge = { const account: $Exact = { id: accountId, xpub: '', - name: `Account ${index}`, + name: getAccountPlaceholderName(currency, index), freshAddress, freshAddressPath, balance, diff --git a/src/helpers/accountName.js b/src/helpers/accountName.js new file mode 100644 index 00000000..fd230c68 --- /dev/null +++ b/src/helpers/accountName.js @@ -0,0 +1,10 @@ +// @flow +import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' + +export const getAccountPlaceholderName = ( + c: CryptoCurrency, + index: number, + isLegacy: boolean = false, +) => `${c.name} ${index}${isLegacy ? ' (legacy)' : ''}` + +export const getNewAccountPlaceholderName = (_c: CryptoCurrency, _index: number) => `New Account` diff --git a/src/helpers/libcore.js b/src/helpers/libcore.js index 38d3c64a..d0a047e5 100644 --- a/src/helpers/libcore.js +++ b/src/helpers/libcore.js @@ -10,6 +10,8 @@ import type { NJSAccount, NJSOperation } from '@ledgerhq/ledger-core/src/ledgerc import * as accountIdHelper from 'helpers/accountId' +import { getAccountPlaceholderName, getNewAccountPlaceholderName } from './accountName' + type Props = { core: *, devicePath: string, @@ -255,10 +257,14 @@ async function buildAccountRaw({ const operations = ops.map(op => buildOperationRaw({ core, op, xpub })) const currency = getCryptoCurrencyById(currencyId) - let name = operations.length === 0 ? `New Account` : `Account ${accountIndex}` - if (currency.supportsSegwit && !isSegwit) { - name += ' (legacy)' - } + const name = + operations.length === 0 + ? getNewAccountPlaceholderName(currency, accountIndex) + : getAccountPlaceholderName( + currency, + accountIndex, + (currency.supportsSegwit && !isSegwit) || false, + ) const rawAccount: AccountRaw = { id: accountIdHelper.encode({