1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

transactions - throw error if dapp provides txParams whos value has a decimal

This commit is contained in:
frankiebee 2017-12-19 14:28:02 -08:00
parent 84dece92a6
commit f47e81e493

View File

@ -81,8 +81,15 @@ module.exports = class txProvideUtil {
}
async validateTxParams (txParams) {
if (('value' in txParams) && txParams.value.indexOf('-') === 0) {
throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
if ('value' in txParams) {
const value = txParams.value.toString()
if (value.indexOf('-') === 0) {
throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
}
if (value.indexOf('.') >= 0) {
throw new Error(`Invalid transaction value of ${txParams.value} number must be in wei`)
}
}
}
}