From ed7501c4fc8e9601bbaff0bd26eff79ed5139ea4 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 15 Oct 2018 15:44:10 +0200 Subject: [PATCH] refactor Coin > Network --- public/data/appConfig.json | 8 ++-- public/data/ropstenTokens.json | 6 +++ src/actions/DiscoveryActions.js | 10 ++-- src/actions/LocalStorageActions.js | 47 +++---------------- src/actions/RouterActions.js | 4 +- src/actions/SelectedAccountActions.js | 2 +- src/actions/SendFormActions.js | 10 ++-- src/actions/SendFormValidationActions.js | 6 +-- src/actions/TrezorConnectActions.js | 2 +- src/actions/Web3Actions.js | 10 ++-- src/actions/constants/TrezorConnect.js | 2 +- src/components/images/CoinLogo/index.js | 24 +++------- .../Context/components/Account/index.js | 2 +- src/flowtype/index.js | 2 +- src/reducers/BlockchainReducer.js | 16 +++---- src/reducers/LocalStorageReducer.js | 21 ++------- src/reducers/SelectedAccountReducer.js | 4 +- src/reducers/utils/index.js | 8 ++-- src/services/WalletService.js | 4 +- .../components/AccountMenu/index.js | 40 ++++++++-------- .../components/CoinMenu/index.js | 14 +++--- .../components/RowCoin/index.js | 14 ++---- .../components/PendingTransactions/index.js | 4 +- .../Summary/components/Balance/index.js | 18 +++---- .../Wallet/views/Account/Summary/index.js | 12 +---- 25 files changed, 111 insertions(+), 179 deletions(-) diff --git a/public/data/appConfig.json b/public/data/appConfig.json index 93b1520b..08460609 100644 --- a/public/data/appConfig.json +++ b/public/data/appConfig.json @@ -1,9 +1,9 @@ { - "coins": [ + "networks": [ { "name": "Ethereum", "symbol": "ETH", - "network": "eth", + "shortcut": "eth", "bip44": "m/44'/60'/0'/0", "chainId": 1, "defaultGasPrice": 64, @@ -21,7 +21,7 @@ { "name": "Ethereum Classic", "symbol": "ETC", - "network": "etc", + "shortcut": "etc", "chainId": 61, "bip44": "m/44'/61'/0'/0", "defaultGasPrice": 64, @@ -39,7 +39,7 @@ { "name": "Ethereum Ropsten", "symbol": "tROP", - "network": "trop", + "shortcut": "trop", "chainId": 3, "bip44": "m/44'/60'/0'/0", "defaultGasPrice": 64, diff --git a/public/data/ropstenTokens.json b/public/data/ropstenTokens.json index f4d716ae..ae6aa8cb 100644 --- a/public/data/ropstenTokens.json +++ b/public/data/ropstenTokens.json @@ -16,5 +16,11 @@ "name": "Trezor13", "symbol": "T013", "decimals": 13 + }, + { + "address": "0x58cda554935e4a1f2acbe15f8757400af275e084", + "name": "LahodCoin", + "symbol": "LAHOD", + "decimals": 13 } ] \ No newline at end of file diff --git a/src/actions/DiscoveryActions.js b/src/actions/DiscoveryActions.js index 596bc335..3c497f2e 100644 --- a/src/actions/DiscoveryActions.js +++ b/src/actions/DiscoveryActions.js @@ -92,7 +92,7 @@ const start = (device: TrezorDevice, network: string, ignoreCompleted?: boolean) return; } - const blockchain = getState().blockchain.find(b => b.name === network); + const blockchain = getState().blockchain.find(b => b.shortcut === network); if (blockchain && !blockchain.connected && (!discoveryProcess || !discoveryProcess.completed)) { dispatch({ type: DISCOVERY.WAITING_FOR_BLOCKCHAIN, @@ -124,8 +124,8 @@ const start = (device: TrezorDevice, network: string, ignoreCompleted?: boolean) // start discovery process const begin = (device: TrezorDevice, network: string): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise => { const { config } = getState().localStorage; - const coinToDiscover = config.coins.find(c => c.network === network); - if (!coinToDiscover) return; + const networkData = config.networks.find(c => c.shortcut === network); + if (!networkData) return; dispatch({ type: DISCOVERY.WAITING_FOR_DEVICE, @@ -140,7 +140,7 @@ const begin = (device: TrezorDevice, network: string): AsyncAction => async (dis instance: device.instance, state: device.state, }, - path: coinToDiscover.bip44, + path: networkData.bip44, keepSession: true, // acquire and hold session //useEmptyPassphrase: !device.instance, useEmptyPassphrase: device.useEmptyPassphrase, @@ -179,7 +179,7 @@ const begin = (device: TrezorDevice, network: string): AsyncAction => async (dis // send data to reducer dispatch({ type: DISCOVERY.START, - network: coinToDiscover.network, + network, device, publicKey: response.payload.publicKey, chainCode: response.payload.chainCode, diff --git a/src/actions/LocalStorageActions.js b/src/actions/LocalStorageActions.js index d7d32a1f..ae1c04c2 100644 --- a/src/actions/LocalStorageActions.js +++ b/src/actions/LocalStorageActions.js @@ -13,7 +13,7 @@ import * as buildUtils from 'utils/build'; import type { ThunkAction, AsyncAction, /* GetState, */ Dispatch, } from 'flowtype'; -import type { Config, Coin, TokensCollection } from 'reducers/LocalStorageReducer'; +import type { Config, Network, TokensCollection } from 'reducers/LocalStorageReducer'; import Erc20AbiJSON from 'public/data/ERC20Abi.json'; import AppConfigJSON from 'public/data/appConfig.json'; @@ -99,8 +99,8 @@ export function loadTokensFromJSON(): AsyncAction { const config: Config = await httpRequest(AppConfigJSON, 'json'); if (!buildUtils.isDev()) { - const index = config.coins.findIndex(c => c.network === 'trop'); - delete config.coins[index]; + const index = config.networks.findIndex(c => c.shortcut === 'trop'); + delete config.networks[index]; } const ERC20Abi = await httpRequest(Erc20AbiJSON, 'json'); @@ -117,10 +117,10 @@ export function loadTokensFromJSON(): AsyncAction { } // load tokens - const tokens = await config.coins.reduce(async (promise: Promise, coin: Coin): Promise => { + const tokens = await config.networks.reduce(async (promise: Promise, network: Network): Promise => { const collection: TokensCollection = await promise; - const json = await httpRequest(coin.tokens, 'json'); - collection[coin.network] = json; + const json = await httpRequest(network.tokens, 'json'); + collection[network.shortcut] = json; return collection; }, Promise.resolve({})); @@ -195,41 +195,6 @@ export const loadData = (): ThunkAction => (dispatch: Dispatch): void => { dispatch(loadTokensFromJSON()); }; -// const parseConfig = (json: JSON): Config => { - -// if (json['coins']) { - -// } - -// for (let key in json) { -// if (key === 'coins') { - -// } -// } - -// const coins: Array = json.coins || []; - -// if ("coins" in json){ -// json.coins -// } -// if (!json.hasOwnProperty("fiatValueTickers")) throw new Error(`Property "fiatValueTickers" is missing in appConfig.json`); -// if (json.config && json.hasOwnProperty('coins') && Array.isArray(json.coins)) { -// json.coins.map(c => { -// return { - -// } -// }) -// } else { -// throw new Error(`Property "coins" is missing in appConfig.json`); -// } - - -// return { -// coins: [], -// fiatValueTickers: [] -// } -// } - export const save = (key: string, value: string): ThunkAction => (): void => { if (typeof window.localStorage !== 'undefined') { try { diff --git a/src/actions/RouterActions.js b/src/actions/RouterActions.js index b764dcb9..4e744df7 100644 --- a/src/actions/RouterActions.js +++ b/src/actions/RouterActions.js @@ -71,8 +71,8 @@ export const paramsValidation = (params: RouterLocationState): PayloadAction c.network === params.network); - if (!coin) return false; + const network = config.networks.find(c => c.shortcut === params.network); + if (!network) return false; if (!params.account) return false; } diff --git a/src/actions/SelectedAccountActions.js b/src/actions/SelectedAccountActions.js index a075906e..995e1cf8 100644 --- a/src/actions/SelectedAccountActions.js +++ b/src/actions/SelectedAccountActions.js @@ -63,7 +63,7 @@ const getAccountStatus = (state: State, selectedAccount: SelectedAccountState): }; } - const blockchain = state.blockchain.find(b => b.name === network.network); + const blockchain = state.blockchain.find(b => b.shortcut === network.shortcut); if (blockchain && !blockchain.connected) { return { type: 'backend', diff --git a/src/actions/SendFormActions.js b/src/actions/SendFormActions.js index 39301c7b..3413ed36 100644 --- a/src/actions/SendFormActions.js +++ b/src/actions/SendFormActions.js @@ -130,7 +130,7 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS return; } - const gasPrice: BigNumber = await dispatch(BlockchainActions.getGasPrice(network.network, network.defaultGasPrice)); + const gasPrice: BigNumber = await dispatch(BlockchainActions.getGasPrice(network.shortcut, network.defaultGasPrice)); const gasLimit = network.defaultGasLimit.toString(); const feeLevels = ValidationActions.getFeeLevels(network.symbol, gasPrice, gasLimit); const selectedFeeLevel = ValidationActions.getSelectedFeeLevel(feeLevels, initialState.selectedFeeLevel); @@ -139,7 +139,7 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS type: SEND.INIT, state: { ...initialState, - networkName: network.network, + networkName: network.shortcut, networkSymbol: network.symbol, currency: network.symbol, feeLevels, @@ -411,7 +411,7 @@ const estimateGasPrice = (): AsyncAction => async (dispatch: Dispatch, getState: return; } - const gasLimit = await dispatch(BlockchainActions.estimateGasLimit(network.network, state.data, state.amount, state.gasPrice)); + const gasLimit = await dispatch(BlockchainActions.estimateGasLimit(network.shortcut, state.data, state.amount, state.gasPrice)); // double check "data" field // possible race condition when data changed before backend respond @@ -439,7 +439,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge const nonce = pendingNonce > 0 && pendingNonce >= account.nonce ? pendingNonce : account.nonce; const txData = await dispatch(prepareEthereumTx({ - network: network.network, + network: network.shortcut, token: isToken ? findToken(getState().tokens, account.address, currentState.currency, account.deviceState) : null, from: account.address, to: currentState.address, @@ -487,7 +487,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge const serializedTx: string = await dispatch(serializeEthereumTx(txData)); const push = await TrezorConnect.pushTransaction({ tx: serializedTx, - coin: network.network, + coin: network.shortcut, }); if (!push.success) { diff --git a/src/actions/SendFormValidationActions.js b/src/actions/SendFormValidationActions.js index 327ccff3..c1a4fe9c 100644 --- a/src/actions/SendFormValidationActions.js +++ b/src/actions/SendFormValidationActions.js @@ -174,7 +174,7 @@ export const addressLabel = ($state: State): PayloadAction => (dispatch: const savedAccounts = getState().accounts.filter(a => a.address.toLowerCase() === address.toLowerCase()); if (savedAccounts.length > 0) { // check if found account belongs to this network - const currentNetworkAccount = savedAccounts.find(a => a.network === network.network); + const currentNetworkAccount = savedAccounts.find(a => a.network === network.shortcut); if (currentNetworkAccount) { const device = findDevice(getState().devices, currentNetworkAccount.deviceID, currentNetworkAccount.deviceState); if (device) { @@ -184,8 +184,8 @@ export const addressLabel = ($state: State): PayloadAction => (dispatch: // corner-case: the same derivation path is used on different networks const otherNetworkAccount = savedAccounts[0]; const device = findDevice(getState().devices, otherNetworkAccount.deviceID, otherNetworkAccount.deviceState); - const { coins } = getState().localStorage.config; - const otherNetwork = coins.find(c => c.network === otherNetworkAccount.network); + const { networks } = getState().localStorage.config; + const otherNetwork = networks.find(c => c.shortcut === otherNetworkAccount.network); if (device && otherNetwork) { state.warnings.address = `Looks like it's ${device.instanceLabel} Account #${(otherNetworkAccount.index + 1)} address of ${otherNetwork.name} network`; } diff --git a/src/actions/TrezorConnectActions.js b/src/actions/TrezorConnectActions.js index b7320a2e..cc51ffab 100644 --- a/src/actions/TrezorConnectActions.js +++ b/src/actions/TrezorConnectActions.js @@ -36,7 +36,7 @@ export type TrezorConnectAction = { type: typeof CONNECT.INITIALIZATION_ERROR, error: string } | { - type: typeof CONNECT.COIN_CHANGED, + type: typeof CONNECT.NETWORK_CHANGED, payload: { network: string } diff --git a/src/actions/Web3Actions.js b/src/actions/Web3Actions.js index 2c3d9131..5cf2607e 100644 --- a/src/actions/Web3Actions.js +++ b/src/actions/Web3Actions.js @@ -57,15 +57,15 @@ export const initWeb3 = (network: string, urlIndex: number = 0): PromiseAction c.network === network); - if (!coin) { - // coin not found + const networkData = config.networks.find(c => c.shortcut === network); + if (!networkData) { + // network not found reject(new Error(`Network ${network} not found in application config.`)); return; } // get first url - const url = coin.web3[urlIndex]; + const url = networkData.web3[urlIndex]; if (!url) { reject(new Error('Web3 backend is not responding')); return; @@ -80,7 +80,7 @@ export const initWeb3 = (network: string, urlIndex: number = 0): PromiseAction ); @@ -52,8 +41,7 @@ class CoinLogo extends PureComponent { } CoinLogo.propTypes = { - coinId: PropTypes.string, - coinNetwork: PropTypes.string, + network: PropTypes.string, }; export default CoinLogo; diff --git a/src/components/notifications/Context/components/Account/index.js b/src/components/notifications/Context/components/Account/index.js index bb980931..5dbddcbc 100644 --- a/src/components/notifications/Context/components/Account/index.js +++ b/src/components/notifications/Context/components/Account/index.js @@ -20,7 +20,7 @@ export default (props: Props) => { [{ label: 'Connect', callback: async () => { - await props.blockchainReconnect(network.network); + await props.blockchainReconnect(network.shortcut); }, }] } diff --git a/src/flowtype/index.js b/src/flowtype/index.js index 44bd5556..f262aa49 100644 --- a/src/flowtype/index.js +++ b/src/flowtype/index.js @@ -150,7 +150,7 @@ export type Action = export type State = ReducersState; // reexport reduces types -export type { Coin } from 'reducers/LocalStorageReducer'; +export type { Network } from 'reducers/LocalStorageReducer'; export type { Account } from 'reducers/AccountsReducer'; export type { Discovery } from 'reducers/DiscoveryReducer'; export type { Token } from 'reducers/TokensReducer'; diff --git a/src/reducers/BlockchainReducer.js b/src/reducers/BlockchainReducer.js index 570c02a5..1b863232 100644 --- a/src/reducers/BlockchainReducer.js +++ b/src/reducers/BlockchainReducer.js @@ -5,7 +5,7 @@ import { BLOCKCHAIN } from 'trezor-connect'; import type { Action } from 'flowtype'; export type BlockchainNetwork = { - +name: string; + +shortcut: string; connected: boolean; } @@ -13,16 +13,16 @@ export type State = Array; export const initialState: State = []; -const find = (state: State, name: string): number => state.findIndex(b => b.name === name); +const find = (state: State, shortcut: string): number => state.findIndex(b => b.shortcut === shortcut); const connect = (state: State, action: any): State => { - const name = action.payload.coin.shortcut.toLowerCase(); + const shortcut = action.payload.coin.shortcut.toLowerCase(); const network: BlockchainNetwork = { - name, + shortcut, connected: true, }; const newState: State = [...state]; - const index: number = find(newState, name); + const index: number = find(newState, shortcut); if (index >= 0) { newState[index] = network; } else { @@ -32,13 +32,13 @@ const connect = (state: State, action: any): State => { }; const disconnect = (state: State, action: any): State => { - const name = action.payload.coin.shortcut.toLowerCase(); + const shortcut = action.payload.coin.shortcut.toLowerCase(); const network: BlockchainNetwork = { - name, + shortcut, connected: false, }; const newState: State = [...state]; - const index: number = find(newState, name); + const index: number = find(newState, shortcut); if (index >= 0) { newState[index] = network; } else { diff --git a/src/reducers/LocalStorageReducer.js b/src/reducers/LocalStorageReducer.js index 27b3d9e2..c9d81925 100644 --- a/src/reducers/LocalStorageReducer.js +++ b/src/reducers/LocalStorageReducer.js @@ -5,9 +5,9 @@ import * as STORAGE from 'actions/constants/localStorage'; import type { Action } from 'flowtype'; -export type Coin = { +export type Network = { name: string; - network: string; + shortcut: string; symbol: string; bip44: string; defaultGasLimit: number; @@ -57,40 +57,27 @@ export type FiatValueTicker = { } export type Config = { - coins: Array; + networks: Array; fiatValueTickers: Array; } -export type CustomBackend = { - name: string; - url: string; -} - export type State = { initialized: boolean; error: ?string; config: Config; ERC20Abi: Array; tokens: TokensCollection; - customBackend: Array; } const initialState: State = { initialized: false, error: null, config: { - coins: [], + networks: [], fiatValueTickers: [], }, ERC20Abi: [], tokens: {}, - customBackend: [ - { - name: 'Custom1', - slug: 'custom1', - url: 'http://google.com', - }, - ], }; export default function localStorage(state: State = initialState, action: Action): State { diff --git a/src/reducers/SelectedAccountReducer.js b/src/reducers/SelectedAccountReducer.js index d00d5f00..fbd4f643 100644 --- a/src/reducers/SelectedAccountReducer.js +++ b/src/reducers/SelectedAccountReducer.js @@ -4,7 +4,7 @@ import * as ACCOUNT from 'actions/constants/account'; import type { Action, Account, - Coin, + Network, Token, PendingTx, Discovery, @@ -13,7 +13,7 @@ import type { export type State = { location: string; account: ?Account; - network: ?Coin; + network: ?Network; tokens: Array, pending: Array, discovery: ?Discovery, diff --git a/src/reducers/utils/index.js b/src/reducers/utils/index.js index 5de5aece..c56cebdd 100644 --- a/src/reducers/utils/index.js +++ b/src/reducers/utils/index.js @@ -6,7 +6,7 @@ import type { Device, TrezorDevice, Account, - Coin, + Network, Discovery, Token, PendingTx, @@ -66,13 +66,13 @@ export const getSelectedAccount = (state: State): ?Account => { return state.accounts.find(a => a.deviceState === device.state && a.index === index && a.network === locationState.network); }; -export const getSelectedNetwork = (state: State): ?Coin => { +export const getSelectedNetwork = (state: State): ?Network => { const device = state.wallet.selectedDevice; - const { coins } = state.localStorage.config; + const { networks } = state.localStorage.config; const locationState = state.router.location.state; if (!device || !locationState.network) return null; - return coins.find(c => c.network === locationState.network); + return networks.find(c => c.shortcut === locationState.network); }; export const getDiscoveryProcess = (state: State): ?Discovery => { diff --git a/src/services/WalletService.js b/src/services/WalletService.js index 24b35496..597f1b3c 100644 --- a/src/services/WalletService.js +++ b/src/services/WalletService.js @@ -70,10 +70,10 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa const prevLocation = prevState.router.location; const currentLocation = api.getState().router.location; if (action.type === LOCATION_CHANGE && prevLocation.pathname !== currentLocation.pathname) { - // watch for coin change + // watch for network change if (prevLocation.state.network !== currentLocation.state.network) { api.dispatch({ - type: CONNECT.COIN_CHANGED, + type: CONNECT.NETWORK_CHANGED, payload: { network: currentLocation.state.network, }, diff --git a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js index ba6cf83a..dfd38016 100644 --- a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js @@ -115,11 +115,11 @@ const AccountMenu = (props: Props) => { const baseUrl: string = urlParams.deviceInstance ? `/device/${urlParams.device}:${urlParams.deviceInstance}` : `/device/${urlParams.device}`; const { config } = props.localStorage; - const selectedCoin = config.coins.find(c => c.network === location.state.network); + const network = config.networks.find(c => c.shortcut === location.state.network); - if (!selected || !selectedCoin) return null; + if (!selected || !network) return null; - const fiatRate = props.fiat.find(f => f.network === selectedCoin.network); + const fiatRate = props.fiat.find(f => f.network === network.shortcut); const deviceAccounts: Accounts = findDeviceAccounts(accounts, selected, location.state.network); @@ -130,14 +130,14 @@ const AccountMenu = (props: Props) => { let balance: string = 'Loading...'; if (account.balance !== '') { const pending = stateUtils.getAccountPendingTx(props.pending, account); - const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, selectedCoin.symbol); + const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, network.symbol); const availableBalance: string = new BigNumber(account.balance).minus(pendingAmount).toString(10); - balance = `${availableBalance} ${selectedCoin.symbol}`; + balance = `${availableBalance} ${network.symbol}`; if (fiatRate) { const accountBalance = new BigNumber(availableBalance); const fiat = accountBalance.times(fiatRate.value).toFixed(2); - balance = `${availableBalance} ${selectedCoin.symbol} / $${fiat}`; + balance = `${availableBalance} ${network.symbol} / $${fiat}`; } } @@ -233,21 +233,19 @@ const AccountMenu = (props: Props) => { return ( - {selectedCoin && ( - - - - )} + + + {selectedAccounts} diff --git a/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js index 8391bc17..6d262662 100644 --- a/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js @@ -37,9 +37,9 @@ class CoinMenu extends PureComponent { return coins.map((coin) => { const row = ( { const { config } = this.props.localStorage; return ( - {config.coins.map(item => ( + {config.networks.map(item => ( diff --git a/src/views/Wallet/components/LeftNavigation/components/RowCoin/index.js b/src/views/Wallet/components/LeftNavigation/components/RowCoin/index.js index 4ffc780b..472f6d1a 100644 --- a/src/views/Wallet/components/LeftNavigation/components/RowCoin/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/RowCoin/index.js @@ -38,7 +38,7 @@ const IconWrapper = styled.div` `; const RowCoin = ({ - coin, iconLeft, iconRight, + network, iconLeft, iconRight, }) => ( @@ -53,11 +53,8 @@ const RowCoin = ({ )} - -

{coin.name}

+ +

{network.name}

{iconRight && ( @@ -77,10 +74,9 @@ const iconShape = { size: PropTypes.number.isRequired, }; RowCoin.propTypes = { - coin: PropTypes.shape({ + network: PropTypes.shape({ name: PropTypes.string.isRequired, - network: PropTypes.string, - id: PropTypes.string, + shortcut: PropTypes.string, }).isRequired, iconLeft: PropTypes.shape(iconShape), iconRight: PropTypes.shape(iconShape), diff --git a/src/views/Wallet/views/Account/Send/components/PendingTransactions/index.js b/src/views/Wallet/views/Account/Send/components/PendingTransactions/index.js index 418c3a0c..63c5dfb8 100644 --- a/src/views/Wallet/views/Account/Send/components/PendingTransactions/index.js +++ b/src/views/Wallet/views/Account/Send/components/PendingTransactions/index.js @@ -7,14 +7,14 @@ import { H2 } from 'components/Heading'; import Link from 'components/Link'; import ScaleText from 'react-scale-text'; -import type { Coin } from 'reducers/LocalStorageReducer'; +import type { Network } from 'reducers/LocalStorageReducer'; import type { Token } from 'reducers/TokensReducer'; import type { Props as BaseProps } from '../../Container'; type Props = { pending: $PropertyType<$ElementType, 'pending'>, tokens: $PropertyType<$ElementType, 'tokens'>, - network: Coin + network: Network } const Wrapper = styled.div` diff --git a/src/views/Wallet/views/Account/Summary/components/Balance/index.js b/src/views/Wallet/views/Account/Summary/components/Balance/index.js index 09e38769..1968abe1 100644 --- a/src/views/Wallet/views/Account/Summary/components/Balance/index.js +++ b/src/views/Wallet/views/Account/Summary/components/Balance/index.js @@ -7,11 +7,11 @@ import colors from 'config/colors'; import ICONS from 'config/icons'; import { FONT_SIZE, FONT_WEIGHT } from 'config/variables'; -import type { Coin } from 'reducers/LocalStorageReducer'; +import type { Network } from 'flowtype'; import type { Props as BaseProps } from '../../Container'; type Props = { - coin: Coin, + network: Network, balance: string, fiat: $ElementType, } @@ -77,7 +77,7 @@ const BalanceRateWrapper = styled(BalanceWrapper)` padding-left: 50px; `; -const CoinBalace = styled.div` +const CoinBalance = styled.div` font-size: ${FONT_SIZE.SMALLER}; color: ${colors.TEXT_SECONDARY}; `; @@ -97,7 +97,7 @@ class AccountBalance extends PureComponent { }; } - handleHideBallanceIconClick() { + handleHideBalanceIconClick() { this.setState(previousState => ({ isHidden: !previousState.isHidden, canAnimateHideBalanceIcon: true, @@ -105,8 +105,8 @@ class AccountBalance extends PureComponent { } render() { - const selectedCoin = this.props.coin; - const fiatRate: any = this.props.fiat.find(f => f.network === selectedCoin.network); + const { network } = this.props; + const fiatRate: any = this.props.fiat.find(f => f.network === network.shortcut); let accountBalance = ''; let fiatRateValue = ''; @@ -121,7 +121,7 @@ class AccountBalance extends PureComponent { return ( this.handleHideBallanceIconClick()} + onClick={() => this.handleHideBalanceIconClick()} > { {fiatRate && ( ${fiat} )} - {this.props.balance} {selectedCoin.symbol} + {this.props.balance} {network.symbol} {fiatRate && ( ${fiatRateValue} - 1.00 {selectedCoin.symbol} + 1.00 {network.symbol} )} diff --git a/src/views/Wallet/views/Account/Summary/index.js b/src/views/Wallet/views/Account/Summary/index.js index 3be7a769..6dc91de2 100644 --- a/src/views/Wallet/views/Account/Summary/index.js +++ b/src/views/Wallet/views/Account/Summary/index.js @@ -81,18 +81,15 @@ const AccountSummary = (props: Props) => { - +

Account #{parseInt(account.index, 10) + 1}

See full transaction history

Tokens

@@ -108,11 +105,6 @@ const AccountSummary = (props: Props) => { />
- {/* 0x58cda554935e4a1f2acbe15f8757400af275e084 Lahod */} - {/* 0x58cda554935e4a1f2acbe15f8757400af275e084 T01 */} - - {/* TOOO: AsyncSelect is lagging when dropdown menu must show more than 200 items */} - {/* TODO: Input's box-shadow */}