// @flow import React from 'react'; import Big from 'bignumber.js'; import { BaseWallet } from 'libs/wallet'; import type { NetworkConfig } from 'config/data'; import type { State } from 'reducers'; import { connect } from 'react-redux'; import { getWalletInst, getTokenBalances } from 'selectors/wallet'; import type { TokenBalance } from 'selectors/wallet'; import { getNetworkConfig } from 'selectors/config'; import { Link } from 'react-router'; import TokenBalances from './TokenBalances'; import { formatNumber } from 'utils/formatters'; import { Identicon } from 'components/ui'; import translate from 'translations'; import * as customTokenActions from 'actions/customTokens'; import { showNotification } from 'actions/notifications'; type Props = { wallet: BaseWallet, balance: Big, network: NetworkConfig, tokenBalances: TokenBalance[], rates: { [string]: number }, showNotification: Function, addCustomToken: typeof customTokenActions.addCustomToken, removeCustomToken: typeof customTokenActions.removeCustomToken }; export class BalanceSidebar extends React.Component { props: Props; state = { showLongBalance: false, address: '' }; componentDidMount() { this.props.wallet .getAddress() .then(addr => { this.setState({ address: addr }); }) .catch(err => { this.props.showNotification('danger', err); }); } render() { const { wallet, balance, network, tokenBalances, rates } = this.props; const { blockExplorer, tokenExplorer } = network; const { address } = this.state; if (!wallet) { return null; } return ( ); } toggleShowLongBalance = (e: SyntheticMouseEvent) => { e.preventDefault(); this.setState(state => { return { showLongBalance: !state.showLongBalance }; }); }; } function mapStateToProps(state: State) { return { wallet: getWalletInst(state), balance: state.wallet.balance, tokenBalances: getTokenBalances(state), network: getNetworkConfig(state), rates: state.rates }; } export default connect(mapStateToProps, { ...customTokenActions, showNotification })(BalanceSidebar);