diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/send.js | 4 | ||||
-rw-r--r-- | ui/app/util.js | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/ui/app/send.js b/ui/app/send.js index ea9dd7c0c..926c3e29a 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -209,8 +209,8 @@ SendTransactionScreen.prototype.back = function() { SendTransactionScreen.prototype.onSubmit = function() { const recipient = document.querySelector('input[name="address"]').value - const inputAmount = parseFloat(document.querySelector('input[name="amount"]').value) - const value = util.normalizeNumberToWei(inputAmount, 'ether') + const input = document.querySelector('input[name="amount"]').value + const value = util.normalizeEthStringToWei(input) const txData = document.querySelector('input[name="txData"]').value const balance = this.props.balance diff --git a/ui/app/util.js b/ui/app/util.js index 7597c2df8..31c147877 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -31,6 +31,7 @@ module.exports = { ethToWei: ethToWei, weiToEth: weiToEth, normalizeToWei: normalizeToWei, + normalizeEthStringToWei: normalizeEthStringToWei, normalizeNumberToWei: normalizeNumberToWei, valueTable: valueTable, bnTable: bnTable, @@ -120,6 +121,20 @@ function normalizeToWei(amount, currency) { return amount } +function normalizeEthStringToWei(str) { + const parts = str.split('.') + let eth = new ethUtil.BN(parts[0], 10).mul(bnTable.wei) + if (parts[1]) { + var decimal = parts[1] + while(decimal.length < 18) { + decimal += '0' + } + const decimalBN = new ethUtil.BN(decimal, 10) + eth = eth.add(decimalBN) + } + return eth +} + var multiple = new ethUtil.BN('10000', 10) function normalizeNumberToWei(n, currency) { var enlarged = n * 10000 |