aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/conversion-util.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-10-13 00:42:14 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-16 11:09:05 +0800
commita9244f5e426d6572ef135e07ab75a49c00e84942 (patch)
tree7aa7e1d98711ffbb2e27eb068b086c13238f421f /ui/app/conversion-util.js
parenta59972dcabc56c3d92f09ba1b88a2ded70ce8c34 (diff)
downloadtangerine-wallet-browser-a9244f5e426d6572ef135e07ab75a49c00e84942.tar.gz
tangerine-wallet-browser-a9244f5e426d6572ef135e07ab75a49c00e84942.tar.zst
tangerine-wallet-browser-a9244f5e426d6572ef135e07ab75a49c00e84942.zip
Customize Gas connected to state
Diffstat (limited to 'ui/app/conversion-util.js')
-rw-r--r--ui/app/conversion-util.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js
index 3a702bcdd..3a9e9ad0f 100644
--- a/ui/app/conversion-util.js
+++ b/ui/app/conversion-util.js
@@ -32,6 +32,7 @@ BigNumber.config({
// Big Number Constants
const BIG_NUMBER_WEI_MULTIPLIER = new BigNumber('1000000000000000000')
+const BIG_NUMBER_GWEI_MULTIPLIER = new BigNumber('1000000000')
// Individual Setters
const convert = R.invoker(1, 'times')
@@ -45,10 +46,12 @@ const toBigNumber = {
BN: n => new BigNumber(n.toString(16), 16),
}
const toNormalizedDenomination = {
- WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER)
+ WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER),
+ GWEI: bigNumber => bigNumber.div(BIG_NUMBER_GWEI_MULTIPLIER),
}
const toSpecifiedDenomination = {
- WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round()
+ WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round(),
+ GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).round(),
}
const baseChange = {
hex: n => n.toString(16),
@@ -139,8 +142,13 @@ const addCurrencies = (a, b, options = {}) => {
}
const multiplyCurrencies = (a, b, options = {}) => {
- const { toNumericBase, numberOfDecimals } = options
- const value = (new BigNumber(a)).times(b);
+ const {
+ toNumericBase,
+ numberOfDecimals,
+ multiplicandBase,
+ multiplierBase,
+ } = options
+ const value = (new BigNumber(a, multiplicandBase)).times(b, multiplierBase);
return converter({
value,
toNumericBase,