diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 5e510572e..9801bc89f 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -48,7 +48,7 @@ static const vector> g_units = {((u256(1000000000) * 1000000000) * 1000000000) * 1000, "Tether"}, {(u256(1000000000) * 1000000000) * 1000000000, "Gether"}, {(u256(1000000000) * 1000000000) * 1000000, "Mether"}, - {(u256(1000000000) * 1000000000) * 1000, "Kether"}, + {(u256(1000000000) * 1000000000) * 1000, "grand"}, {u256(1000000000) * 1000000000, "ether"}, {u256(1000000000) * 1000000, "finney"}, {u256(1000000000) * 1000, "szabo"}, diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index be7db8434..704e354a2 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -48,7 +48,7 @@ std::vector> const& units(); using LogBloom = h512; // The various denominations; here for ease of use where needed within code. -static const u256 Uether = ((((u256(1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000; +/*static const u256 Uether = ((((u256(1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000; static const u256 Vether = ((((u256(1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000; static const u256 Dether = ((((u256(1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000; static const u256 Nether = (((u256(1000000000) * 1000000000) * 1000000000) * 1000000000) * 1000000000; @@ -59,13 +59,13 @@ static const u256 Pether = ((u256(1000000000) * 1000000000) * 1000000000) * 1000 static const u256 Tether = ((u256(1000000000) * 1000000000) * 1000000000) * 1000; static const u256 Gether = (u256(1000000000) * 1000000000) * 1000000000; static const u256 Mether = (u256(1000000000) * 1000000000) * 1000000; -static const u256 Kether = (u256(1000000000) * 1000000000) * 1000; +static const u256 grand = (u256(1000000000) * 1000000000) * 1000;*/ static const u256 ether = u256(1000000000) * 1000000000; static const u256 finney = u256(1000000000) * 1000000; static const u256 szabo = u256(1000000000) * 1000; -static const u256 Gwei = u256(1000000000); +/*static const u256 Gwei = u256(1000000000); static const u256 Mwei = u256(1000000); -static const u256 Kwei = u256(1000); +static const u256 Kwei = u256(1000);*/ static const u256 wei = u256(1); } diff --git a/libjsqrc/ethereum.js b/libjsqrc/ethereum.js index cc8afc932..0a27f3905 100644 --- a/libjsqrc/ethereum.js +++ b/libjsqrc/ethereum.js @@ -714,6 +714,25 @@ var web3 = { return "0x" + hex; }, + toEth: function(str) { + var val = parseInt(str, 16); + var unit = 0; + var units = [ 'wei', 'Kwei', 'Mwei', 'Gwei', 'szabo', 'finney', 'ether', 'grand', 'Mether', 'Gether', 'Tether', 'Pether', 'Eether', 'Zether', 'Yether', 'Nether', 'Dether', 'Vether', 'Uether' ]; + while (val > 3000 && unit < units.length - 1) + { + val /= 1000; + unit++; + } + var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2); + while (true) { + var o = s; + s = s.replace(/(\d)(\d\d\d[\.\,])/, function($0, $1, $2) { return $1 + ',' + $2; }); + if (o == s) + break; + } + return s + ' ' + units[unit]; + }, + eth: { prototype: Object(), // jshint ignore:line watch: function (params) { @@ -1065,4 +1084,4 @@ module.exports = web3; },{"./lib/autoprovider":2,"./lib/contract":3,"./lib/httprpc":4,"./lib/main":5,"./lib/qt":6,"./lib/websocket":7}]},{},[]) -//# sourceMappingURL=ethereum.js.map \ No newline at end of file +//# sourceMappingURL=ethereum.js.map