mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fixes the saving of transactions in send and display in tx-list with conversion utility.
This commit is contained in:
parent
6fa1cd6225
commit
55d62190e3
@ -5,6 +5,8 @@ const classnames = require('classnames')
|
||||
const prefixForNetwork = require('../../lib/etherscan-prefix-for-network')
|
||||
const Identicon = require('./identicon')
|
||||
|
||||
const { conversionUtil } = require('../conversion-util')
|
||||
|
||||
module.exports = TxListItem
|
||||
|
||||
inherits(TxListItem, Component)
|
||||
@ -27,8 +29,26 @@ TxListItem.prototype.render = function () {
|
||||
address,
|
||||
transactionAmount,
|
||||
className,
|
||||
conversionRate,
|
||||
} = this.props
|
||||
|
||||
const totalInUSD = conversionUtil(transactionAmount, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'USD',
|
||||
numberOfDecimals: 2,
|
||||
conversionRate,
|
||||
})
|
||||
const totalInETH = conversionUtil(transactionAmount, {
|
||||
fromNumericBase: 'hex',
|
||||
toNumericBase: 'dec',
|
||||
fromCurrency: 'ETH',
|
||||
toCurrency: 'ETH',
|
||||
conversionRate,
|
||||
numberOfDecimals: 6,
|
||||
})
|
||||
|
||||
return h(`div${className || ''}`, {
|
||||
key: transActionId,
|
||||
onClick: () => onClick && onClick(transActionId),
|
||||
@ -87,11 +107,11 @@ TxListItem.prototype.render = function () {
|
||||
'tx-list-value--confirmed': transactionStatus === 'confirmed'
|
||||
})
|
||||
},
|
||||
transactionAmount
|
||||
`${totalInETH} ETH`,
|
||||
),
|
||||
|
||||
h('span.tx-list-fiat-value', {}, [
|
||||
'+ $300 USD',
|
||||
`${totalInUSD} USD`,
|
||||
]),
|
||||
|
||||
]),
|
||||
|
@ -40,26 +40,26 @@ TxList.prototype.render = function () {
|
||||
]),
|
||||
]),
|
||||
|
||||
this.renderTranstions(),
|
||||
this.renderTransaction(),
|
||||
|
||||
])
|
||||
}
|
||||
|
||||
TxList.prototype.renderTranstions = function () {
|
||||
const { txsToRender } = this.props
|
||||
TxList.prototype.renderTransaction = function () {
|
||||
const { txsToRender, conversionRate } = this.props
|
||||
|
||||
return txsToRender.length
|
||||
? txsToRender.map((transaction) => this.renderTransactionListItem(transaction))
|
||||
? txsToRender.map((transaction) => this.renderTransactionListItem(transaction, conversionRate))
|
||||
: [h('div.tx-list-item.tx-list-item--empty', [ 'No Transactions' ])]
|
||||
}
|
||||
|
||||
// TODO: Consider moving TxListItem into a separate component
|
||||
TxList.prototype.renderTransactionListItem = function (transaction) {
|
||||
TxList.prototype.renderTransactionListItem = function (transaction, conversionRate) {
|
||||
const props = {
|
||||
dateString: formatDate(transaction.time),
|
||||
address: transaction.txParams.to,
|
||||
transactionStatus: transaction.status,
|
||||
transactionAmount: formatBalance(transaction.txParams.value, 6),
|
||||
transactionAmount: transaction.txParams.value,
|
||||
transActionId: transaction.id,
|
||||
transactionHash: transaction.hash,
|
||||
transactionNetworkId: transaction.metamaskNetworkId,
|
||||
@ -85,6 +85,7 @@ TxList.prototype.renderTransactionListItem = function (transaction) {
|
||||
transactionAmount,
|
||||
transactionHash,
|
||||
className: '.tx-list-item.tx-list-clickable',
|
||||
conversionRate,
|
||||
}
|
||||
|
||||
if (transactionStatus === 'unapproved') {
|
||||
|
@ -20,6 +20,7 @@ const {
|
||||
} = require('./actions')
|
||||
const { stripHexPrefix, addHexPrefix } = require('ethereumjs-util')
|
||||
const { isHex, numericBalance } = require('./util')
|
||||
const { conversionUtil } = require('./conversion-util')
|
||||
|
||||
const ARAGON = '960b236A07cf122663c4303350609A66A7B288C0'
|
||||
|
||||
@ -666,11 +667,19 @@ SendTransactionScreen.prototype.onSubmit = function () {
|
||||
|
||||
this.props.dispatch(addToAddressBook(recipient, nickname))
|
||||
|
||||
const sendAmount = conversionUtil(this.state.newTx.amount, {
|
||||
fromNumericBase: 'dec',
|
||||
toNumericBase: 'hex',
|
||||
fromCurrency: this.props.currentCurrency,
|
||||
toCurrency: 'ETH',
|
||||
conversionRate: this.props.conversionRate,
|
||||
})
|
||||
|
||||
var txParams = {
|
||||
from: this.state.newTx.from,
|
||||
to: this.state.newTx.to,
|
||||
|
||||
value: this.state.newTx.amount.toString(16),
|
||||
value: sendAmount,
|
||||
|
||||
// New: gas will now be specified on this step
|
||||
gas: this.state.newTx.gas,
|
||||
|
Loading…
Reference in New Issue
Block a user