Socket
Socket
Sign inDemoInstall

web3-validator

Package Overview
Dependencies
Maintainers
2
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-validator - npm Package Compare versions

Comparing version 0.1.1-alpha.1 to 0.1.1-alpha.2

7

dist/utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.padLeft = exports.numberToHex = exports.hexToNumber = exports.codePointToInt = exports.transformJsonDataToAbiFormat = exports.fetchArrayElement = exports.ethAbiToJsonSchema = exports.abiSchemaToJsonSchema = exports.parseBaseType = void 0;
const web3_errors_1 = require("web3-errors");
const constants_1 = require("./constants");

@@ -241,3 +242,5 @@ const abi_1 = require("./validation/abi");

if (typeof value === 'string' && (0, string_1.isHexStrict)(value)) {
return (0, exports.numberToHex)((0, exports.hexToNumber)(value));
const [negative, hex] = value.startsWith('-') ? [true, value.slice(1)] : [false, value];
const hexValue = hex.split(/^(-)?0(x|X)/).slice(-1)[0];
return `${negative ? '-' : ''}0x${hexValue.replace(/^0+/, '').toLowerCase()}`;
}

@@ -247,3 +250,3 @@ if (typeof value === 'string' && !(0, string_1.isHexStrict)(value)) {

}
throw new Error('Invalid number value');
throw new web3_errors_1.InvalidNumberError(value);
};

@@ -250,0 +253,0 @@ exports.numberToHex = numberToHex;

@@ -6,7 +6,7 @@ "use strict";

exports.isString = isString;
const isHexStrict = (hex) => typeof hex === 'string' && /^(-)?0x[0-9a-f]*$/i.test(hex);
const isHexStrict = (hex) => typeof hex === 'string' && /^((-)?0x[0-9a-f]+|(0x))$/i.test(hex);
exports.isHexStrict = isHexStrict;
const isHex = (hex) => typeof hex === 'number' ||
typeof hex === 'bigint' ||
(typeof hex === 'string' && /^(-0x|0x)?[0-9a-f]*$/i.test(hex));
(typeof hex === 'string' && /^((-0x|0x|-)?[0-9a-f]+|(0x))$/i.test(hex));
exports.isHex = isHex;

@@ -13,0 +13,0 @@ const isHexString8Bytes = (value, prefixed = true) => prefixed ? (0, exports.isHexStrict)(value) && value.length === 18 : (0, exports.isHex)(value) && value.length === 16;

{
"name": "web3-validator",
"version": "0.1.1-alpha.1",
"version": "0.1.1-alpha.2",
"description": "JSON-Schema compatible validator for web3",

@@ -32,4 +32,4 @@ "main": "dist/index.js",

"ethereum-cryptography": "^1.1.2",
"web3-errors": "^0.1.1-alpha.1",
"web3-types": "^0.1.1-alpha.1"
"web3-errors": "^0.1.1-alpha.2",
"web3-types": "^0.1.1-alpha.2"
},

@@ -50,3 +50,3 @@ "devDependencies": {

},
"gitHead": "a754e3a965c30f42a6e639df27462650062833ee"
"gitHead": "7d5de3b049bf7929669c89e474387b16bd27c612"
}

Sorry, the diff of this file is too big to display

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

Sorry, the diff of this file is not supported yet

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