aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-01-03 06:30:39 +0800
committerGitHub <noreply@github.com>2018-01-03 06:30:39 +0800
commit313b3c087a09bcc4462da15ff3caeac515967cf5 (patch)
tree15a0730287a602baa99a767c3fead548c708b540 /app/scripts
parente572768cb105a400a53ebbedb69d58b83d8a9f28 (diff)
parent3f6cef0b3f56edc8cc0b66403f23ae216de7bcfa (diff)
downloadtangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.tar
tangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.tar.gz
tangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.tar.bz2
tangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.tar.lz
tangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.tar.xz
tangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.tar.zst
tangerine-wallet-browser-313b3c087a09bcc4462da15ff3caeac515967cf5.zip
Merge pull request #2783 from MetaMask/tx-param-vaalidation
transactions - throw error if txParams.value contains a decimal
Diffstat (limited to 'app/scripts')
-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 247b34e47..ccf8bb1b1 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.includes('-')) {
+ throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
+ }
+
+ if (value.includes('.')) {
+ throw new Error(`Invalid transaction value of ${txParams.value} number must be in wei`)
+ }
}
}
}