aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md9
-rw-r--r--test/unit/util_test.js14
-rw-r--r--ui/app/send.js4
-rw-r--r--ui/app/util.js15
4 files changed, 36 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b713433a2..8681c9517 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,10 +2,11 @@
## Current Master
-- UI Overhaul per Vlad Todirut's designs
-- Replaced identicons with jazzicons
-- Fixed glitchy transitions
-- Added support for capitalization-based address checksums
+- UI Overhaul per Vlad Todirut's designs.
+- Replaced identicons with jazzicons.
+- Fixed glitchy transitions.
+- Added support for capitalization-based address checksums.
+- Send value is no longer limited by javascript number precision, and is always in ETH.
## 1.8.4 2016-05-13
diff --git a/test/unit/util_test.js b/test/unit/util_test.js
index 5f28dbb25..b091d5bc7 100644
--- a/test/unit/util_test.js
+++ b/test/unit/util_test.js
@@ -159,6 +159,20 @@ describe('util', function() {
})
})
+ describe('normalizeEthStringToWei', function() {
+ it('should convert decimal eth to pure wei BN', function() {
+ var input = '1.23456789'
+ var output = util.normalizeEthStringToWei(input)
+ assert.equal(output.toString(10), '1234567890000000000')
+ })
+
+ it('should convert 1 to expected wei', function() {
+ var input = '1'
+ var output = util.normalizeEthStringToWei(input)
+ assert.equal(output.toString(10), ethInWei)
+ })
+ })
+
describe('#normalizeNumberToWei', function() {
it('should handle a simple use case', function() {
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