Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-utils

Package Overview
Dependencies
Maintainers
2
Versions
494
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-utils - npm Package Compare versions

Comparing version 1.2.11 to 1.3.0-rc.0

lib/index.js

7

package.json
{
"name": "web3-utils",
"version": "1.2.11",
"version": "1.3.0-rc.0",
"description": "Collection of utility functions used in web3.js.",

@@ -12,5 +12,6 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-utils",

"scripts": {
"tsc": "tsc -b tsconfig.json",
"dtslint": "dtslint --localTs ../../node_modules/typescript/lib types"
},
"main": "src/index.js",
"main": "lib/index.js",
"dependencies": {

@@ -30,3 +31,3 @@ "bn.js": "^4.11.9",

},
"gitHead": "87e668275ac7d9b8af7c909137fc0626c3866929"
"gitHead": "83c9f65c7cb3b4f4532f890ec5a3608fd1879e35"
}

@@ -30,5 +30,5 @@ /*

var randombytes = require('randombytes');
var BN = require('bn.js');
/**

@@ -310,3 +310,3 @@ * Fires an error in an event emitter and callback and returns the eventemitter

for (var i = 0; i < address.length; i++ ) {
// If ith character is 9 to f then make it uppercase
// If ith character is 8 to f then make it uppercase
if (parseInt(addressHash[i], 16) > 7) {

@@ -321,2 +321,58 @@ checksumAddress += address[i].toUpperCase();

/**
* Returns -1 if a<b, 1 if a>b; 0 if a == b.
* For more details on this type of function, see
* developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
*
* @method compareBlockNumbers
*
* @param {String|Number|BN} a
*
* @param {String|Number|BN} b
*
* @returns {Number} -1, 0, or 1
*/
var compareBlockNumbers = function(a, b) {
if (a == b) {
return 0;
} else if (("genesis" == a || "earliest" == a || 0 == a) && ("genesis" == b || "earliest" == b || 0 == b)) {
return 0;
} else if ("genesis" == a || "earliest" == a) {
// b !== a, thus a < b
return -1;
} else if ("genesis" == b || "earliest" == b) {
// b !== a, thus a > b
return 1;
} else if (a == "latest") {
if (b == "pending") {
return -1;
} else {
// b !== ("pending" OR "latest"), thus a > b
return 1;
}
} else if (b === "latest") {
if (a == "pending") {
return 1;
} else {
// b !== ("pending" OR "latest"), thus a > b
return -1
}
} else if (a == "pending") {
// b (== OR <) "latest", thus a > b
return 1;
} else if (b == "pending") {
return -1;
} else {
let bnA = new BN(a);
let bnB = new BN(b);
if(bnA.lt(bnB)) {
return -1;
} else if(bnA.eq(bnB)) {
return 0;
} else {
return 1;
}
}
};
module.exports = {

@@ -340,2 +396,3 @@ _fireError: _fireError,

soliditySha3Raw: soliditySha3.soliditySha3Raw,
encodePacked: soliditySha3.encodePacked,
isAddress: utils.isAddress,

@@ -386,3 +443,5 @@ checkAddressChecksum: utils.checkAddressChecksum,

isTopicInBloom: utils.isTopicInBloom,
isInBloom: utils.isInBloom
isInBloom: utils.isInBloom,
compareBlockNumbers: compareBlockNumbers
};

@@ -172,3 +172,3 @@ /*

var _processSoliditySha3Args = function (arg) {
var _processSolidityEncodePackedArgs = function (arg) {
/*jshint maxcomplexity:false */

@@ -237,3 +237,3 @@

var hexArgs = _.map(args, _processSoliditySha3Args);
var hexArgs = _.map(args, _processSolidityEncodePackedArgs);

@@ -253,9 +253,26 @@ // console.log(args, hexArgs);

var soliditySha3Raw = function () {
return utils.sha3Raw('0x'+ _.map(Array.prototype.slice.call(arguments), _processSoliditySha3Args).join(''));
return utils.sha3Raw('0x'+ _.map(Array.prototype.slice.call(arguments), _processSolidityEncodePackedArgs).join(''));
};
/**
* Encode packed args to hex
*
* @method encodePacked
* @return {String} the hex encoded arguments
*/
var encodePacked = function () {
/*jshint maxcomplexity:false */
var args = Array.prototype.slice.call(arguments);
var hexArgs = _.map(args, _processSolidityEncodePackedArgs);
return '0x'+ hexArgs.join('').toLowerCase();
};
module.exports = {
soliditySha3: soliditySha3,
soliditySha3Raw: soliditySha3Raw
soliditySha3Raw: soliditySha3Raw,
encodePacked: encodePacked
};

@@ -118,2 +118,3 @@ /*

export function soliditySha3Raw(...val: Mixed[]): string;
export function encodePacked(...val: Mixed[]): string | null;
export function getUnitValue(unit: Unit): string;

@@ -174,2 +175,3 @@ export function unitMap(): Units;

soliditySha3Raw(...val: Mixed[]): string;
encodePacked(...val: Mixed[]): string | null;
getUnitValue(unit: Unit): string;

@@ -176,0 +178,0 @@ unitMap(): Units;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc