diff --git a/app/components/Wallet/ReceiveModal/ReceiveModal.js b/app/components/Wallet/ReceiveModal/ReceiveModal.js index 70588f06..c766a8cc 100644 --- a/app/components/Wallet/ReceiveModal/ReceiveModal.js +++ b/app/components/Wallet/ReceiveModal/ReceiveModal.js @@ -102,7 +102,8 @@ class ReceiveModal extends React.Component {

- ({network.name}) + {' '} + {network && network.name.toLowerCase() === 'testnet' && network.name}

{address} diff --git a/app/reducers/info.js b/app/reducers/info.js index 3ebe1c91..c63a8deb 100644 --- a/app/reducers/info.js +++ b/app/reducers/info.js @@ -1,5 +1,6 @@ import bitcoin from 'bitcoinjs-lib' import { ipcRenderer } from 'electron' +import get from 'lodash.get' import db from 'store/db' import { walletAddress } from './address' @@ -56,7 +57,7 @@ const networks = { unitPrefix: 't' }, mainnet: { - name: null, // no name since it is the presumed default + name: 'Mainnet', explorerUrl: 'https://smartbit.com.au', bitcoinJsNetwork: bitcoin.networks.bitcoin, unitPrefix: '' @@ -76,6 +77,7 @@ const ACTION_HANDLERS = { ...state, infoLoading: false, network: data.testnet ? networks.testnet : networks.mainnet, + chain: get(data, 'chains[0]'), data }) } @@ -87,7 +89,8 @@ const initialState = { infoLoading: false, hasSynced: undefined, network: {}, - data: {} + data: {}, + chain: null } // Selectors diff --git a/app/reducers/ticker.js b/app/reducers/ticker.js index 60726bb8..7346f35a 100644 --- a/app/reducers/ticker.js +++ b/app/reducers/ticker.js @@ -13,12 +13,18 @@ export const SET_FIAT_TICKER = 'SET_FIAT_TICKER' export const GET_TICKERS = 'GET_TICKERS' export const RECIEVE_TICKERS = 'RECIEVE_TICKERS' -// Map for crypto names to crypto tickers +// Map for crypto codes to crypto tickers const cryptoTickers = { bitcoin: 'btc', litecoin: 'ltc' } +// Map for crypto names to crypto tickers +const cryptoNames = { + bitcoin: 'Bitcoin', + litecoin: 'Litecoin' +} + // ------------------------------------ // Actions // ------------------------------------ @@ -70,7 +76,7 @@ export const fetchTicker = () => async dispatch => { // Receive IPC event for receiveCryptocurrency export const receiveCryptocurrency = (event, currency) => dispatch => { dispatch({ type: SET_CURRENCY, currency: cryptoTickers[currency] }) - dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] }) + dispatch({ type: SET_CRYPTO, crypto: currency }) } // ------------------------------------ @@ -105,9 +111,11 @@ tickerSelectors.currentTicker = createSelector( cryptoSelector, bitcoinTickerSelector, litecoinTickerSelector, - (crypto, btcTicker, ltcTicker) => (crypto === 'btc' ? btcTicker : ltcTicker) + (crypto, btcTicker, ltcTicker) => (crypto === 'bitcoin' ? btcTicker : ltcTicker) ) +tickerSelectors.cryptoName = createSelector(cryptoSelector, crypto => cryptoNames[crypto]) + tickerSelectors.currencyFilters = createSelector( infoSelectors.networkSelector, currencyFiltersSelector, @@ -142,9 +150,9 @@ export { tickerSelectors } // ------------------------------------ const initialState = { tickerLoading: false, - currency: '', - fromCurrency: 'sats', - crypto: '', + currency: null, + fromCurrency: null, + crypto: null, btcTicker: null, ltcTicker: null, fiatTicker: getDefaultCurrency(), diff --git a/test/unit/reducers/__snapshots__/info.spec.js.snap b/test/unit/reducers/__snapshots__/info.spec.js.snap index 2efe44bf..2758e89c 100644 --- a/test/unit/reducers/__snapshots__/info.spec.js.snap +++ b/test/unit/reducers/__snapshots__/info.spec.js.snap @@ -2,6 +2,7 @@ exports[`reducers infoReducer should correctly getInfo 1`] = ` Object { + "chain": null, "data": Object {}, "hasSynced": undefined, "infoLoading": true, @@ -11,6 +12,7 @@ Object { exports[`reducers infoReducer should correctly receiveInfo 1`] = ` Object { + "chain": undefined, "data": "foo", "hasSynced": undefined, "infoLoading": false, @@ -28,7 +30,7 @@ Object { "wif": 128, }, "explorerUrl": "https://smartbit.com.au", - "name": null, + "name": "Mainnet", "unitPrefix": "", }, } @@ -36,6 +38,7 @@ Object { exports[`reducers infoReducer should handle initial state 1`] = ` Object { + "chain": null, "data": Object {}, "hasSynced": undefined, "infoLoading": false, diff --git a/test/unit/reducers/__snapshots__/ticker.spec.js.snap b/test/unit/reducers/__snapshots__/ticker.spec.js.snap index c17714b9..9bc98ecf 100644 --- a/test/unit/reducers/__snapshots__/ticker.spec.js.snap +++ b/test/unit/reducers/__snapshots__/ticker.spec.js.snap @@ -3,8 +3,8 @@ exports[`reducers tickerReducer should correctly getTicker 1`] = ` Object { "btcTicker": null, - "crypto": "", - "currency": "", + "crypto": null, + "currency": null, "currencyFilters": Array [ Object { "key": "btc", @@ -44,7 +44,7 @@ Object { "THB", "TWB", ], - "fromCurrency": "sats", + "fromCurrency": null, "ltcTicker": null, "tickerLoading": true, } @@ -53,8 +53,8 @@ Object { exports[`reducers tickerReducer should correctly receiveTicker 1`] = ` Object { "btcTicker": undefined, - "crypto": "", - "currency": "", + "crypto": null, + "currency": null, "currencyFilters": Array [ Object { "key": "btc", @@ -94,7 +94,7 @@ Object { "THB", "TWB", ], - "fromCurrency": "sats", + "fromCurrency": null, "ltcTicker": undefined, "tickerLoading": false, } @@ -104,7 +104,7 @@ exports[`reducers tickerReducer should correctly setCrypto 1`] = ` Object { "btcTicker": null, "crypto": "foo", - "currency": "", + "currency": null, "currencyFilters": Array [ Object { "key": "btc", @@ -144,7 +144,7 @@ Object { "THB", "TWB", ], - "fromCurrency": "sats", + "fromCurrency": null, "ltcTicker": null, "tickerLoading": false, } @@ -153,7 +153,7 @@ Object { exports[`reducers tickerReducer should correctly setCurrency 1`] = ` Object { "btcTicker": null, - "crypto": "", + "crypto": null, "currency": "foo", "currencyFilters": Array [ Object { @@ -194,7 +194,7 @@ Object { "THB", "TWB", ], - "fromCurrency": "", + "fromCurrency": null, "ltcTicker": null, "tickerLoading": false, } @@ -203,8 +203,8 @@ Object { exports[`reducers tickerReducer should handle initial state 1`] = ` Object { "btcTicker": null, - "crypto": "", - "currency": "", + "crypto": null, + "currency": null, "currencyFilters": Array [ Object { "key": "btc", @@ -244,7 +244,7 @@ Object { "THB", "TWB", ], - "fromCurrency": "sats", + "fromCurrency": null, "ltcTicker": null, "tickerLoading": false, }