Skip to content

Commit

Permalink
Updated dist files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jan 11, 2020
1 parent 384923c commit 0b2c167
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 177 deletions.
4 changes: 2 additions & 2 deletions dist/ethers-all.esm.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/ethers-all.umd.min.js

Large diffs are not rendered by default.

169 changes: 89 additions & 80 deletions dist/ethers.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3725,7 +3725,7 @@ var lib_esm = /*#__PURE__*/Object.freeze({
Logger: Logger
});

const version$1 = "bytes/5.0.0-beta.135";
const version$1 = "bytes/5.0.0-beta.136";

"use strict";
const logger = new Logger(version$1);
Expand Down Expand Up @@ -3993,16 +3993,21 @@ function splitSignature(signature) {
if (bytes.length !== 65) {
logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature);
}
// Get the r and s
// Get the r, s and v
result.r = hexlify(bytes.slice(0, 32));
result.s = hexlify(bytes.slice(32, 64));
// Reduce v to the canonical 27 or 28
result.v = bytes[64];
if (result.v !== 27 && result.v !== 28) {
result.v = 27 + (result.v % 2);
}
// Compute recoveryParam from v
result.recoveryParam = (result.v - 27);
result.recoveryParam = 1 - (result.v % 2);
// Allow a recid to be used as the v
if (result.v < 27) {
if (result.v === 0 || result.v === 1) {
result.v += 27;
}
else {
logger.throwArgumentError("signature invalid v byte", "signature", signature);
}
}
// Compute _vs from recoveryParam and s
if (result.recoveryParam) {
bytes[32] |= 0x80;
Expand All @@ -4015,83 +4020,78 @@ function splitSignature(signature) {
result.v = signature.v;
result.recoveryParam = signature.recoveryParam;
result._vs = signature._vs;
// Normalize v into a canonical 27 or 28
if (result.v != null && !(result.v == 27 || result.v == 28)) {
result.v = 27 + (result.v % 2);
}
// Populate a missing v or recoveryParam if possible
if (result.recoveryParam == null && result.v != null) {
result.recoveryParam = 1 - (result.v % 2);
}
else if (result.recoveryParam != null && result.v == null) {
result.v = 27 + result.recoveryParam;
}
else if (result.recoveryParam != null && result.v != null) {
if (result.v !== 27 + result.recoveryParam) {
logger.throwArgumentError("signature v mismatch recoveryParam", "signature", signature);
}
}
// Make sure r and s are padded properly
if (result.r != null) {
result.r = hexZeroPad(result.r, 32);
}
if (result.s != null) {
result.s = hexZeroPad(result.s, 32);
}
// If the _vs is available, use it to populate missing s, v and recoveryParam
// and verify non-missing s, v and recoveryParam
if (result._vs != null) {
result._vs = hexZeroPad(result._vs, 32);
if (result._vs.length > 66) {
logger.throwArgumentError("signature _vs overflow", "signature", signature);
}
const vs = arrayify(result._vs);
const vs = zeroPad(arrayify(result._vs), 32);
result._vs = hexlify(vs);
// Set or check the recid
const recoveryParam = ((vs[0] >= 128) ? 1 : 0);
const v = 27 + result.recoveryParam;
// Use _vs to compute s
if (result.recoveryParam == null) {
result.recoveryParam = recoveryParam;
}
else if (result.recoveryParam !== recoveryParam) {
logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature);
}
// Set or check the s
vs[0] &= 0x7f;
const s = hexlify(vs);
// Check _vs aggress with other parameters
if (result.s == null) {
result.s = s;
}
else if (result.s !== s) {
logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
}
}
// Use recid and v to populate each other
if (result.recoveryParam == null) {
if (result.v == null) {
result.v = v;
logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature);
}
else if (result.v !== v) {
logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
else {
result.recoveryParam = 1 - (result.v % 2);
}
if (recoveryParam == null) {
result.recoveryParam = recoveryParam;
}
else {
if (result.v == null) {
result.v = 27 + result.recoveryParam;
}
else if (result.recoveryParam !== recoveryParam) {
logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature);
else if (result.recoveryParam !== (1 - (result.v % 2))) {
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature);
}
}
// After all populating, both v and recoveryParam are still missing...
if (result.v == null && result.recoveryParam == null) {
logger.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature);
if (result.r == null || !isHexString(result.r)) {
logger.throwArgumentError("signature missing or invalid r", "signature", signature);
}
// Check for canonical v
if (result.v !== 27 && result.v !== 28) {
logger.throwArgumentError("signature v not canonical", "signature", signature);
else {
result.r = hexZeroPad(result.r, 32);
}
// Check that r and s are in range
if (result.r.length > 66 || result.s.length > 66) {
logger.throwArgumentError("signature overflow r or s", "signature", signature);
if (result.s == null || !isHexString(result.s)) {
logger.throwArgumentError("signature missing or invalid s", "signature", signature);
}
if (result._vs == null) {
const vs = arrayify(result.s);
if (vs[0] >= 128) {
logger.throwArgumentError("signature s out of range", "signature", signature);
}
if (result.recoveryParam) {
vs[0] |= 0x80;
else {
result.s = hexZeroPad(result.s, 32);
}
const vs = arrayify(result.s);
if (vs[0] >= 128) {
logger.throwArgumentError("signature s out of range", "signature", signature);
}
if (result.recoveryParam) {
vs[0] |= 0x80;
}
const _vs = hexlify(vs);
if (result._vs) {
if (!isHexString(result._vs)) {
logger.throwArgumentError("signature invalid _vs", "signature", signature);
}
result._vs = hexlify(vs);
result._vs = hexZeroPad(result._vs, 32);
}
// Set or check the _vs
if (result._vs == null) {
result._vs = _vs;
}
else if (result._vs !== _vs) {
logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature);
}
}
return result;
Expand Down Expand Up @@ -16092,7 +16092,7 @@ function poll(func, options) {
});
}

const version$j = "providers/5.0.0-beta.147";
const version$j = "providers/5.0.0-beta.148";

"use strict";
const logger$m = new Logger(version$j);
Expand Down Expand Up @@ -16355,25 +16355,34 @@ class Formatter {
}
*/
let result = Formatter.check(this.formats.transaction, transaction);
let networkId = transaction.networkId;
// geth-etc returns chainId
if (transaction.chainId != null && networkId == null && result.v == null) {
networkId = transaction.chainId;
}
if (isHexString(networkId)) {
networkId = BigNumber.from(networkId).toNumber();
}
if (typeof (networkId) !== "number" && result.v != null) {
networkId = (result.v - 35) / 2;
if (networkId < 0) {
networkId = 0;
if (transaction.chainId != null) {
let chainId = transaction.chainId;
if (isHexString(chainId)) {
chainId = BigNumber.from(chainId).toNumber();
}
networkId = parseInt(networkId);
result.chainId = chainId;
}
if (typeof (networkId) !== "number") {
networkId = 0;
else {
let chainId = transaction.networkId;
// geth-etc returns chainId
if (chainId == null && result.v == null) {
chainId = transaction.chainId;
}
if (isHexString(chainId)) {
chainId = BigNumber.from(chainId).toNumber();
}
if (typeof (chainId) !== "number" && result.v != null) {
chainId = (result.v - 35) / 2;
if (chainId < 0) {
chainId = 0;
}
chainId = parseInt(chainId);
}
if (typeof (chainId) !== "number") {
chainId = 0;
}
result.chainId = chainId;
}
result.networkId = networkId;
// 0x0000... should actually be null
if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") {
result.blockHash = null;
Expand Down Expand Up @@ -18993,7 +19002,7 @@ var utils$1 = /*#__PURE__*/Object.freeze({
Indexed: Indexed
});

const version$l = "ethers/5.0.0-beta.166";
const version$l = "ethers/5.0.0-beta.167";

"use strict";
const errors = Logger.errors;
Expand Down
4 changes: 2 additions & 2 deletions dist/ethers.esm.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 0b2c167

Please sign in to comment.