diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-05-20 05:46:50 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-05-20 05:46:50 +0800 |
commit | 60270de53d214edffad7b90356bbe06081a55443 (patch) | |
tree | 67a648b43cbb604507ccd793e9a44cbbe24deb23 /ui/app/util.js | |
parent | 22a77b80411350bd844313b51ea58312940b9738 (diff) | |
download | tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.tar tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.tar.gz tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.tar.bz2 tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.tar.lz tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.tar.xz tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.tar.zst tangerine-wallet-browser-60270de53d214edffad7b90356bbe06081a55443.zip |
Add full precision to send tx value field.
Diffstat (limited to 'ui/app/util.js')
-rw-r--r-- | ui/app/util.js | 15 |
1 files changed, 15 insertions, 0 deletions
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 |