aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-12-20 06:28:02 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-12-21 06:09:59 +0800
commitf47e81e4937871a7a690e357443a728b9049b8f0 (patch)
tree5e29162271ba2f28c8c90066655124fe61ce82a2
parent84dece92a6214b4ee562f69194c964a935e27af8 (diff)
downloadtangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.tar
tangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.tar.gz
tangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.tar.bz2
tangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.tar.lz
tangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.tar.xz
tangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.tar.zst
tangerine-wallet-browser-f47e81e4937871a7a690e357443a728b9049b8f0.zip
transactions - throw error if dapp provides txParams whos value has a decimal
-rw-r--r--app/scripts/lib/tx-gas-utils.js11
1 files 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`)
+ }
}
}
}