aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/conversions.util.js
blob: 1dec216fade114153990bbea0ee387fe4c150650 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { conversionUtil } from '../conversion-util'

export function hexToDecimal (hexValue) {
  return conversionUtil(hexValue, {
    fromNumericBase: 'hex',
    toNumericBase: 'dec',
  })
}

export function getEthFromWeiHex ({
  value,
  conversionRate,
}) {
  return getValueFromWeiHex({
    value,
    conversionRate,
    toCurrency: 'ETH',
    numberOfDecimals: 6,
  })
}

export function getValueFromWeiHex ({
  value,
  toCurrency,
  conversionRate,
  numberOfDecimals,
}) {
  return conversionUtil(value, {
    fromNumericBase: 'hex',
    toNumericBase: 'dec',
    fromCurrency: 'ETH',
    toCurrency,
    numberOfDecimals,
    fromDenomination: 'WEI',
    conversionRate,
  })
}