diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-12-20 06:28:02 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-12-21 06:09:59 +0800 |
commit | f47e81e4937871a7a690e357443a728b9049b8f0 (patch) | |
tree | 5e29162271ba2f28c8c90066655124fe61ce82a2 /app/scripts/lib | |
parent | 84dece92a6214b4ee562f69194c964a935e27af8 (diff) | |
download | tangerine-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
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/tx-gas-utils.js | 11 |
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`) + } } } } |