From f47e81e4937871a7a690e357443a728b9049b8f0 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Tue, 19 Dec 2017 14:28:02 -0800 Subject: [PATCH 1/4] 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`) + } } } } From 9f08ada1a6d9ba15ecec1be83089d89222bbe6c1 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Wed, 20 Dec 2017 18:49:52 -0800 Subject: [PATCH 2/4] add to CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b7256466..846e6d81e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Throw an error if a application trys to submit a tx who's value contains a decimal and infor that it should be in wei. + ## 3.13.3 2017-12-14 - Show tokens that are held that have no balance. From cc7e85c078c0bd3ac69f4f2c2de07da8f4fb4d23 Mon Sep 17 00:00:00 2001 From: Dan Finlay <542863+danfinlay@users.noreply.github.com> Date: Thu, 21 Dec 2017 11:36:09 -0800 Subject: [PATCH 3/4] Spelling --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 846e6d81e..391cbe66c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Current Master -- Throw an error if a application trys to submit a tx who's value contains a decimal and infor that it should be in wei. +- Throw an error if a application tries to submit a tx whose value is a decimal, and inform that it should be in wei. ## 3.13.3 2017-12-14 From 3f6cef0b3f56edc8cc0b66403f23ae216de7bcfa Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 2 Jan 2018 14:22:44 -0800 Subject: [PATCH 4/4] tx-gas-utils - tx-param-validation - use more intuitive check --- app/scripts/lib/tx-gas-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js index c00323a64..bc891fc07 100644 --- a/app/scripts/lib/tx-gas-utils.js +++ b/app/scripts/lib/tx-gas-utils.js @@ -83,11 +83,11 @@ module.exports = class txProvideUtil { async validateTxParams (txParams) { if ('value' in txParams) { const value = txParams.value.toString() - if (value.indexOf('-') === 0) { + if (value.includes('-')) { throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`) } - if (value.indexOf('.') >= 0) { + if (value.includes('.')) { throw new Error(`Invalid transaction value of ${txParams.value} number must be in wei`) } }