1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Add valdations to txData param

This commit is contained in:
Frankie 2016-10-19 14:33:30 -07:00
parent 0f0951ba54
commit 5fb1e492fb
2 changed files with 12 additions and 0 deletions

View File

@ -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 = {

View File

@ -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
}