mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
Merge branch 'develop' into strings
Conflicts: dist/web3-light.js dist/web3-light.min.js dist/web3.js dist/web3.min.js
This commit is contained in:
commit
8c6f9769e0
50
dist/web3-light.js
vendored
50
dist/web3-light.js
vendored
File diff suppressed because one or more lines are too long
4
dist/web3-light.min.js
vendored
4
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
50
dist/web3.js
vendored
50
dist/web3.js
vendored
File diff suppressed because one or more lines are too long
4
dist/web3.min.js
vendored
4
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -38,11 +38,19 @@ var BigNumber = require('bignumber.js');
|
||||
|
||||
var ETH_UNITS = [
|
||||
'wei',
|
||||
'Kwei',
|
||||
'kwei',
|
||||
'Mwei',
|
||||
'Gwei',
|
||||
'szabo',
|
||||
'finney',
|
||||
'femtoether',
|
||||
'picoether',
|
||||
'nanoether',
|
||||
'microether',
|
||||
'milliether',
|
||||
'nano',
|
||||
'micro',
|
||||
'milli',
|
||||
'ether',
|
||||
'grand',
|
||||
'Mether',
|
||||
|
@ -39,12 +39,20 @@ var unitMap = {
|
||||
'wei': '1',
|
||||
'kwei': '1000',
|
||||
'ada': '1000',
|
||||
'femtoether': '1000',
|
||||
'mwei': '1000000',
|
||||
'babbage': '1000000',
|
||||
'picoether': '1000000',
|
||||
'gwei': '1000000000',
|
||||
'shannon': '1000000000',
|
||||
'nanoether': '1000000000',
|
||||
'nano': '1000000000',
|
||||
'szabo': '1000000000000',
|
||||
'microether': '1000000000000',
|
||||
'micro': '1000000000000',
|
||||
'finney': '1000000000000000',
|
||||
'milliether': '1000000000000000',
|
||||
'milli': '1000000000000000',
|
||||
'ether': '1000000000000000000',
|
||||
'kether': '1000000000000000000000',
|
||||
'grand': '1000000000000000000000',
|
||||
@ -248,13 +256,14 @@ var getValueOfUnit = function (unit) {
|
||||
* Takes a number of wei and converts it to any other ether unit.
|
||||
*
|
||||
* Possible units are:
|
||||
* - kwei/ada
|
||||
* - mwei/babbage
|
||||
* - gwei/shannon
|
||||
* - szabo
|
||||
* - finney
|
||||
* - ether
|
||||
* - kether/grand/einstein
|
||||
* SI Short SI Full Effigy Other
|
||||
* - kwei femtoether ada
|
||||
* - mwei picoether babbage
|
||||
* - gwei nanoether shannon nano
|
||||
* - -- microether szabo micro
|
||||
* - -- milliether finney milli
|
||||
* - ether -- --
|
||||
* - kether einstein grand
|
||||
* - mether
|
||||
* - gether
|
||||
* - tether
|
||||
@ -274,13 +283,14 @@ var fromWei = function(number, unit) {
|
||||
* Takes a number of a unit and converts it to wei.
|
||||
*
|
||||
* Possible units are:
|
||||
* - kwei/ada
|
||||
* - mwei/babbage
|
||||
* - gwei/shannon
|
||||
* - szabo
|
||||
* - finney
|
||||
* - ether
|
||||
* - kether/grand/einstein
|
||||
* SI Short SI Full Effigy Other
|
||||
* - kwei femtoether ada
|
||||
* - mwei picoether babbage
|
||||
* - gwei nanoether shannon nano
|
||||
* - -- microether szabo micro
|
||||
* - -- milliether finney milli
|
||||
* - ether -- --
|
||||
* - kether einstein grand
|
||||
* - mether
|
||||
* - gether
|
||||
* - tether
|
||||
|
@ -19,6 +19,14 @@ describe('lib/utils/utils', function () {
|
||||
assert.equal(utils.toWei(1, 'gether'), '1000000000000000000000000000');
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user