From 8b55b95e288115e2762b6cb5680a6192de3a781b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 11 Jun 2018 11:56:57 +0200 Subject: [PATCH] whitelist crypto currencies supported --- src/components/DeviceConnect/stories.js | 6 ++--- src/config/cryptocurrencies.js | 34 +++++++++++++++++++++++++ src/reducers/settings.js | 2 +- src/stories/currencies.stories.js | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/config/cryptocurrencies.js diff --git a/src/components/DeviceConnect/stories.js b/src/components/DeviceConnect/stories.js index 1032e803..a819c3b0 100644 --- a/src/components/DeviceConnect/stories.js +++ b/src/components/DeviceConnect/stories.js @@ -4,10 +4,8 @@ import React from 'react' import { storiesOf } from '@storybook/react' import { boolean, select, text } from '@storybook/addon-knobs' import { action } from '@storybook/addon-actions' -import { - getCryptoCurrencyById, - listCryptoCurrencies, -} from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { listCryptoCurrencies } from 'config/cryptocurrencies' import type { Currency } from '@ledgerhq/live-common/lib/types' diff --git a/src/config/cryptocurrencies.js b/src/config/cryptocurrencies.js new file mode 100644 index 00000000..0b097368 --- /dev/null +++ b/src/config/cryptocurrencies.js @@ -0,0 +1,34 @@ +// @flow +import memoize from 'lodash/memoize' +import { listCryptoCurrencies as listCC } from '@ledgerhq/live-common/lib/helpers/currencies' +import type { CryptoCurrencyIds } from '@ledgerhq/live-common/lib/types' + +const supported: CryptoCurrencyIds[] = [ + 'bitcoin', + 'ethereum', + 'ripple', + 'bitcoin_cash', + 'litecoin', + 'dash', + 'ethereum_classic', + 'qtum', + 'zcash', + 'bitcoin_gold', + 'stratis', + 'dogecoin', + 'digibyte', + 'hcash', + 'komodo', + 'pivx', + 'zencash', + 'vertcoin', + 'peercoin', + 'viacoin', + 'stealthcoin', + 'poswallet', + 'bitcoin_testnet', +] + +export const listCryptoCurrencies = memoize((withDevCrypto?: boolean) => + listCC(withDevCrypto).filter(c => supported.includes(c.id)), +) diff --git a/src/reducers/settings.js b/src/reducers/settings.js index 76a14892..be751c6d 100644 --- a/src/reducers/settings.js +++ b/src/reducers/settings.js @@ -5,8 +5,8 @@ import { findCurrencyByTicker, getCryptoCurrencyById, getFiatCurrencyByTicker, - listCryptoCurrencies, } from '@ledgerhq/live-common/lib/helpers/currencies' +import { listCryptoCurrencies } from 'config/cryptocurrencies' import languages from 'config/languages' import { createSelector } from 'reselect' import type { InputSelector as Selector } from 'reselect' diff --git a/src/stories/currencies.stories.js b/src/stories/currencies.stories.js index c3b5803f..cd90b664 100644 --- a/src/stories/currencies.stories.js +++ b/src/stories/currencies.stories.js @@ -2,7 +2,7 @@ import React, { Fragment } from 'react' import { storiesOf } from '@storybook/react' -import { listCryptoCurrencies } from '@ledgerhq/live-common/lib/helpers/currencies' +import { listCryptoCurrencies } from 'config/cryptocurrencies' import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react' import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'