@nomicfoundation/ethereumjs-common
Advanced tools
Comparing version
@@ -31,3 +31,3 @@ "use strict"; | ||
this._hardfork = this.DEFAULT_HARDFORK; | ||
if ((0, ethereumjs_util_1.isTruthy)(opts.hardfork)) { | ||
if (opts.hardfork !== undefined) { | ||
this.setHardfork(opts.hardfork); | ||
@@ -145,3 +145,3 @@ } | ||
} | ||
if ((0, ethereumjs_util_1.isTruthy)(initializedChains[chain])) { | ||
if (initializedChains[chain] !== undefined) { | ||
return initializedChains[chain]; | ||
@@ -234,3 +234,3 @@ } | ||
} | ||
if (td && (0, ethereumjs_util_1.isTruthy)(hf.ttd)) { | ||
if (td && (typeof hf.ttd === 'string' || typeof hf.ttd === 'bigint')) { | ||
if (td >= BigInt(hf.ttd)) { | ||
@@ -247,3 +247,3 @@ minTdHF = hf.name; | ||
let msgAdd = `block number: ${blockNumber} (-> ${hardfork}), `; | ||
if ((0, ethereumjs_util_1.isTruthy)(minTdHF)) { | ||
if (minTdHF !== undefined) { | ||
if (!this.hardforkGteHardfork(hardfork, minTdHF)) { | ||
@@ -255,3 +255,3 @@ const msg = 'HF determined by block number is lower than the minimum total difficulty HF'; | ||
} | ||
if ((0, ethereumjs_util_1.isTruthy)(maxTdHF)) { | ||
if (maxTdHF !== undefined) { | ||
if (!this.hardforkGteHardfork(maxTdHF, hardfork)) { | ||
@@ -309,3 +309,3 @@ const msg = 'Maximum HF determined by total difficulty is lower than the block number HF'; | ||
} | ||
if ((0, ethereumjs_util_1.isTruthy)(eips_1.EIPs[eip].requiredEIPs)) { | ||
if (eips_1.EIPs[eip].requiredEIPs !== undefined) { | ||
for (const elem of eips_1.EIPs[eip].requiredEIPs) { | ||
@@ -357,3 +357,3 @@ if (!(eips.includes(elem) || this.isActivatedEIP(elem))) { | ||
const valueEIP = this.paramByEIP(topic, name, eip); | ||
value = valueEIP !== undefined ? valueEIP : value; | ||
value = typeof valueEIP === 'bigint' ? valueEIP : value; | ||
} | ||
@@ -363,3 +363,3 @@ // Parameter-inlining HF file (e.g. istanbul.json) | ||
else { | ||
if ((0, ethereumjs_util_1.isFalsy)(hfChanges[1][topic])) { | ||
if (hfChanges[1][topic] === undefined) { | ||
throw new Error(`Topic ${topic} not defined`); | ||
@@ -443,3 +443,3 @@ } | ||
const hfBlock = this.hardforkBlock(hardfork); | ||
if ((0, ethereumjs_util_1.isTruthy)(hfBlock) && blockNumber >= hfBlock) { | ||
if (typeof hfBlock === 'bigint' && hfBlock !== BigInt(0) && blockNumber >= hfBlock) { | ||
return true; | ||
@@ -539,3 +539,3 @@ } | ||
const block = this.hardforkBlock(hardfork); | ||
return (0, ethereumjs_util_1.isTruthy)(block) ? block === blockNumber : false; | ||
return typeof block === 'bigint' && block !== BigInt(0) ? block === blockNumber : false; | ||
} | ||
@@ -734,5 +734,3 @@ /** | ||
} | ||
return (0, ethereumjs_util_1.isTruthy)(value) | ||
? value | ||
: this._chainParams['consensus']['algorithm']; | ||
return value ?? this._chainParams['consensus']['algorithm']; | ||
} | ||
@@ -764,5 +762,3 @@ /** | ||
} | ||
return (0, ethereumjs_util_1.isTruthy)(value) | ||
? value | ||
: this._chainParams['consensus'][this.consensusAlgorithm()]; | ||
return value ?? this._chainParams['consensus'][this.consensusAlgorithm()]; | ||
} | ||
@@ -769,0 +765,0 @@ /** |
{ | ||
"name": "@nomicfoundation/ethereumjs-common", | ||
"version": "3.0.0-rc.3", | ||
"version": "3.0.0", | ||
"description": "Resources common to all Ethereum implementations", | ||
@@ -50,5 +50,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@nomicfoundation/ethereumjs-util": "8.0.0-rc.3", | ||
"@nomicfoundation/ethereumjs-util": "^8.0.0", | ||
"crc-32": "^1.2.0" | ||
} | ||
} |
@@ -1,8 +0,2 @@ | ||
import { | ||
TypeOutput, | ||
intToBuffer, | ||
isFalsy, | ||
isTruthy, | ||
toType, | ||
} from '@nomicfoundation/ethereumjs-util' | ||
import { TypeOutput, intToBuffer, toType } from '@nomicfoundation/ethereumjs-util' | ||
import { buf as crc32Buffer } from 'crc-32' | ||
@@ -187,3 +181,3 @@ import { EventEmitter } from 'events' | ||
if (isTruthy(initializedChains[chain])) { | ||
if (initializedChains[chain] !== undefined) { | ||
return initializedChains[chain] as ChainConfig | ||
@@ -201,3 +195,3 @@ } | ||
this._hardfork = this.DEFAULT_HARDFORK | ||
if (isTruthy(opts.hardfork)) { | ||
if (opts.hardfork !== undefined) { | ||
this.setHardfork(opts.hardfork) | ||
@@ -296,3 +290,3 @@ } | ||
} | ||
if (td && isTruthy(hf.ttd)) { | ||
if (td && (typeof hf.ttd === 'string' || typeof hf.ttd === 'bigint')) { | ||
if (td >= BigInt(hf.ttd)) { | ||
@@ -308,3 +302,3 @@ minTdHF = hf.name | ||
let msgAdd = `block number: ${blockNumber} (-> ${hardfork}), ` | ||
if (isTruthy(minTdHF)) { | ||
if (minTdHF !== undefined) { | ||
if (!this.hardforkGteHardfork(hardfork, minTdHF)) { | ||
@@ -316,3 +310,3 @@ const msg = 'HF determined by block number is lower than the minimum total difficulty HF' | ||
} | ||
if (isTruthy(maxTdHF)) { | ||
if (maxTdHF !== undefined) { | ||
if (!this.hardforkGteHardfork(maxTdHF, hardfork)) { | ||
@@ -374,3 +368,3 @@ const msg = 'Maximum HF determined by total difficulty is lower than the block number HF' | ||
} | ||
if (isTruthy(EIPs[eip].requiredEIPs)) { | ||
if (EIPs[eip].requiredEIPs !== undefined) { | ||
for (const elem of EIPs[eip].requiredEIPs) { | ||
@@ -423,7 +417,7 @@ if (!(eips.includes(elem) || this.isActivatedEIP(elem))) { | ||
const valueEIP = this.paramByEIP(topic, name, eip) | ||
value = valueEIP !== undefined ? valueEIP : value | ||
value = typeof valueEIP === 'bigint' ? valueEIP : value | ||
} | ||
// Parameter-inlining HF file (e.g. istanbul.json) | ||
} else { | ||
if (isFalsy(hfChanges[1][topic])) { | ||
if (hfChanges[1][topic] === undefined) { | ||
throw new Error(`Topic ${topic} not defined`) | ||
@@ -511,3 +505,3 @@ } | ||
const hfBlock = this.hardforkBlock(hardfork) | ||
if (isTruthy(hfBlock) && blockNumber >= hfBlock) { | ||
if (typeof hfBlock === 'bigint' && hfBlock !== BigInt(0) && blockNumber >= hfBlock) { | ||
return true | ||
@@ -614,3 +608,3 @@ } | ||
const block = this.hardforkBlock(hardfork) | ||
return isTruthy(block) ? block === blockNumber : false | ||
return typeof block === 'bigint' && block !== BigInt(0) ? block === blockNumber : false | ||
} | ||
@@ -827,5 +821,3 @@ | ||
} | ||
return isTruthy(value) | ||
? value | ||
: (this._chainParams['consensus']['algorithm'] as ConsensusAlgorithm) | ||
return value ?? (this._chainParams['consensus']['algorithm'] as ConsensusAlgorithm) | ||
} | ||
@@ -858,5 +850,3 @@ | ||
} | ||
return isTruthy(value) | ||
? value | ||
: this._chainParams['consensus'][this.consensusAlgorithm() as ConsensusAlgorithm]! | ||
return value ?? this._chainParams['consensus'][this.consensusAlgorithm() as ConsensusAlgorithm]! | ||
} | ||
@@ -863,0 +853,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
-100%247138
-0.09%6815
-0.21%+ Added
- Removed