Merge pull request #224 from alexvandesande/prefix-name-reorg

Prefix name reorg
This commit is contained in:
Fabian Vogelsteller 2015-06-03 17:16:05 +02:00
commit 61f1ba6dda
3 changed files with 76 additions and 50 deletions

View File

@ -36,26 +36,34 @@
/// required to define ETH_BIGNUMBER_ROUNDING_MODE /// required to define ETH_BIGNUMBER_ROUNDING_MODE
var BigNumber = require('bignumber.js'); var BigNumber = require('bignumber.js');
var ETH_UNITS = [ var ETH_UNITS = [
'wei', 'wei',
'Kwei', 'kwei',
'Mwei', 'Mwei',
'Gwei', 'Gwei',
'szabo', 'szabo',
'finney', 'finney',
'ether', 'femtoether',
'grand', 'picoether',
'Mether', 'nanoether',
'Gether', 'microether',
'Tether', 'milliether',
'Pether', 'nano',
'Eether', 'micro',
'Zether', 'milli',
'Yether', 'ether',
'Nether', 'grand',
'Dether', 'Mether',
'Vether', 'Gether',
'Uether' 'Tether',
'Pether',
'Eether',
'Zether',
'Yether',
'Nether',
'Dether',
'Vether',
'Uether'
]; ];
module.exports = { module.exports = {

View File

@ -36,22 +36,30 @@
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', 'nano': '1000000000',
'grand': '1000000000000000000000', 'szabo': '1000000000000',
'einstein': '1000000000000000000000', 'microether': '1000000000000',
'mether': '1000000000000000000000000', 'micro': '1000000000000',
'gether': '1000000000000000000000000000', 'finney': '1000000000000000',
'tether': '1000000000000000000000000000000' 'milliether': '1000000000000000',
'milli': '1000000000000000',
'ether': '1000000000000000000',
'kether': '1000000000000000000000',
'grand': '1000000000000000000000',
'einstein': '1000000000000000000000',
'mether': '1000000000000000000000000',
'gether': '1000000000000000000000000000',
'tether': '1000000000000000000000000000000'
}; };
/** /**
@ -239,13 +247,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 nano
* - finney * - -- microether szabo micro
* - ether * - -- milliether finney milli
* - kether/grand/einstein * - ether -- --
* - kether einstein grand
* - mether * - mether
* - gether * - gether
* - tether * - tether
@ -265,13 +274,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 nano
* - finney * - -- microether szabo micro
* - ether * - -- milliether finney milli
* - kether/grand/einstein * - ether -- --
* - kether einstein grand
* - mether * - mether
* - gether * - gether
* - tether * - tether

View File

@ -19,6 +19,14 @@ describe('lib/utils/utils', function () {
assert.equal(utils.toWei(1, 'gether'), '1000000000000000000000000000'); assert.equal(utils.toWei(1, 'gether'), '1000000000000000000000000000');
assert.equal(utils.toWei(1, 'tether'), '1000000000000000000000000000000'); assert.equal(utils.toWei(1, 'tether'), '1000000000000000000000000000000');
assert.equal(utils.toWei(1, 'kwei'), utils.toWei(1, 'femtoether'));
assert.equal(utils.toWei(1, 'babbage'), utils.toWei(1, 'picoether'));
assert.equal(utils.toWei(1, 'shannon'), utils.toWei(1, 'nanoether'));
assert.equal(utils.toWei(1, 'szabo'), utils.toWei(1, 'microether'));
assert.equal(utils.toWei(1, 'finney'), utils.toWei(1, 'milliether'));
assert.equal(utils.toWei(1, 'milli'), utils.toWei(1, 'milliether'));
assert.equal(utils.toWei(1, 'milli'), utils.toWei(1000, 'micro'));
assert.throws(function () {utils.toWei(1, 'wei1');}, Error); assert.throws(function () {utils.toWei(1, 'wei1');}, Error);
}); });
}); });