@ethersproject/bytes
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -1,2 +0,2 @@ | ||
export declare const version = "bytes/5.4.0"; | ||
export declare const version = "bytes/5.5.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "bytes/5.4.0"; | ||
export const version = "bytes/5.5.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -22,2 +22,5 @@ "use strict"; | ||
} | ||
function isInteger(value) { | ||
return (typeof (value) === "number" && value == value && (value % 1) === 0); | ||
} | ||
export function isBytes(value) { | ||
@@ -33,3 +36,3 @@ if (value == null) { | ||
} | ||
if (value.length == null) { | ||
if (!isInteger(value.length) || value.length < 0) { | ||
return false; | ||
@@ -39,3 +42,3 @@ } | ||
const v = value[i]; | ||
if (typeof (v) !== "number" || v < 0 || v >= 256 || (v % 1)) { | ||
if (!isInteger(v) || v < 0 || v >= 256) { | ||
return false; | ||
@@ -345,4 +348,7 @@ } | ||
} | ||
else if (result.recoveryParam !== (1 - (result.v % 2))) { | ||
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); | ||
else { | ||
const recId = (result.v === 0 || result.v === 1) ? result.v : (1 - (result.v % 2)); | ||
if (result.recoveryParam !== recId) { | ||
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); | ||
} | ||
} | ||
@@ -349,0 +355,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare const version = "bytes/5.4.0"; | ||
export declare const version = "bytes/5.5.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "bytes/5.4.0"; | ||
exports.version = "bytes/5.5.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -25,2 +25,5 @@ "use strict"; | ||
exports.isBytesLike = isBytesLike; | ||
function isInteger(value) { | ||
return (typeof (value) === "number" && value == value && (value % 1) === 0); | ||
} | ||
function isBytes(value) { | ||
@@ -36,3 +39,3 @@ if (value == null) { | ||
} | ||
if (value.length == null) { | ||
if (!isInteger(value.length) || value.length < 0) { | ||
return false; | ||
@@ -42,3 +45,3 @@ } | ||
var v = value[i]; | ||
if (typeof (v) !== "number" || v < 0 || v >= 256 || (v % 1)) { | ||
if (!isInteger(v) || v < 0 || v >= 256) { | ||
return false; | ||
@@ -361,4 +364,7 @@ } | ||
} | ||
else if (result.recoveryParam !== (1 - (result.v % 2))) { | ||
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); | ||
else { | ||
var recId = (result.v === 0 || result.v === 1) ? result.v : (1 - (result.v % 2)); | ||
if (result.recoveryParam !== recId) { | ||
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); | ||
} | ||
} | ||
@@ -365,0 +371,0 @@ } |
{ | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"dependencies": { | ||
"@ethersproject/logger": "^5.4.0" | ||
"@ethersproject/logger": "^5.5.0" | ||
}, | ||
@@ -18,3 +18,3 @@ "description": "Bytes utility functions for ethers.", | ||
], | ||
"gitHead": "c2c0ce75039e7256b287f9a764188d08ed0b7296", | ||
"gitHead": "5899c8aec0600dca42d7e24fc215037aa48917f2", | ||
"keywords": [ | ||
@@ -42,5 +42,5 @@ "Ethereum", | ||
"sideEffects": false, | ||
"tarballHash": "0x16bcd0fa081ba271873675e4a95cf89a43c909f3269cf41711346cc50274c041", | ||
"tarballHash": "0x1daef684cc067d9e39c56da0288767a1d0d210074513e60fac0b86d8243278fc", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.4.0" | ||
"version": "5.5.0" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "bytes/5.4.0"; | ||
export const version = "bytes/5.5.0"; |
@@ -73,2 +73,6 @@ "use strict"; | ||
function isInteger(value: number) { | ||
return (typeof(value) === "number" && value == value && (value % 1) === 0); | ||
} | ||
export function isBytes(value: any): value is Bytes { | ||
@@ -79,9 +83,7 @@ if (value == null) { return false; } | ||
if (typeof(value) === "string") { return false; } | ||
if (value.length == null) { return false; } | ||
if (!isInteger(value.length) || value.length < 0) { return false; } | ||
for (let i = 0; i < value.length; i++) { | ||
const v = value[i]; | ||
if (typeof(v) !== "number" || v < 0 || v >= 256 || (v % 1)) { | ||
return false; | ||
} | ||
if (!isInteger(v) || v < 0 || v >= 256) { return false; } | ||
} | ||
@@ -409,4 +411,7 @@ return true; | ||
result.v = 27 + result.recoveryParam; | ||
} else if (result.recoveryParam !== (1 - (result.v % 2))) { | ||
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); | ||
} else { | ||
const recId = (result.v === 0 || result.v === 1) ? result.v :(1 - (result.v % 2)); | ||
if (result.recoveryParam !== recId) { | ||
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); | ||
} | ||
} | ||
@@ -413,0 +418,0 @@ } |
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
78276
1262
Updated@ethersproject/logger@^5.5.0