diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-10-20 05:33:30 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-10-20 05:33:30 +0800 |
commit | 5fb1e492fb32e664364603c34044c3e573501781 (patch) | |
tree | 23fd77e8658c24faefb97056e951d8f8f7044dda | |
parent | 0f0951ba549c294222421ef8508294165e9b5fdd (diff) | |
download | tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.tar tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.tar.gz tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.tar.bz2 tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.tar.lz tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.tar.xz tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.tar.zst tangerine-wallet-browser-5fb1e492fb32e664364603c34044c3e573501781.zip |
Add valdations to txData param
-rw-r--r-- | ui/app/send.js | 6 | ||||
-rw-r--r-- | ui/app/util.js | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/ui/app/send.js b/ui/app/send.js index 97ed29e4a..d28a6433b 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -7,6 +7,7 @@ const actions = require('./actions') const util = require('./util') const numericBalance = require('./util').numericBalance const addressSummary = require('./util').addressSummary +const isHex = require('./util').isHex const EthBalance = require('./components/eth-balance') const ethUtil = require('ethereumjs-util') const RangeSlider = require('./components/range-slider') @@ -312,6 +313,11 @@ SendTransactionScreen.prototype.onSubmit = function (gasPrice) { return this.props.dispatch(actions.displayWarning(message)) } + if (!isHex(ethUtil.stripHexPrefix(txData)) && txData) { + message = 'Transaction data must be hex string.' + return this.props.dispatch(actions.displayWarning(message)) + } + this.props.dispatch(actions.hideWarning()) var txParams = { diff --git a/ui/app/util.js b/ui/app/util.js index e4b77e2bc..facaef3ee 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -35,6 +35,7 @@ module.exports = { normalizeNumberToWei: normalizeNumberToWei, valueTable: valueTable, bnTable: bnTable, + isHex: isHex, } function valuesFor (obj) { @@ -209,3 +210,8 @@ function readableDate (ms) { var time = `${hours}:${minutes.substr(-2)}:${seconds.substr(-2)}` return `${dateStr} ${time}` } + +function isHex (str) { + if (str.match(/[g-zG-Z]/) || str.match(/\W/)) return false + return true +} |