aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/conversions.util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/helpers/conversions.util.js')
-rw-r--r--ui/app/helpers/conversions.util.js40
1 files changed, 39 insertions, 1 deletions
diff --git a/ui/app/helpers/conversions.util.js b/ui/app/helpers/conversions.util.js
index cb5e1b90b..065d67e8e 100644
--- a/ui/app/helpers/conversions.util.js
+++ b/ui/app/helpers/conversions.util.js
@@ -1,6 +1,6 @@
import ethUtil from 'ethereumjs-util'
-import { conversionUtil } from '../conversion-util'
import { ETH, GWEI, WEI } from '../constants/common'
+import { conversionUtil, addCurrencies } from '../conversion-util'
export function bnToHex (inputBn) {
return ethUtil.addHexPrefix(inputBn.toString(16))
@@ -82,3 +82,41 @@ export function getWeiHexFromDecimalValue ({
toDenomination: WEI,
})
}
+
+export function addHexWEIsToDec (aHexWEI, bHexWEI) {
+ return addCurrencies(aHexWEI, bHexWEI, {
+ aBase: 16,
+ bBase: 16,
+ fromDenomination: 'WEI',
+ numberOfDecimals: 6,
+ })
+}
+
+export function decEthToConvertedCurrency (ethTotal, convertedCurrency, conversionRate) {
+ return conversionUtil(ethTotal, {
+ fromNumericBase: 'dec',
+ toNumericBase: 'dec',
+ fromCurrency: 'ETH',
+ toCurrency: convertedCurrency,
+ numberOfDecimals: 2,
+ conversionRate,
+ })
+}
+
+export function decGWEIToHexWEI (decGWEI) {
+ return conversionUtil(decGWEI, {
+ fromNumericBase: 'dec',
+ toNumericBase: 'hex',
+ fromDenomination: 'GWEI',
+ toDenomination: 'WEI',
+ })
+}
+
+export function hexWEIToDecGWEI (decGWEI) {
+ return conversionUtil(decGWEI, {
+ fromNumericBase: 'hex',
+ toNumericBase: 'dec',
+ fromDenomination: 'WEI',
+ toDenomination: 'GWEI',
+ })
+}