@ethereumjs/util
Advanced tools
Comparing version 8.0.0-rc.1 to 8.0.0
@@ -12,3 +12,2 @@ "use strict"; | ||
const internal_1 = require("./internal"); | ||
const types_1 = require("./types"); | ||
const _0n = BigInt(0); | ||
@@ -29,3 +28,3 @@ class Account { | ||
const { nonce, balance, storageRoot, codeHash } = accountData; | ||
return new Account((0, types_1.isTruthy)(nonce) ? (0, bytes_1.bufferToBigInt)((0, bytes_1.toBuffer)(nonce)) : undefined, (0, types_1.isTruthy)(balance) ? (0, bytes_1.bufferToBigInt)((0, bytes_1.toBuffer)(balance)) : undefined, (0, types_1.isTruthy)(storageRoot) ? (0, bytes_1.toBuffer)(storageRoot) : undefined, (0, types_1.isTruthy)(codeHash) ? (0, bytes_1.toBuffer)(codeHash) : undefined); | ||
return new Account(nonce !== undefined ? (0, bytes_1.bufferToBigInt)((0, bytes_1.toBuffer)(nonce)) : undefined, balance !== undefined ? (0, bytes_1.bufferToBigInt)((0, bytes_1.toBuffer)(balance)) : undefined, storageRoot !== undefined ? (0, bytes_1.toBuffer)(storageRoot) : undefined, codeHash !== undefined ? (0, bytes_1.toBuffer)(codeHash) : undefined); | ||
} | ||
@@ -119,3 +118,3 @@ static fromRlpSerializedAccount(serialized) { | ||
let prefix = ''; | ||
if ((0, types_1.isTruthy)(eip1191ChainId)) { | ||
if (eip1191ChainId !== undefined) { | ||
const chainId = (0, bytes_1.bufferToBigInt)((0, bytes_1.toBuffer)(eip1191ChainId)); | ||
@@ -122,0 +121,0 @@ prefix = chainId.toString() + '0x'; |
@@ -45,20 +45,2 @@ /// <reference types="node" /> | ||
export declare function toType<T extends TypeOutput>(input: ToBufferInputTypes, outputType: T): TypeOutputReturnType[T]; | ||
declare type Falsy = false | '' | 0 | null | undefined | 0n; | ||
/** | ||
* Returns true if a value is falsy | ||
* | ||
* @param value - Value to check for falseness | ||
* | ||
* @deprecated This helper function should only be used temporarily until the monorepo types are explicit enough | ||
*/ | ||
export declare function isFalsy(value: unknown): value is Falsy; | ||
/** | ||
* Returns true if a value is truthy | ||
* | ||
* @param value - Value to check for truthiness | ||
* | ||
* @deprecated This helper function should only be used temporarily until the monorepo types are explicit enough | ||
*/ | ||
export declare function isTruthy<T>(value: T | Falsy): value is T; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isTruthy = exports.isFalsy = exports.toType = exports.TypeOutput = void 0; | ||
exports.toType = exports.TypeOutput = void 0; | ||
const bytes_1 = require("./bytes"); | ||
@@ -49,30 +49,2 @@ const internal_1 = require("./internal"); | ||
exports.toType = toType; | ||
/** | ||
* Returns true if a value is falsy | ||
* | ||
* @param value - Value to check for falseness | ||
* | ||
* @deprecated This helper function should only be used temporarily until the monorepo types are explicit enough | ||
*/ | ||
function isFalsy(value) { | ||
return !!(value === false || | ||
value === '' || | ||
value === 0 || | ||
Number.isNaN(value) || | ||
value === null || | ||
typeof value === 'undefined' || | ||
value === BigInt(0)); | ||
} | ||
exports.isFalsy = isFalsy; | ||
/** | ||
* Returns true if a value is truthy | ||
* | ||
* @param value - Value to check for truthiness | ||
* | ||
* @deprecated This helper function should only be used temporarily until the monorepo types are explicit enough | ||
*/ | ||
function isTruthy(value) { | ||
return !isFalsy(value); | ||
} | ||
exports.isTruthy = isTruthy; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@ethereumjs/util", | ||
"version": "8.0.0-rc.1", | ||
"version": "8.0.0", | ||
"description": "A collection of utility functions for Ethereum", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -18,3 +18,2 @@ import { RLP } from '@ethereumjs/rlp' | ||
import { stripHexPrefix } from './internal' | ||
import { isTruthy } from './types' | ||
@@ -42,6 +41,6 @@ import type { BigIntLike, BufferLike } from './types' | ||
return new Account( | ||
isTruthy(nonce) ? bufferToBigInt(toBuffer(nonce)) : undefined, | ||
isTruthy(balance) ? bufferToBigInt(toBuffer(balance)) : undefined, | ||
isTruthy(storageRoot) ? toBuffer(storageRoot) : undefined, | ||
isTruthy(codeHash) ? toBuffer(codeHash) : undefined | ||
nonce !== undefined ? bufferToBigInt(toBuffer(nonce)) : undefined, | ||
balance !== undefined ? bufferToBigInt(toBuffer(balance)) : undefined, | ||
storageRoot !== undefined ? toBuffer(storageRoot) : undefined, | ||
codeHash !== undefined ? toBuffer(codeHash) : undefined | ||
) | ||
@@ -163,3 +162,3 @@ } | ||
let prefix = '' | ||
if (isTruthy(eip1191ChainId)) { | ||
if (eip1191ChainId !== undefined) { | ||
const chainId = bufferToBigInt(toBuffer(eip1191ChainId)) | ||
@@ -166,0 +165,0 @@ prefix = chainId.toString() + '0x' |
@@ -123,33 +123,1 @@ import { bufferToBigInt, bufferToHex, toBuffer } from './bytes' | ||
} | ||
type Falsy = false | '' | 0 | null | undefined | 0n | ||
/** | ||
* Returns true if a value is falsy | ||
* | ||
* @param value - Value to check for falseness | ||
* | ||
* @deprecated This helper function should only be used temporarily until the monorepo types are explicit enough | ||
*/ | ||
export function isFalsy(value: unknown): value is Falsy { | ||
return !!( | ||
value === false || | ||
value === '' || | ||
value === 0 || | ||
Number.isNaN(value) || | ||
value === null || | ||
typeof value === 'undefined' || | ||
value === BigInt(0) | ||
) | ||
} | ||
/** | ||
* Returns true if a value is truthy | ||
* | ||
* @param value - Value to check for truthiness | ||
* | ||
* @deprecated This helper function should only be used temporarily until the monorepo types are explicit enough | ||
*/ | ||
export function isTruthy<T>(value: T | Falsy): value is T { | ||
return !isFalsy(value) | ||
} |
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
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
0
176084
3295