From f47e81e4937871a7a690e357443a728b9049b8f0 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Tue, 19 Dec 2017 14:28:02 -0800 Subject: transactions - throw error if dapp provides txParams whos value has a decimal --- app/scripts/lib/tx-gas-utils.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js index 56bee19f7..c00323a64 100644 --- a/app/scripts/lib/tx-gas-utils.js +++ b/app/scripts/lib/tx-gas-utils.js @@ -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`) + } } } } -- cgit v1.2.3