diff options
author | Daniel Tsui <szehungdanieltsui@gmail.com> | 2017-11-08 08:35:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 08:35:18 +0800 |
commit | da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c (patch) | |
tree | 99151d2b40844d5e90a4175550a4b37950d6c744 /ui/app/conversion-util.js | |
parent | 9f70762434deb1c973665a76623838289e655f22 (diff) | |
parent | c57d504794b6020d42dcdabe08a13ed412450fc1 (diff) | |
download | tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.gz tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.bz2 tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.lz tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.xz tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.tar.zst tangerine-wallet-browser-da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c.zip |
Merge pull request #2510 from danjm/NewUI-flat-token-balance
[NewUI] Improving gas precision and send (token) balance validation; max amount feature
Diffstat (limited to 'ui/app/conversion-util.js')
-rw-r--r-- | ui/app/conversion-util.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js index 9359d7c90..ee2950071 100644 --- a/ui/app/conversion-util.js +++ b/ui/app/conversion-util.js @@ -53,7 +53,7 @@ const toNormalizedDenomination = { } const toSpecifiedDenomination = { WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round(), - GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).round(1), + GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).round(9), } const baseChange = { hex: n => n.toString(16), @@ -145,6 +145,20 @@ const addCurrencies = (a, b, options = {}) => { }) } +const subtractCurrencies = (a, b, options = {}) => { + const { + aBase, + bBase, + ...conversionOptions + } = options + const value = (new BigNumber(a, aBase)).minus(b, bBase); + + return converter({ + value, + ...conversionOptions, + }) +} + const multiplyCurrencies = (a, b, options = {}) => { const { multiplicandBase, @@ -169,6 +183,7 @@ const conversionGreaterThan = ( ) => { const firstValue = converter({ ...firstProps }) const secondValue = converter({ ...secondProps }) + return firstValue.gt(secondValue) } @@ -202,4 +217,5 @@ module.exports = { conversionGTE, conversionLTE, toNegative, + subtractCurrencies, } |