From ce463f3aff07c3cb73370cc1446a6b64f91ceb05 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 6 Jul 2016 22:48:02 -0700 Subject: Fixed up pending-tx-details --- ui/app/components/eth-balance.js | 3 ++- ui/app/components/pending-tx-details.js | 47 ++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 23 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/eth-balance.js b/ui/app/components/eth-balance.js index 510b620f3..288a0fcaf 100644 --- a/ui/app/components/eth-balance.js +++ b/ui/app/components/eth-balance.js @@ -14,7 +14,8 @@ function EthBalanceComponent () { EthBalanceComponent.prototype.render = function () { var state = this.props var style = state.style - var value = formatBalance(state.value) + + const value = formatBalance(state.value) return ( diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js index 04e9cd2cd..369104089 100644 --- a/ui/app/components/pending-tx-details.js +++ b/ui/app/components/pending-tx-details.js @@ -4,10 +4,14 @@ const inherits = require('util').inherits const MiniAccountPanel = require('./mini-account-panel') const addressSummary = require('../util').addressSummary -const readableDate = require('../util').readableDate const formatBalance = require('../util').formatBalance const nameForAddress = require('../../lib/contract-namer') -const BN = require('ethereumjs-util').BN +const ethUtil = require('ethereumjs-util') +const BN = ethUtil.BN + +const baseGasFee = new BN('21000', 10) +const gasCost = new BN('10000000000', 10) +const baseFeeHex = baseGasFee.mul(gasCost).toString(16) module.exports = PendingTxDetails @@ -25,11 +29,11 @@ PTXP.render = function () { var txParams = txData.txParams || {} var address = txParams.from || props.selectedAddress var identity = props.identities[address] || { address: address } - var account = props.accounts[address] || { address: address } - - var isContractDeploy = !('to' in txParams) - var maxCost = (new BN(txParams.value, 16) + new BN(txParams.gas, 16)).toString(16) + var gasCost = ethUtil.stripHexPrefix(txParams.gas || baseFeeHex) + var txValue = ethUtil.stripHexPrefix(txParams.value || '0x0') + var maxCost = ((new BN(txValue, 16)).add(new BN(gasCost, 16))).toString(16) + var dataLength = txParams.data ? txParams.data.length - 2 : 0 return ( h('div', [ @@ -86,7 +90,7 @@ PTXP.render = function () { h('.cell.row', [ h('.cell.label', 'Max Transaction Fee'), - h('.cell.value', formatBalance(txParams.gas).formatted), + h('.cell.value', formatBalance(gasCost).formatted), ]), h('.cell.row', { @@ -103,11 +107,11 @@ PTXP.render = function () { style: { background: '#f7f7f7', paddingBottom: '0px', - } + }, }, [ h('.cell.label'), - h('.cell.value', `Data included: ${txParams.data.length - 2} bytes`) - ]) + h('.cell.value', `Data included: ${dataLength} bytes`), + ]), ]), // End of Table this.warnIfNeeded(), @@ -116,15 +120,10 @@ PTXP.render = function () { ) } -PTXP.miniAccountPanelForRecipient = function() { +PTXP.miniAccountPanelForRecipient = function () { var props = this.props var txData = props.txData - var txParams = txData.txParams || {} - var address = txParams.from || props.selectedAddress - var identity = props.identities[address] || { address: address } - var account = props.accounts[address] || { address: address } - var isContractDeploy = !('to' in txParams) // If it's not a contract deploy, send to the account @@ -134,14 +133,14 @@ PTXP.miniAccountPanelForRecipient = function() { nameForAddress(txParams.to), addressSummary(txParams.to, 6, 4, false), ], - imageSeed: address, + imageSeed: txParams.to, imageifyIdenticons: props.imageifyIdenticons, picOrder: 'left', }) } else { - return h(MiniAccountPanel, { + return h(MiniAccountPanel, { attrs: [ - 'New Contract' + 'New Contract', ], imageifyIdenticons: props.imageifyIdenticons, picOrder: 'left', @@ -151,8 +150,12 @@ PTXP.miniAccountPanelForRecipient = function() { // Should analyze if there is a DELEGATECALL opcode // in the recipient contract, and show a warning if so. -PTXP.warnIfNeeded = function() { - return null +PTXP.warnIfNeeded = function () { + const containsDelegateCall = !!this.props.txData.containsDelegateCall + + if (!containsDelegateCall) { + return null + } return h('span.error', { style: { @@ -160,7 +163,7 @@ PTXP.warnIfNeeded = function() { fontSize: '13px', display: 'flex', justifyContent: 'center', - } + }, }, [ h('i.fa.fa-lg.fa-info-circle', { style: { margin: '5px' } }), h('span', ' Your identity may be used in other contracts!'), -- cgit