mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Fixed up pending-tx-details
This commit is contained in:
parent
7481f7c3df
commit
ce463f3aff
File diff suppressed because one or more lines are too long
1
development/states/pending-tx-value.json
Normal file
1
development/states/pending-tx-value.json
Normal file
File diff suppressed because one or more lines are too long
@ -14,7 +14,8 @@ function EthBalanceComponent () {
|
|||||||
EthBalanceComponent.prototype.render = function () {
|
EthBalanceComponent.prototype.render = function () {
|
||||||
var state = this.props
|
var state = this.props
|
||||||
var style = state.style
|
var style = state.style
|
||||||
var value = formatBalance(state.value)
|
|
||||||
|
const value = formatBalance(state.value)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
@ -4,10 +4,14 @@ const inherits = require('util').inherits
|
|||||||
|
|
||||||
const MiniAccountPanel = require('./mini-account-panel')
|
const MiniAccountPanel = require('./mini-account-panel')
|
||||||
const addressSummary = require('../util').addressSummary
|
const addressSummary = require('../util').addressSummary
|
||||||
const readableDate = require('../util').readableDate
|
|
||||||
const formatBalance = require('../util').formatBalance
|
const formatBalance = require('../util').formatBalance
|
||||||
const nameForAddress = require('../../lib/contract-namer')
|
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
|
module.exports = PendingTxDetails
|
||||||
|
|
||||||
@ -25,11 +29,11 @@ PTXP.render = function () {
|
|||||||
var txParams = txData.txParams || {}
|
var txParams = txData.txParams || {}
|
||||||
var address = txParams.from || props.selectedAddress
|
var address = txParams.from || props.selectedAddress
|
||||||
var identity = props.identities[address] || { address: address }
|
var identity = props.identities[address] || { address: address }
|
||||||
var account = props.accounts[address] || { address: address }
|
|
||||||
|
|
||||||
var isContractDeploy = !('to' in txParams)
|
var gasCost = ethUtil.stripHexPrefix(txParams.gas || baseFeeHex)
|
||||||
|
var txValue = ethUtil.stripHexPrefix(txParams.value || '0x0')
|
||||||
var maxCost = (new BN(txParams.value, 16) + new BN(txParams.gas, 16)).toString(16)
|
var maxCost = ((new BN(txValue, 16)).add(new BN(gasCost, 16))).toString(16)
|
||||||
|
var dataLength = txParams.data ? txParams.data.length - 2 : 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h('div', [
|
h('div', [
|
||||||
@ -86,7 +90,7 @@ PTXP.render = function () {
|
|||||||
|
|
||||||
h('.cell.row', [
|
h('.cell.row', [
|
||||||
h('.cell.label', 'Max Transaction Fee'),
|
h('.cell.label', 'Max Transaction Fee'),
|
||||||
h('.cell.value', formatBalance(txParams.gas).formatted),
|
h('.cell.value', formatBalance(gasCost).formatted),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
h('.cell.row', {
|
h('.cell.row', {
|
||||||
@ -103,11 +107,11 @@ PTXP.render = function () {
|
|||||||
style: {
|
style: {
|
||||||
background: '#f7f7f7',
|
background: '#f7f7f7',
|
||||||
paddingBottom: '0px',
|
paddingBottom: '0px',
|
||||||
}
|
},
|
||||||
}, [
|
}, [
|
||||||
h('.cell.label'),
|
h('.cell.label'),
|
||||||
h('.cell.value', `Data included: ${txParams.data.length - 2} bytes`)
|
h('.cell.value', `Data included: ${dataLength} bytes`),
|
||||||
])
|
]),
|
||||||
]), // End of Table
|
]), // End of Table
|
||||||
|
|
||||||
this.warnIfNeeded(),
|
this.warnIfNeeded(),
|
||||||
@ -116,15 +120,10 @@ PTXP.render = function () {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
PTXP.miniAccountPanelForRecipient = function() {
|
PTXP.miniAccountPanelForRecipient = function () {
|
||||||
var props = this.props
|
var props = this.props
|
||||||
var txData = props.txData
|
var txData = props.txData
|
||||||
|
|
||||||
var txParams = txData.txParams || {}
|
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 isContractDeploy = !('to' in txParams)
|
||||||
|
|
||||||
// If it's not a contract deploy, send to the account
|
// If it's not a contract deploy, send to the account
|
||||||
@ -134,14 +133,14 @@ PTXP.miniAccountPanelForRecipient = function() {
|
|||||||
nameForAddress(txParams.to),
|
nameForAddress(txParams.to),
|
||||||
addressSummary(txParams.to, 6, 4, false),
|
addressSummary(txParams.to, 6, 4, false),
|
||||||
],
|
],
|
||||||
imageSeed: address,
|
imageSeed: txParams.to,
|
||||||
imageifyIdenticons: props.imageifyIdenticons,
|
imageifyIdenticons: props.imageifyIdenticons,
|
||||||
picOrder: 'left',
|
picOrder: 'left',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return h(MiniAccountPanel, {
|
return h(MiniAccountPanel, {
|
||||||
attrs: [
|
attrs: [
|
||||||
'New Contract'
|
'New Contract',
|
||||||
],
|
],
|
||||||
imageifyIdenticons: props.imageifyIdenticons,
|
imageifyIdenticons: props.imageifyIdenticons,
|
||||||
picOrder: 'left',
|
picOrder: 'left',
|
||||||
@ -151,8 +150,12 @@ PTXP.miniAccountPanelForRecipient = function() {
|
|||||||
|
|
||||||
// Should analyze if there is a DELEGATECALL opcode
|
// Should analyze if there is a DELEGATECALL opcode
|
||||||
// in the recipient contract, and show a warning if so.
|
// in the recipient contract, and show a warning if so.
|
||||||
PTXP.warnIfNeeded = function() {
|
PTXP.warnIfNeeded = function () {
|
||||||
return null
|
const containsDelegateCall = !!this.props.txData.containsDelegateCall
|
||||||
|
|
||||||
|
if (!containsDelegateCall) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return h('span.error', {
|
return h('span.error', {
|
||||||
style: {
|
style: {
|
||||||
@ -160,7 +163,7 @@ PTXP.warnIfNeeded = function() {
|
|||||||
fontSize: '13px',
|
fontSize: '13px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
}
|
},
|
||||||
}, [
|
}, [
|
||||||
h('i.fa.fa-lg.fa-info-circle', { style: { margin: '5px' } }),
|
h('i.fa.fa-lg.fa-info-circle', { style: { margin: '5px' } }),
|
||||||
h('span', ' Your identity may be used in other contracts!'),
|
h('span', ' Your identity may be used in other contracts!'),
|
||||||
|
@ -35,7 +35,6 @@ function rootReducer (state, action) {
|
|||||||
|
|
||||||
state.appState = reduceApp(state, action)
|
state.appState = reduceApp(state, action)
|
||||||
|
|
||||||
console.log(JSON.stringify(state))
|
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user