Merge pull request #2783 from MetaMask/tx-param-vaalidation

transactions - throw error if txParams.value contains a decimal
feature/default_network_editable
kumavis 7 years ago committed by GitHub
commit 313b3c087a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 11
      app/scripts/lib/tx-gas-utils.js

@ -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.

@ -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`)
}
}
}
}

Loading…
Cancel
Save