@harmony-js/utils
Advanced tools
Comparing version 0.1.28 to 0.1.35
@@ -216,2 +216,3 @@ /** | ||
Units["ether"] = "ether"; | ||
Units["one"] = "one"; | ||
Units["Kether"] = "Kether"; | ||
@@ -230,2 +231,3 @@ Units["Mether"] = "Mether"; | ||
["ether" /* ether */, '1000000000000000000'], | ||
["one" /* one */, '1000000000000000000'], | ||
["Kether" /* Kether */, '1000000000000000000000'], | ||
@@ -435,2 +437,5 @@ ["Mether" /* Mether */, '1000000000000000000000000'], | ||
}; | ||
Unit.One = function (str) { | ||
return new Unit(str).asOne(); | ||
}; | ||
Unit.Kether = function (str) { | ||
@@ -476,2 +481,6 @@ return new Unit(str).asKether(); | ||
}; | ||
Unit.prototype.asOne = function () { | ||
this.wei = toWei(this.unit, "one" /* one */); | ||
return this; | ||
}; | ||
Unit.prototype.asKether = function () { | ||
@@ -549,2 +558,10 @@ this.wei = toWei(this.unit, "Kether" /* Kether */); | ||
}; | ||
Unit.prototype.toOne = function () { | ||
if (this.wei) { | ||
return fromWei(this.wei, "one" /* one */); | ||
} | ||
else { | ||
throw new Error('error transforming'); | ||
} | ||
}; | ||
Unit.prototype.toKether = function () { | ||
@@ -551,0 +568,0 @@ if (this.wei) { |
@@ -212,2 +212,3 @@ /** | ||
Units["ether"] = "ether"; | ||
Units["one"] = "one"; | ||
Units["Kether"] = "Kether"; | ||
@@ -226,2 +227,3 @@ Units["Mether"] = "Mether"; | ||
["ether" /* ether */, '1000000000000000000'], | ||
["one" /* one */, '1000000000000000000'], | ||
["Kether" /* Kether */, '1000000000000000000000'], | ||
@@ -431,2 +433,5 @@ ["Mether" /* Mether */, '1000000000000000000000000'], | ||
}; | ||
Unit.One = function (str) { | ||
return new Unit(str).asOne(); | ||
}; | ||
Unit.Kether = function (str) { | ||
@@ -472,2 +477,6 @@ return new Unit(str).asKether(); | ||
}; | ||
Unit.prototype.asOne = function () { | ||
this.wei = toWei(this.unit, "one" /* one */); | ||
return this; | ||
}; | ||
Unit.prototype.asKether = function () { | ||
@@ -545,2 +554,10 @@ this.wei = toWei(this.unit, "Kether" /* Kether */); | ||
}; | ||
Unit.prototype.toOne = function () { | ||
if (this.wei) { | ||
return fromWei(this.wei, "one" /* one */); | ||
} | ||
else { | ||
throw new Error('error transforming'); | ||
} | ||
}; | ||
Unit.prototype.toKether = function () { | ||
@@ -547,0 +564,0 @@ if (this.wei) { |
@@ -216,2 +216,3 @@ /** | ||
Units["ether"] = "ether"; | ||
Units["one"] = "one"; | ||
Units["Kether"] = "Kether"; | ||
@@ -230,2 +231,3 @@ Units["Mether"] = "Mether"; | ||
["ether" /* ether */, '1000000000000000000'], | ||
["one" /* one */, '1000000000000000000'], | ||
["Kether" /* Kether */, '1000000000000000000000'], | ||
@@ -435,2 +437,5 @@ ["Mether" /* Mether */, '1000000000000000000000000'], | ||
}; | ||
Unit.One = function (str) { | ||
return new Unit(str).asOne(); | ||
}; | ||
Unit.Kether = function (str) { | ||
@@ -476,2 +481,6 @@ return new Unit(str).asKether(); | ||
}; | ||
Unit.prototype.asOne = function () { | ||
this.wei = toWei(this.unit, "one" /* one */); | ||
return this; | ||
}; | ||
Unit.prototype.asKether = function () { | ||
@@ -549,2 +558,10 @@ this.wei = toWei(this.unit, "Kether" /* Kether */); | ||
}; | ||
Unit.prototype.toOne = function () { | ||
if (this.wei) { | ||
return fromWei(this.wei, "one" /* one */); | ||
} | ||
else { | ||
throw new Error('error transforming'); | ||
} | ||
}; | ||
Unit.prototype.toKether = function () { | ||
@@ -551,0 +568,0 @@ if (this.wei) { |
@@ -10,2 +10,3 @@ import BN from 'bn.js'; | ||
ether = "ether", | ||
one = "one", | ||
Kether = "Kether", | ||
@@ -35,2 +36,3 @@ Mether = "Mether", | ||
static Ether(str: BN | string): Unit; | ||
static One(str: BN | string): Unit; | ||
static Kether(str: BN | string): Unit; | ||
@@ -50,2 +52,3 @@ static Mether(str: BN | string): Unit; | ||
asEther(): this; | ||
asOne(): this; | ||
asKether(): this; | ||
@@ -62,2 +65,3 @@ asMether(): this; | ||
toEther(): string; | ||
toOne(): string; | ||
toKether(): string; | ||
@@ -64,0 +68,0 @@ toMether(): string; |
@@ -15,2 +15,3 @@ "use strict"; | ||
Units["ether"] = "ether"; | ||
Units["one"] = "one"; | ||
Units["Kether"] = "Kether"; | ||
@@ -29,2 +30,3 @@ Units["Mether"] = "Mether"; | ||
["ether" /* ether */, '1000000000000000000'], | ||
["one" /* one */, '1000000000000000000'], | ||
["Kether" /* Kether */, '1000000000000000000000'], | ||
@@ -234,2 +236,5 @@ ["Mether" /* Mether */, '1000000000000000000000000'], | ||
}; | ||
Unit.One = function (str) { | ||
return new Unit(str).asOne(); | ||
}; | ||
Unit.Kether = function (str) { | ||
@@ -275,2 +280,6 @@ return new Unit(str).asKether(); | ||
}; | ||
Unit.prototype.asOne = function () { | ||
this.wei = exports.toWei(this.unit, "one" /* one */); | ||
return this; | ||
}; | ||
Unit.prototype.asKether = function () { | ||
@@ -348,2 +357,10 @@ this.wei = exports.toWei(this.unit, "Kether" /* Kether */); | ||
}; | ||
Unit.prototype.toOne = function () { | ||
if (this.wei) { | ||
return exports.fromWei(this.wei, "one" /* one */); | ||
} | ||
else { | ||
throw new Error('error transforming'); | ||
} | ||
}; | ||
Unit.prototype.toKether = function () { | ||
@@ -350,0 +367,0 @@ if (this.wei) { |
{ | ||
"name": "@harmony-js/utils", | ||
"version": "0.1.28", | ||
"version": "0.1.35", | ||
"description": "utils for harmony", | ||
@@ -24,3 +24,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "1ccc7071aee39a4597caa1019c36104420499af9" | ||
"gitHead": "cc00c23e9a5da76ad044490827995f1e5c66781e" | ||
} |
@@ -12,2 +12,3 @@ import BN from 'bn.js'; | ||
ether = 'ether', | ||
one = 'one', | ||
Kether = 'Kether', | ||
@@ -27,2 +28,3 @@ Mether = 'Mether', | ||
[Units.ether, '1000000000000000000'], // 1e18 wei | ||
[Units.one, '1000000000000000000'], // 1e18 wei | ||
[Units.Kether, '1000000000000000000000'], // 1e21 wei | ||
@@ -238,2 +240,5 @@ [Units.Mether, '1000000000000000000000000'], // 1e24 wei | ||
} | ||
static One(str: BN | string) { | ||
return new Unit(str).asOne(); | ||
} | ||
static Kether(str: BN | string) { | ||
@@ -297,2 +302,6 @@ return new Unit(str).asKether(); | ||
} | ||
asOne() { | ||
this.wei = toWei(this.unit, Units.one); | ||
return this; | ||
} | ||
asKether() { | ||
@@ -365,2 +374,9 @@ this.wei = toWei(this.unit, Units.Kether); | ||
} | ||
toOne() { | ||
if (this.wei) { | ||
return fromWei(this.wei, Units.one); | ||
} else { | ||
throw new Error('error transforming'); | ||
} | ||
} | ||
toKether() { | ||
@@ -367,0 +383,0 @@ if (this.wei) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
336731
4815