|
|
@ -1,5 +1,6 @@ |
|
|
|
// @flow
|
|
|
|
|
|
|
|
import type { CryptoCurrencyConfig } from '@ledgerhq/live-common/lib/types' |
|
|
|
import type Transport from '@ledgerhq/hw-transport' |
|
|
|
import btc from './btc' |
|
|
|
import ethereum from './ethereum' |
|
|
@ -9,7 +10,10 @@ type Resolver = ( |
|
|
|
transport: Transport<*>, |
|
|
|
currencyId: string, |
|
|
|
path: string, |
|
|
|
options: *, |
|
|
|
options: { |
|
|
|
segwit?: boolean, |
|
|
|
verify?: boolean, |
|
|
|
}, |
|
|
|
) => Promise<{ address: string, path: string, publicKey: string }> |
|
|
|
|
|
|
|
type Module = (currencyId: string) => Resolver |
|
|
@ -17,10 +21,12 @@ type Module = (currencyId: string) => Resolver |
|
|
|
const fallback: string => Resolver = currencyId => () => |
|
|
|
Promise.reject(new Error(`${currencyId} device support not implemented`)) |
|
|
|
|
|
|
|
const all = { |
|
|
|
const all: CryptoCurrencyConfig<Resolver> = { |
|
|
|
bitcoin: btc, |
|
|
|
bitcoin_testnet: btc, |
|
|
|
|
|
|
|
litecoin: btc, |
|
|
|
|
|
|
|
zcash: btc, |
|
|
|
bitcoin_cash: btc, |
|
|
|
bitcoin_gold: btc, |
|
|
@ -29,12 +35,24 @@ const all = { |
|
|
|
ethereum, |
|
|
|
ethereum_testnet: ethereum, |
|
|
|
ethereum_classic: ethereum, |
|
|
|
ethereum_classic_testnet: ethereum, |
|
|
|
|
|
|
|
ripple, |
|
|
|
|
|
|
|
// TODO port of all these
|
|
|
|
viacoin: fallback('viacoin'), |
|
|
|
vertcoin: fallback('vertcoin'), |
|
|
|
stratis: fallback('stratis'), |
|
|
|
stealthcoin: fallback('stealthcoin'), |
|
|
|
qtum: fallback('qtum'), |
|
|
|
pivx: fallback('pivx'), |
|
|
|
peercoin: fallback('peercoin'), |
|
|
|
komodo: fallback('komodo'), |
|
|
|
hshare: fallback('hshare'), |
|
|
|
dogecoin: fallback('dogecoin'), |
|
|
|
digibyte: fallback('digibyte'), |
|
|
|
dash: fallback('dash'), |
|
|
|
} |
|
|
|
|
|
|
|
const getAddressForCurrency: Module = (currencyId: string) => |
|
|
|
all[currencyId] || fallback(currencyId) |
|
|
|
const getAddressForCurrency: Module = (currencyId: string) => all[currencyId] |
|
|
|
|
|
|
|
export default getAddressForCurrency |
|
|
|