eth-lib
Advanced tools
Comparing version 0.2.5 to 0.2.7
@@ -43,4 +43,4 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
v = _ref2[0], | ||
r = _ref2[1], | ||
s = _ref2[2]; | ||
r = Bytes.pad(32, _ref2[1]), | ||
s = Bytes.pad(32, _ref2[2]); | ||
@@ -47,0 +47,0 @@ return Bytes.flatten([r, s, v]); |
@@ -12,2 +12,5 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var baseDefaults = [tx.chainId || rpc("net_version", []), tx.gasPrice || rpc("eth_gasPrice", []), tx.nonce || rpc("eth_getTransactionCount", [tx.from, "latest"]), tx.value || "0x0", tx.data || "0x"]; | ||
var noAddress = function noAddress(address) { | ||
return !address || address === "" || address === "0x"; | ||
}; | ||
return Promise.all(baseDefaults).then(function (_ref) { | ||
@@ -22,7 +25,5 @@ var _ref2 = _slicedToArray(_ref, 5), | ||
var chainId = Nat.fromNumber(chainIdNum); | ||
var from = tx.from; | ||
var to = tx.to === "" || tx.to === "0x" ? null : tx.to; | ||
var gasEstimator = tx.gas ? Promise.resolve(null) : rpc("eth_estimateGas", [{ | ||
from: tx.from, | ||
to: tx.to, | ||
from: noAddress(tx.from) ? null : tx.from, | ||
to: noAddress(tx.to) ? null : tx.to, | ||
value: tx.value, | ||
@@ -33,6 +34,9 @@ nonce: tx.nonce, | ||
return gasEstimator.then(function (gasEstimate) { | ||
if (gasEstimate.error) { | ||
throw gasEstimate.error; | ||
} | ||
return { | ||
chainId: chainId, | ||
from: from ? from.toLowerCase() : null, | ||
to: to ? to.toLowerCase() : null, | ||
from: noAddress(tx.from) ? "0x" : tx.from.toLowerCase(), | ||
to: noAddress(tx.to) ? "0x" : to.toLowerCase(), | ||
gasPrice: gasPrice, | ||
@@ -39,0 +43,0 @@ gas: tx.gas ? tx.gas : Nat.div(Nat.mul(gasEstimate, "0x6"), "0x5"), |
{ | ||
"name": "eth-lib", | ||
"version": "0.2.5", | ||
"version": "0.2.7", | ||
"description": "Lightweight Ethereum libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -16,11 +16,10 @@ const Account = require("./account"); | ||
]; | ||
const noAddress = address => !address || address === "" || address === "0x"; | ||
return Promise.all(baseDefaults).then(([chainIdNum, gasPrice, nonce, value, data]) => { | ||
var chainId = Nat.fromNumber(chainIdNum); | ||
var from = tx.from; | ||
var to = tx.to === "" || tx.to === "0x" ? null : tx.to; | ||
var gasEstimator = tx.gas | ||
? Promise.resolve(null) | ||
: rpc("eth_estimateGas", [{ | ||
from: tx.from, | ||
to: tx.to, | ||
from: noAddress(tx.from) ? null : tx.from, | ||
to: noAddress(tx.to) ? null : tx.to, | ||
value: tx.value, | ||
@@ -31,6 +30,9 @@ nonce: tx.nonce, | ||
return gasEstimator.then(gasEstimate => { | ||
if (gasEstimate.error) { | ||
throw gasEstimate.error; | ||
} | ||
return { | ||
chainId: chainId, | ||
from: from ? from.toLowerCase() : null, | ||
to: to ? to.toLowerCase() : null, | ||
from: noAddress(tx.from) ? "0x" : tx.from.toLowerCase(), | ||
to: noAddress(tx.to) ? "0x" : to.toLowerCase(), | ||
gasPrice: gasPrice, | ||
@@ -37,0 +39,0 @@ gas: tx.gas ? tx.gas : Nat.div(Nat.mul(gasEstimate, "0x6"), "0x5"), |
@@ -5,3 +5,3 @@ const assert = require("assert"); | ||
const ref = {rlp: require("rlp")}; | ||
const F = require("./../src/types.js"); | ||
// const F = require("./../src/types.js"); | ||
const Nat = require("./../src/Nat.js"); | ||
@@ -8,0 +8,0 @@ const Account = require("./../src/account.js"); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
87002
37
2475
1