Socket
Socket
Sign inDemoInstall

web3-validator

Package Overview
Dependencies
Maintainers
5
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 2.0.3-dev.171b413.0 to 2.0.3-dev.226b3ba.0

2

lib/commonjs/validation/numbers.d.ts

@@ -6,2 +6,4 @@ import { ValidInputTypes } from '../types.js';

export declare const isBigInt: (value: ValidInputTypes) => boolean;
/** @internal */
export declare const bigintPower: (base: bigint, expo: bigint) => bigint;
export declare const isUInt: (value: ValidInputTypes, options?: {

@@ -8,0 +10,0 @@ abiType: string;

19

lib/commonjs/validation/numbers.js

@@ -19,3 +19,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isNumber = exports.isInt = exports.isUInt = exports.isBigInt = void 0;
exports.isNumber = exports.isInt = exports.isUInt = exports.bigintPower = exports.isBigInt = void 0;
const utils_js_1 = require("../utils.js");

@@ -28,2 +28,13 @@ const string_js_1 = require("./string.js");

exports.isBigInt = isBigInt;
// Note: this could be simplified using ** operator, but babel does not handle it well
// you can find more at: https://github.com/babel/babel/issues/13109 and https://github.com/web3/web3.js/issues/6187
/** @internal */
const bigintPower = (base, expo) => {
let res = base;
for (let index = 1; index < expo; index += 1) {
res *= base;
}
return res;
};
exports.bigintPower = bigintPower;
const isUInt = (value, options = {

@@ -46,3 +57,3 @@ abiType: 'uint',

}
const maxSize = BigInt(2) ** BigInt(size !== null && size !== void 0 ? size : 256) - BigInt(1);
const maxSize = (0, exports.bigintPower)(BigInt(2), BigInt(size !== null && size !== void 0 ? size : 256)) - BigInt(1);
try {

@@ -82,4 +93,4 @@ const valueToCheck = typeof value === 'string' && (0, string_js_1.isHexStrict)(value)

}
const maxSize = BigInt(2) ** BigInt((size !== null && size !== void 0 ? size : 256) - 1);
const minSize = BigInt(-1) * BigInt(2) ** BigInt((size !== null && size !== void 0 ? size : 256) - 1);
const maxSize = (0, exports.bigintPower)(BigInt(2), BigInt((size !== null && size !== void 0 ? size : 256) - 1));
const minSize = BigInt(-1) * (0, exports.bigintPower)(BigInt(2), BigInt((size !== null && size !== void 0 ? size : 256) - 1));
try {

@@ -86,0 +97,0 @@ const valueToCheck = typeof value === 'string' && (0, string_js_1.isHexStrict)(value)

@@ -23,2 +23,12 @@ /*

export const isBigInt = (value) => typeof value === 'bigint';
// Note: this could be simplified using ** operator, but babel does not handle it well
// you can find more at: https://github.com/babel/babel/issues/13109 and https://github.com/web3/web3.js/issues/6187
/** @internal */
export const bigintPower = (base, expo) => {
let res = base;
for (let index = 1; index < expo; index += 1) {
res *= base;
}
return res;
};
export const isUInt = (value, options = {

@@ -41,3 +51,3 @@ abiType: 'uint',

}
const maxSize = BigInt(2) ** BigInt(size !== null && size !== void 0 ? size : 256) - BigInt(1);
const maxSize = bigintPower(BigInt(2), BigInt(size !== null && size !== void 0 ? size : 256)) - BigInt(1);
try {

@@ -76,4 +86,4 @@ const valueToCheck = typeof value === 'string' && isHexStrict(value)

}
const maxSize = BigInt(2) ** BigInt((size !== null && size !== void 0 ? size : 256) - 1);
const minSize = BigInt(-1) * BigInt(2) ** BigInt((size !== null && size !== void 0 ? size : 256) - 1);
const maxSize = bigintPower(BigInt(2), BigInt((size !== null && size !== void 0 ? size : 256) - 1));
const minSize = BigInt(-1) * bigintPower(BigInt(2), BigInt((size !== null && size !== void 0 ? size : 256) - 1));
try {

@@ -80,0 +90,0 @@ const valueToCheck = typeof value === 'string' && isHexStrict(value)

@@ -6,2 +6,4 @@ import { ValidInputTypes } from '../types.js';

export declare const isBigInt: (value: ValidInputTypes) => boolean;
/** @internal */
export declare const bigintPower: (base: bigint, expo: bigint) => bigint;
export declare const isUInt: (value: ValidInputTypes, options?: {

@@ -8,0 +10,0 @@ abiType: string;

{
"name": "web3-validator",
"version": "2.0.3-dev.171b413.0+171b413",
"version": "2.0.3-dev.226b3ba.0+226b3ba",
"description": "JSON-Schema compatible validator for web3",

@@ -30,3 +30,3 @@ "main": "./lib/commonjs/index.js",

"prebuild": "yarn clean",
"build": "yarn build:cjs & yarn build:esm & yarn build:types",
"build": "concurrently --kill-others-on-fail \"yarn:build:*(!check|web)\"",
"build:cjs": "tsc --build tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/commonjs/package.json",

@@ -51,4 +51,4 @@ "build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",

"util": "^0.12.5",
"web3-errors": "1.1.3-dev.171b413.0+171b413",
"web3-types": "1.2.1-dev.171b413.0+171b413",
"web3-errors": "1.1.3-dev.226b3ba.0+226b3ba",
"web3-types": "1.2.1-dev.226b3ba.0+226b3ba",
"zod": "^3.21.4"

@@ -70,3 +70,3 @@ },

},
"gitHead": "171b413ae61a6cc5466a8501ed6dd513e83749c6"
"gitHead": "226b3ba9c1ece0a399d120b83229582ea20b6c95"
}

@@ -27,2 +27,13 @@ /*

// Note: this could be simplified using ** operator, but babel does not handle it well
// you can find more at: https://github.com/babel/babel/issues/13109 and https://github.com/web3/web3.js/issues/6187
/** @internal */
export const bigintPower = (base: bigint, expo: bigint) => {
let res = base;
for (let index = 1; index < expo; index += 1) {
res *= base;
}
return res;
};
export const isUInt = (

@@ -53,3 +64,3 @@ value: ValidInputTypes,

const maxSize = BigInt(2) ** BigInt(size ?? 256) - BigInt(1);
const maxSize = bigintPower(BigInt(2), BigInt(size ?? 256)) - BigInt(1);

@@ -99,4 +110,4 @@ try {

const maxSize = BigInt(2) ** BigInt((size ?? 256) - 1);
const minSize = BigInt(-1) * BigInt(2) ** BigInt((size ?? 256) - 1);
const maxSize = bigintPower(BigInt(2), BigInt((size ?? 256) - 1));
const minSize = BigInt(-1) * bigintPower(BigInt(2), BigInt((size ?? 256) - 1));

@@ -103,0 +114,0 @@ try {

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

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