aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/app/account-detail.js5
-rw-r--r--ui/app/send.js18
-rw-r--r--ui/app/util.js16
3 files changed, 27 insertions, 12 deletions
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js
index 263e48441..489392473 100644
--- a/ui/app/account-detail.js
+++ b/ui/app/account-detail.js
@@ -13,6 +13,7 @@ const Identicon = require('./components/identicon')
const EtherBalance = require('./components/eth-balance')
const transactionList = require('./components/transaction-list')
const ExportAccountView = require('./components/account-export')
+const ethUtil = require('ethereumjs-util')
module.exports = connect(mapStateToProps)(AccountDetailScreen)
@@ -110,7 +111,7 @@ AccountDetailScreen.prototype.render = function() {
}),
h('i.fa.fa-clipboard.fa-md.cursor-pointer.color-orange', {
- onClick: () => copyToClipboard(selected),
+ onClick: () => copyToClipboard(ethUtil.toChecksumAddress(selected)),
}),
]),
@@ -133,7 +134,7 @@ AccountDetailScreen.prototype.render = function() {
}, 'SEND ETH'),
]),
-
+
]),
// subview (tx history, pk export confirm)
diff --git a/ui/app/send.js b/ui/app/send.js
index 52e56132c..044311b94 100644
--- a/ui/app/send.js
+++ b/ui/app/send.js
@@ -206,20 +206,21 @@ SendTransactionScreen.prototype.back = function() {
this.props.dispatch(actions.backToAccountDetail(address))
}
-SendTransactionScreen.prototype.onSubmit = function(event) {
- var recipient = document.querySelector('input[name="address"]').value
+SendTransactionScreen.prototype.onSubmit = function() {
- var inputAmount = parseFloat(document.querySelector('input[name="amount"]').value)
- var value = util.normalizeNumberToWei(inputAmount, 'ether')
-
- var balance = this.props.balance
+ const recipient = document.querySelector('input[name="address"]').value
+ const inputAmount = parseFloat(document.querySelector('input[name="amount"]').value)
+ const value = util.normalizeNumberToWei(inputAmount, 'ether')
+ const txData = document.querySelector('input[name="txData"]').value
+ const balance = this.props.balance
if (value.gt(balance)) {
var message = 'Insufficient funds.'
return this.props.dispatch(actions.displayWarning(message))
}
- if (recipient.length !== 42) {
- var message = 'Recipient address is the incorrect length.'
+
+ if ((util.isValidAddress(recipient) && !txData) || (!recipient && !txData)) {
+ var message = 'Recipient address is invalid.'
return this.props.dispatch(actions.displayWarning(message))
}
@@ -232,7 +233,6 @@ SendTransactionScreen.prototype.onSubmit = function(event) {
value: '0x' + value.toString(16),
}
- var txData = document.querySelector('input[name="txData"]').value
if (txData) txParams.data = txData
this.props.dispatch(actions.signTx(txParams))
diff --git a/ui/app/util.js b/ui/app/util.js
index 0f3f191aa..d8a0313ea 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -21,6 +21,8 @@ for (var currency in valueTable) {
module.exports = {
valuesFor: valuesFor,
addressSummary: addressSummary,
+ isAllOneCase: isAllOneCase,
+ isValidAddress: isValidAddress,
numericBalance: numericBalance,
parseBalance: parseBalance,
formatBalance: formatBalance,
@@ -42,7 +44,19 @@ function valuesFor(obj) {
}
function addressSummary(address) {
- return address ? address.slice(0,2+8)+'...'+address.slice(-4) : '...'
+ var checked = ethUtil.toChecksumAddress(address)
+ return checked ? checked.slice(0,2+8)+'...'+checked.slice(-4) : '...'
+}
+
+function isValidAddress(address) {
+ var prefixed = ethUtil.addHexPrefix(address)
+ return isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed) || ethUtil.isValidChecksumAddress(prefixed)
+}
+
+function isAllOneCase(address) {
+ var lower = address.toLowerCase()
+ var upper = address.toUpperCase()
+ return address === lower || address === upper
}
// Takes wei Hex, returns wei BN, even if input is null