aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/transaction-breakdown/transaction-breakdown.component.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-09-01 03:36:07 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-09-13 10:48:52 +0800
commitfd51ab12298e93286eeaf03c60e0b4e8d5d1bad3 (patch)
tree69e43bf265b933a158a9ab6e5251df2109f31ea7 /ui/app/components/transaction-breakdown/transaction-breakdown.component.js
parent084158f1a2af9d117c054420e895f4ae76a94df0 (diff)
downloadtangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.tar
tangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.tar.gz
tangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.tar.bz2
tangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.tar.lz
tangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.tar.xz
tangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.tar.zst
tangerine-wallet-browser-fd51ab12298e93286eeaf03c60e0b4e8d5d1bad3.zip
Add TransactionBreakdown component
Diffstat (limited to 'ui/app/components/transaction-breakdown/transaction-breakdown.component.js')
-rw-r--r--ui/app/components/transaction-breakdown/transaction-breakdown.component.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/ui/app/components/transaction-breakdown/transaction-breakdown.component.js b/ui/app/components/transaction-breakdown/transaction-breakdown.component.js
new file mode 100644
index 000000000..a168b53dc
--- /dev/null
+++ b/ui/app/components/transaction-breakdown/transaction-breakdown.component.js
@@ -0,0 +1,82 @@
+import React, { PureComponent } from 'react'
+import PropTypes from 'prop-types'
+import classnames from 'classnames'
+import TransactionBreakdownRow from './transaction-breakdown-row'
+import Card from '../card'
+import CurrencyDisplay from '../currency-display'
+import HexToDecimal from '../hex-to-decimal'
+import { ETH, GWEI } from '../../constants/common'
+import { getHexGasTotal } from '../../helpers/confirm-transaction/util'
+import { addHex } from '../../helpers/transactions.util'
+
+export default class TransactionBreakdown extends PureComponent {
+ static contextTypes = {
+ t: PropTypes.func,
+ }
+
+ static propTypes = {
+ transaction: PropTypes.object,
+ className: PropTypes.string,
+ }
+
+ static defaultProps = {
+ transaction: {},
+ }
+
+ render () {
+ const { t } = this.context
+ const { transaction, className } = this.props
+ const { txParams: { gas, gasPrice, value } = {} } = transaction
+ const hexGasTotal = getHexGasTotal({ gasLimit: gas, gasPrice })
+ const totalInHex = addHex(hexGasTotal, value)
+
+ return (
+ <div className={classnames('transaction-breakdown', className)}>
+ <Card
+ title={t('transaction')}
+ className="transaction-breakdown__card"
+ >
+ <TransactionBreakdownRow title={t('amount')}>
+ <CurrencyDisplay
+ className="transaction-breakdown__value"
+ currency={ETH}
+ value={value}
+ />
+ </TransactionBreakdownRow>
+ <TransactionBreakdownRow
+ title={`${t('gasLimit')} (${t('units')})`}
+ className="transaction-breakdown__row-title"
+ >
+ <HexToDecimal
+ className="transaction-breakdown__value"
+ value={gas}
+ />
+ </TransactionBreakdownRow>
+ <TransactionBreakdownRow title={t('gasPrice')}>
+ <CurrencyDisplay
+ className="transaction-breakdown__value"
+ currency={ETH}
+ denomination={GWEI}
+ value={gasPrice}
+ hideLabel
+ />
+ </TransactionBreakdownRow>
+ <TransactionBreakdownRow title={t('total')}>
+ <div>
+ <CurrencyDisplay
+ className="transaction-breakdown__value transaction-breakdown__value--eth-total"
+ currency={ETH}
+ value={totalInHex}
+ numberOfDecimals={6}
+ />
+ <CurrencyDisplay
+ className="transaction-breakdown__value"
+ value={totalInHex}
+ />
+ </div>
+ </TransactionBreakdownRow>
+ </Card>
+ </div>
+ )
+ }
+}