1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const MiniAccountPanel = require('./mini-account-panel')
const addressSummary = require('../util').addressSummary
const formatBalance = require('../util').formatBalance
const nameForAddress = require('../../lib/contract-namer')
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
inherits(PendingTxDetails, Component)
function PendingTxDetails () {
Component.call(this)
}
const PTXP = PendingTxDetails.prototype
PTXP.render = 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 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', [
h('.flex-row.flex-center', {
style: {
maxWidth: '100%',
},
}, [
h(MiniAccountPanel, {
attrs: [
identity.name,
addressSummary(address, 6, 4, false),
formatBalance(identity.balance).formatted,
],
imageSeed: address,
imageifyIdenticons: props.imageifyIdenticons,
picOrder: 'right',
}),
h('img', {
src: 'images/forward-carrat.svg',
style: {
padding: '5px 6px 0px 10px',
height: '48px',
},
}),
this.miniAccountPanelForRecipient(),
]),
h('style', `
.table-box {
margin: 7px 6px 0px 6px;
}
.table-box .row {
margin: 0px;
background: rgb(236,236,236);
display: flex;
justify-content: space-between;
font-family: Montserrat Light, sans-serif;
font-size: 13px;
padding: 5px 15px;
}
`),
h('.table-box', [
h('.row', [
h('.cell.label', 'Amount'),
h('.cell.value', formatBalance(txParams.value).formatted),
]),
h('.cell.row', [
h('.cell.label', 'Max Transaction Fee'),
h('.cell.value', formatBalance(gasCost).formatted),
]),
h('.cell.row', {
style: {
fontFamily: 'Montserrat Regular',
background: 'rgb(216,216,216)',
},
}, [
h('.cell.label', 'Max Total'),
h('.cell.value', formatBalance(maxCost).formatted),
]),
h('.cell.row', {
style: {
background: '#f7f7f7',
paddingBottom: '0px',
},
}, [
h('.cell.label'),
h('.cell.value', `Data included: ${dataLength} bytes`),
]),
]), // End of Table
this.warnIfNeeded(),
])
)
}
PTXP.miniAccountPanelForRecipient = function () {
var props = this.props
var txData = props.txData
var txParams = txData.txParams || {}
var isContractDeploy = !('to' in txParams)
// If it's not a contract deploy, send to the account
if (!isContractDeploy) {
return h(MiniAccountPanel, {
attrs: [
nameForAddress(txParams.to),
addressSummary(txParams.to, 6, 4, false),
],
imageSeed: txParams.to,
imageifyIdenticons: props.imageifyIdenticons,
picOrder: 'left',
})
} else {
return h(MiniAccountPanel, {
attrs: [
'New Contract',
],
imageifyIdenticons: props.imageifyIdenticons,
picOrder: 'left',
})
}
}
// Should analyze if there is a DELEGATECALL opcode
// in the recipient contract, and show a warning if so.
PTXP.warnIfNeeded = function () {
const containsDelegateCall = !!this.props.txData.containsDelegateCall
if (!containsDelegateCall) {
return null
}
return h('span.error', {
style: {
fontFamily: 'Montserrat Light',
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!'),
])
}
|