// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Parity. If not, see . import React, { Component, PropTypes } from 'react'; import ContractIcon from 'material-ui/svg-icons/action/code'; import ReactTooltip from 'react-tooltip'; import * as tUtil from '../util/transaction'; import Account from '../Account'; import styles from './TransactionMainDetails.css'; export default class TransactionMainDetails extends Component { static propTypes = { id: PropTypes.object.isRequired, from: PropTypes.string.isRequired, fromBalance: PropTypes.object, // eth BigNumber, not required since it might take time to fetch value: PropTypes.object.isRequired, // wei hex totalValue: PropTypes.object.isRequired, // wei BigNumber chain: PropTypes.string.isRequired, to: PropTypes.string, // undefined if it's a contract toBalance: PropTypes.object, // eth BigNumber - undefined if it's a contract or until it's fetched className: PropTypes.string, children: PropTypes.node }; componentWillMount () { const { value, totalValue } = this.props; this.updateDisplayValues(value, totalValue); } componentWillReceiveProps (nextProps) { const { value, totalValue } = nextProps; this.updateDisplayValues(value, totalValue); } updateDisplayValues (value, totalValue) { this.setState({ feeEth: tUtil.calcFeeInEth(totalValue, value), valueDisplay: tUtil.getValueDisplay(value), valueDisplayWei: tUtil.getValueDisplayWei(value), totalValueDisplay: tUtil.getTotalValueDisplay(totalValue), totalValueDisplayWei: tUtil.getTotalValueDisplayWei(totalValue) }); } render () { const { className, children } = this.props; return (
{ this.renderTransfer() } { this.renderContract() } { children }
); } renderTransfer () { const { from, fromBalance, to, toBalance, chain } = this.props; if (!to) { return; } return (
{ this.renderValue() }
{ this.renderTotalValue() }
); } renderContract () { const { from, fromBalance, to, chain } = this.props; if (to) { return; } return (
{ this.renderValue() }
{ this.renderTotalValue() }

Contract
); } renderValue () { const { id } = this.props; const { valueDisplay, valueDisplayWei } = this.state; return (
{ valueDisplay } ETH
The value of the transaction.
{ valueDisplayWei } WEI
); } renderTotalValue () { const { id } = this.props; const { totalValueDisplay, totalValueDisplayWei, feeEth } = this.state; return (
{ totalValueDisplay } ETH
The value of the transaction including the mining fee is { totalValueDisplayWei } WEI.
(This includes a mining fee of { feeEth } ETH)
); } }