From d6ab6bb4fa506c5fb9479b6e534ab74632c1b819 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 19 Apr 2016 18:56:22 -0700 Subject: Fix floating point input bug When sending a transaction, we were converting to BN before handling decimals, which meant we were losing any precision past a decimal point, since BN does not handle decimals! Put this numeric normalization into a utility function with a test around it and got it working. --- ui/app/send.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ui/app/send.js') diff --git a/ui/app/send.js b/ui/app/send.js index ad4a27604..d34accddc 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -108,11 +108,11 @@ SendTransactionScreen.prototype.back = function() { SendTransactionScreen.prototype.onSubmit = function(event) { var recipient = document.querySelector('input.address').value - var amount = new ethUtil.BN(document.querySelector('input.ether').value, 10) + + var inputAmount = parseFloat(document.querySelector('input.ether').value) var currency = document.querySelector('select.currency').value - var txData = document.querySelector('textarea.txData').value + var value = util.normalizeNumberToWei(inputAmount, currency) - var value = util.normalizeToWei(amount, currency) var balance = this.props.balance if (value.gt(balance)) { @@ -132,6 +132,8 @@ SendTransactionScreen.prototype.onSubmit = function(event) { from: this.props.address, value: '0x' + value.toString(16), } + + var txData = document.querySelector('textarea.txData').value if (txData) txParams.data = txData this.props.dispatch(actions.signTx(txParams)) -- cgit v1.2.3