Browse Source
Merge pull request #473 from gre/better-default-naming
better default naming
master
Gaëtan Renaudeau
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
26 additions and
8 deletions
-
src/bridge/EthereumJSBridge.js
-
src/bridge/RippleJSBridge.js
-
src/helpers/accountName.js
-
src/helpers/libcore.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<Transaction> = { |
|
|
|
xpub: '', |
|
|
|
freshAddress, |
|
|
|
freshAddressPath, |
|
|
|
name: 'New Account', |
|
|
|
name: getNewAccountPlaceholderName(currency, index), |
|
|
|
balance, |
|
|
|
blockHeight: currentBlock.height, |
|
|
|
index, |
|
|
@ -215,7 +216,7 @@ const EthereumBridge: WalletBridge<Transaction> = { |
|
|
|
xpub: '', |
|
|
|
freshAddress, |
|
|
|
freshAddressPath, |
|
|
|
name: `Account ${index}`, |
|
|
|
name: getAccountPlaceholderName(currency, index, !isStandard), |
|
|
|
balance, |
|
|
|
blockHeight: currentBlock.height, |
|
|
|
index, |
|
|
|
|
|
@ -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<Transaction> = { |
|
|
|
next({ |
|
|
|
id: accountId, |
|
|
|
xpub: '', |
|
|
|
name: 'New Account', |
|
|
|
name: getNewAccountPlaceholderName(currency, index), |
|
|
|
freshAddress, |
|
|
|
freshAddressPath, |
|
|
|
balance: 0, |
|
|
@ -310,7 +311,7 @@ const RippleJSBridge: WalletBridge<Transaction> = { |
|
|
|
const account: $Exact<Account> = { |
|
|
|
id: accountId, |
|
|
|
xpub: '', |
|
|
|
name: `Account ${index}`, |
|
|
|
name: getAccountPlaceholderName(currency, index), |
|
|
|
freshAddress, |
|
|
|
freshAddressPath, |
|
|
|
balance, |
|
|
|
|
|
@ -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` |
|
|
@ -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({ |
|
|
|