mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #2783 from MetaMask/tx-param-vaalidation
transactions - throw error if txParams.value contains a decimal
This commit is contained in:
commit
313b3c087a
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Current Master
|
## 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.
|
- 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.
|
- 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.
|
- Fix rounding error when specifying an ether amount that has too much precision.
|
||||||
|
@ -81,8 +81,15 @@ module.exports = class txProvideUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async validateTxParams (txParams) {
|
async validateTxParams (txParams) {
|
||||||
if (('value' in txParams) && txParams.value.indexOf('-') === 0) {
|
if ('value' in txParams) {
|
||||||
throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
|
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…
Reference in New Issue
Block a user