aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
authorKevin Serrano <kevin.serrano@consensys.net>2017-12-28 10:22:10 +0800
committerKevin Serrano <kevin.serrano@consensys.net>2017-12-28 10:22:10 +0800
commite682fb05fcdeca5f50a2176934d25935e13538f6 (patch)
tree825eee0cb26aca71d796f7564554cfd056106aca /ui/app
parent92eb16fc112eeac749c0ddfff163773ce3a35ef2 (diff)
downloadtangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.gz
tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.zst
tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.zip
Add frontend validation to ensure that ether inputs are valid.
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/send.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/ui/app/send.js b/ui/app/send.js
index 7b31eef7e..09c9e03d4 100644
--- a/ui/app/send.js
+++ b/ui/app/send.js
@@ -247,16 +247,26 @@ SendTransactionScreen.prototype.onSubmit = function () {
const recipient = state.recipient || document.querySelector('input[name="address"]').value.replace(/^[.\s]+|[.\s]+$/g, '')
const nickname = state.nickname || ' '
const input = document.querySelector('input[name="amount"]').value
+ const parts = input.split('')
- if (isNaN(input)) {
+ let message
+
+ if (isNaN(input) || input === '') {
message = 'Invalid ether value.'
return this.props.dispatch(actions.displayWarning(message))
}
+ if (parts[1]) {
+ var decimal = parts[1]
+ if (decimal.length > 18) {
+ message = 'Ether amount is too precise.'
+ return this.props.dispatch(actions.displayWarning(message))
+ }
+ }
+
const value = util.normalizeEthStringToWei(input)
const txData = document.querySelector('input[name="txData"]').value
const balance = this.props.balance
- let message
if (value.gt(balance)) {
message = 'Insufficient funds.'