Skip to content

Commit

Permalink
ethereumjs-util BN ts build compatibility: remove use of IBN, remov…
Browse files Browse the repository at this point in the history
…e compiler option `esModuleInterop`
  • Loading branch information
ryanio committed May 27, 2020
1 parent e9f6396 commit ffc943b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 4 additions & 6 deletions packages/block/src/header.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Common from 'ethereumjs-common'
import {
BN,
zeros,
KECCAK256_RLP_ARRAY,
KECCAK256_RLP,
Expand All @@ -12,9 +13,6 @@ import { Blockchain, BlockHeaderData, BufferLike, ChainOptions, PrefixedHexStrin
import { Buffer } from 'buffer'
import { Block } from './block'

const { BN } = require('ethereumjs-util')
import IBN = require('bn.js')

/**
* An object that represents the block header
*/
Expand Down Expand Up @@ -141,7 +139,7 @@ export class BlockHeader {
*
* @param parentBlock - the parent `Block` of this header
*/
canonicalDifficulty(parentBlock: Block): IBN {
canonicalDifficulty(parentBlock: Block): BN {
const hardfork = this._getHardfork()
const blockTs = new BN(this.timestamp)
const parentTs = new BN(parentBlock.header.timestamp)
Expand All @@ -153,7 +151,7 @@ export class BlockHeader {
let num = new BN(this.number)

// We use a ! here as TS can follow this hardforks-dependent logic, but it always gets assigned
let dif!: IBN
let dif!: BN

if (this._common.hardforkGteHardfork(hardfork, 'byzantium')) {
// max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99) (EIP100)
Expand Down Expand Up @@ -262,7 +260,7 @@ export class BlockHeader {
* @param blockchain - the blockchain that this block is validating against
* @param height - If this is an uncle header, this is the height of the block that is including it
*/
async validate(blockchain: Blockchain, height?: IBN): Promise<void> {
async validate(blockchain: Blockchain, height?: BN): Promise<void> {
if (this.isGenesis()) {
return
}
Expand Down
3 changes: 1 addition & 2 deletions packages/block/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "@ethereumjs/config-tsc",
"include": ["src/**/*.ts", "test/**/*.ts"],
"compilerOptions": {
"outDir": "test-build",
"esModuleInterop": true
"outDir": "test-build"
}
}
3 changes: 1 addition & 2 deletions packages/block/tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "@ethereumjs/config-tsc",
"compilerOptions": {
"outDir": "./dist",
"esModuleInterop": true
"outDir": "./dist"
},
"include": ["src/**/*.ts"]
}

0 comments on commit ffc943b

Please sign in to comment.