@@ -2,7 +2,7 @@ import { buf as crc32Buffer } from 'crc-32'
2
2
import { _getInitializedChains } from './chains'
3
3
import { hardforks as HARDFORK_CHANGES } from './hardforks'
4
4
import { EIPs } from './eips'
5
- import { BootstrapNode , Chain , GenesisBlock , Hardfork } from './types'
5
+ import { Chain } from './types'
6
6
7
7
/**
8
8
* Options for instantiating a [[Common]] instance.
@@ -57,7 +57,7 @@ interface hardforkOptions {
57
57
* Common class to access chain and hardfork parameters
58
58
*/
59
59
export default class Common {
60
- readonly DEFAULT_HARDFORK : string = 'istanbul'
60
+ readonly DEFAULT_HARDFORK : string
61
61
62
62
private _chainParams : Chain
63
63
private _hardfork : string
@@ -117,6 +117,7 @@ export default class Common {
117
117
constructor ( opts : CommonOpts ) {
118
118
this . _customChains = opts . customChains ?? [ ]
119
119
this . _chainParams = this . setChain ( opts . chain )
120
+ this . DEFAULT_HARDFORK = this . _chainParams . defaultHardfork
120
121
this . _hardfork = this . DEFAULT_HARDFORK
121
122
if ( opts . supportedHardforks ) {
122
123
this . _supportedHardforks = opts . supportedHardforks
@@ -513,7 +514,7 @@ export default class Common {
513
514
// Logic: if accumulator is still null and on the first occurence of
514
515
// a block greater than the current hfBlock set the accumulator,
515
516
// pass on the accumulator as the final result from this time on
516
- const nextHfBlock = ( this . hardforks ( ) as any ) . reduce ( ( acc : number , hf : any ) => {
517
+ const nextHfBlock = this . hardforks ( ) . reduce ( ( acc : number , hf : any ) => {
517
518
return hf . block > hfBlock && acc === null ? hf . block : acc
518
519
} , null )
519
520
return nextHfBlock
@@ -539,7 +540,7 @@ export default class Common {
539
540
const genesis = Buffer . from ( this . genesis ( ) . hash . substr ( 2 ) , 'hex' )
540
541
541
542
let hfBuffer = Buffer . alloc ( 0 )
542
- let prevBlock : number | null = 0
543
+ let prevBlock = 0
543
544
for ( const hf of this . hardforks ( ) ) {
544
545
const block = hf . block
545
546
@@ -565,7 +566,7 @@ export default class Common {
565
566
* Returns an eth/64 compliant fork hash (EIP-2124)
566
567
* @param hardfork Hardfork name, optional if HF set
567
568
*/
568
- forkHash ( hardfork ?: string ) : string | null {
569
+ forkHash ( hardfork ?: string ) {
569
570
hardfork = this . _chooseHardfork ( hardfork , false )
570
571
const data = this . _getHardfork ( hardfork )
571
572
if ( data [ 'block' ] === null ) {
0 commit comments