This commit is contained in:
Alexandre Van de Sande 2015-05-22 14:06:32 +00:00
commit 51052c52f5
2 changed files with 114 additions and 82 deletions

File diff suppressed because one or more lines are too long

View file

@ -768,11 +768,18 @@ var BigNumber = require('bignumber.js');
var ETH_UNITS = [ var ETH_UNITS = [
'wei', 'wei',
'Kwei', 'kwei',
'Mwei', 'Mwei',
'Gwei', 'Gwei',
'szabo', 'szabo',
'finney', 'finney',
'femtoether',
'picoether',
'nanoether',
'microether',
'miliether',
'micro',
'mili',
'ether', 'ether',
'grand', 'grand',
'Mether', 'Mether',
@ -870,22 +877,29 @@ module.exports = function (str) {
var BigNumber = require('bignumber.js'); var BigNumber = require('bignumber.js');
var unitMap = { var unitMap = {
'wei': '1', 'wei': '1',
'kwei': '1000', 'kwei': '1000',
'ada': '1000', 'ada': '1000',
'mwei': '1000000', 'femtoether': '1000',
'babbage': '1000000', 'mwei': '1000000',
'gwei': '1000000000', 'babbage': '1000000',
'shannon': '1000000000', 'picoether': '1000000',
'szabo': '1000000000000', 'gwei': '1000000000',
'finney': '1000000000000000', 'shannon': '1000000000',
'ether': '1000000000000000000', 'nanoether': '1000000000',
'kether': '1000000000000000000000', 'szabo': '1000000000000',
'grand': '1000000000000000000000', 'microether': '1000000000000',
'einstein': '1000000000000000000000', 'micro': '1000000000000',
'mether': '1000000000000000000000000', 'finney': '1000000000000000',
'gether': '1000000000000000000000000000', 'miliether': '1000000000000000',
'tether': '1000000000000000000000000000000' 'mili': '1000000000000000',
'ether': '1000000000000000000',
'kether': '1000000000000000000000',
'grand': '1000000000000000000000',
'einstein': '1000000000000000000000',
'mether': '1000000000000000000000000',
'gether': '1000000000000000000000000000',
'tether': '1000000000000000000000000000000'
}; };
/** /**
@ -1073,13 +1087,14 @@ var getValueOfUnit = function (unit) {
* Takes a number of wei and converts it to any other ether unit. * Takes a number of wei and converts it to any other ether unit.
* *
* Possible units are: * Possible units are:
* - kwei/ada * SI Short SI Full Effigy Other
* - mwei/babbage * - kwei femtoether ada
* - gwei/shannon * - mwei picoether babbage
* - szabo * - gwei nanoether shannon
* - finney * - -- microether szabo micro
* - ether * - -- miliether finney mili
* - kether/grand/einstein * - ether -- --
* - kether einstein grand
* - mether * - mether
* - gether * - gether
* - tether * - tether
@ -1099,13 +1114,14 @@ var fromWei = function(number, unit) {
* Takes a number of a unit and converts it to wei. * Takes a number of a unit and converts it to wei.
* *
* Possible units are: * Possible units are:
* - kwei/ada * SI Short SI Full Effigy Other
* - mwei/babbage * - kwei femtoether ada
* - gwei/shannon * - mwei picoether babbage
* - szabo * - gwei nanoether shannon
* - finney * - -- microether szabo micro
* - ether * - -- miliether finney mili
* - kether/grand/einstein * - ether -- --
* - kether einstein grand
* - mether * - mether
* - gether * - gether
* - tether * - tether