web3-utils
Advanced tools
Comparing version 1.7.5 to 1.8.0-rc.0
@@ -282,3 +282,3 @@ /* | ||
* developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | ||
* | ||
* Block tag `safe` and `block number` combination param is not supported | ||
* @method compareBlockNumbers | ||
@@ -293,18 +293,20 @@ * | ||
var compareBlockNumbers = function (a, b) { | ||
if (a == b) { | ||
// Increasing order: (genesis = earliest), safe, (finalized ~ latest), pending | ||
// safe vs block-num cant be compared as block number provided can be on left or right side of safe tag, until safe tag block number is extracted and compared | ||
if (a === b) { | ||
return 0; | ||
} | ||
else if (("genesis" == a || "earliest" == a || 0 == a) && ("genesis" == b || "earliest" == b || 0 == b)) { | ||
else if (("genesis" === a || "earliest" === a || 0 === a) && ("genesis" === b || "earliest" === b || 0 === b)) { | ||
return 0; | ||
} | ||
else if ("genesis" == a || "earliest" == a) { | ||
else if ("genesis" === a || "earliest" === a || a === 0) { | ||
// b !== a, thus a < b | ||
return -1; | ||
} | ||
else if ("genesis" == b || "earliest" == b) { | ||
else if ("genesis" === b || "earliest" === b || b === 0) { | ||
// b !== a, thus a > b | ||
return 1; | ||
} | ||
else if (a == "latest") { | ||
if (b == "pending") { | ||
else if (a === "latest" || a === "finalized") { | ||
if (b === "pending") { | ||
return -1; | ||
@@ -317,4 +319,4 @@ } | ||
} | ||
else if (b === "latest") { | ||
if (a == "pending") { | ||
else if (b === "latest" || b === "finalized") { | ||
if (a === "pending") { | ||
return 1; | ||
@@ -327,9 +329,13 @@ } | ||
} | ||
else if (a == "pending") { | ||
else if (a === "pending") { | ||
// b (== OR <) "latest", thus a > b | ||
return 1; | ||
} | ||
else if (b == "pending") { | ||
else if (b === "pending") { | ||
return -1; | ||
} | ||
else if (a === "safe" || b === "safe") { | ||
// either a or b is "safe" and the other one did not fall into any of the conditions above, so the other one is a number | ||
return undefined; | ||
} | ||
else { | ||
@@ -336,0 +342,0 @@ let bnA = new BN(a); |
{ | ||
"name": "web3-utils", | ||
"version": "1.7.5", | ||
"version": "1.8.0-rc.0", | ||
"description": "Collection of utility functions used in web3.js.", | ||
@@ -29,3 +29,3 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-utils", | ||
}, | ||
"gitHead": "02895cb5b171db83130617abbece47ceda92ea9c" | ||
"gitHead": "09634f9ca4e5be7237fa968057bc60e657338f54" | ||
} |
# web3-utils | ||
[![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url] | ||
[![NPM Package][npm-image]][npm-url] | ||
@@ -40,5 +40,2 @@ This is a sub-package of [web3.js][repo]. | ||
[npm-url]: https://npmjs.org/package/web3-utils | ||
[deps-image]: https://david-dm.org/ethereum/web3.js/1.x/status.svg?path=packages/web3-utils | ||
[deps-url]: https://david-dm.org/ethereum/web3.js/1.x?path=packages/web3-utils | ||
[deps-dev-image]: https://david-dm.org/ethereum/web3.js/1.x/dev-status.svg?path=packages/web3-utils | ||
[deps-dev-url]: https://david-dm.org/ethereum/web3.js/1.x?type=dev&path=packages/web3-utils | ||
@@ -321,3 +321,3 @@ /* | ||
* developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | ||
* | ||
* Block tag `safe` and `block number` combination param is not supported | ||
* @method compareBlockNumbers | ||
@@ -332,14 +332,16 @@ * | ||
var compareBlockNumbers = function(a, b) { | ||
if (a == b) { | ||
// Increasing order: (genesis = earliest), safe, (finalized ~ latest), pending | ||
// safe vs block-num cant be compared as block number provided can be on left or right side of safe tag, until safe tag block number is extracted and compared | ||
if (a === b) { | ||
return 0; | ||
} else if (("genesis" == a || "earliest" == a || 0 == a) && ("genesis" == b || "earliest" == b || 0 == b)) { | ||
} else if (("genesis" === a || "earliest" === a || 0 === a) && ("genesis" === b || "earliest" === b || 0 === b)) { | ||
return 0; | ||
} else if ("genesis" == a || "earliest" == a) { | ||
} else if ("genesis" === a || "earliest" === a || a === 0) { | ||
// b !== a, thus a < b | ||
return -1; | ||
} else if ("genesis" == b || "earliest" == b) { | ||
} else if ("genesis" === b || "earliest" === b || b === 0) { | ||
// b !== a, thus a > b | ||
return 1; | ||
} else if (a == "latest") { | ||
if (b == "pending") { | ||
} else if (a === "latest" || a === "finalized") { | ||
if (b === "pending") { | ||
return -1; | ||
@@ -350,4 +352,4 @@ } else { | ||
} | ||
} else if (b === "latest") { | ||
if (a == "pending") { | ||
} else if (b === "latest" || b === "finalized") { | ||
if (a === "pending") { | ||
return 1; | ||
@@ -358,8 +360,12 @@ } else { | ||
} | ||
} else if (a == "pending") { | ||
} else if (a === "pending") { | ||
// b (== OR <) "latest", thus a > b | ||
return 1; | ||
} else if (b == "pending") { | ||
} else if (b === "pending") { | ||
return -1; | ||
} else { | ||
} else if(a === "safe" || b === "safe") { | ||
// either a or b is "safe" and the other one did not fall into any of the conditions above, so the other one is a number | ||
return undefined; | ||
} | ||
else { | ||
let bnA = new BN(a); | ||
@@ -366,0 +372,0 @@ let bnB = new BN(b); |
@@ -98,4 +98,4 @@ /* | ||
export function padRight(string: string | number, characterAmount: number, sign?: string): string; | ||
export function sha3(value: string | BN): string | null; | ||
export function sha3Raw(value: string | BN): string; | ||
export function sha3(value: string | BN | Buffer): string | null; | ||
export function sha3Raw(value: string | BN | Buffer): string; | ||
export function randomHex(bytesSize: number): string; | ||
@@ -216,3 +216,3 @@ export function utf8ToHex(string: string): string; | ||
export type AbiType = 'function' | 'constructor' | 'event' | 'fallback'; | ||
export type AbiType = 'function' | 'constructor' | 'event' | 'fallback' | 'receive'; | ||
export type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable'; | ||
@@ -219,0 +219,0 @@ |
@@ -29,2 +29,4 @@ /* | ||
// $ExpectType string | ||
sha3Raw(Buffer.from('123')); | ||
// $ExpectType string | ||
sha3Raw(new BN(3)); | ||
@@ -31,0 +33,0 @@ |
@@ -29,2 +29,4 @@ /* | ||
// $ExpectType string | null | ||
sha3(Buffer.from('123')); | ||
// $ExpectType string | null | ||
sha3(new BN(3)); | ||
@@ -31,0 +33,0 @@ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
166375
4853
2
41