aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/scripts/lib/tx-gas-utils.js11
2 files changed, 10 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dfcd0d1b9..dc96203be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Current Master
+- Throw an error if a application tries to submit a tx whose value is a decimal, and inform that it should be in wei.
- Fix bug that prevented updating custom token details.
- No longer mark long-pending transactions as failed, since we now have button to retry with higher gas.
- Fix rounding error when specifying an ether amount that has too much precision.
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`)
+ }
}
}
}