web3-validator
Advanced tools
Comparing version 2.0.3-dev.6e43d1b.0 to 2.0.3-dev.70d1957.0
@@ -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,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.6e43d1b.0+6e43d1b", | ||
"version": "2.0.3-dev.70d1957.0+70d1957", | ||
"description": "JSON-Schema compatible validator for web3", | ||
@@ -50,4 +50,4 @@ "main": "./lib/commonjs/index.js", | ||
"util": "^0.12.5", | ||
"web3-errors": "1.1.3-dev.6e43d1b.0+6e43d1b", | ||
"web3-types": "1.2.1-dev.6e43d1b.0+6e43d1b", | ||
"web3-errors": "1.1.3-dev.70d1957.0+70d1957", | ||
"web3-types": "1.2.1-dev.70d1957.0+70d1957", | ||
"zod": "^3.21.4" | ||
@@ -69,3 +69,3 @@ }, | ||
}, | ||
"gitHead": "6e43d1b78940d795c22d62fc431e09d10ffcab92" | ||
"gitHead": "70d1957e0a8642d1e5dba47c39ea65504689b6ec" | ||
} |
@@ -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
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
935503
5502