|
1 | 1 | import Account from 'ethereumjs-account'
|
2 |
| -const Block = require('ethereumjs-block') |
| 2 | +import { BlockHeader } from '@ethereumjs/block' |
3 | 3 | const Trie = require('merkle-patricia-tree/secure')
|
4 | 4 | import * as util from 'ethereumjs-util'
|
5 | 5 | import * as url from 'url'
|
@@ -93,16 +93,21 @@ async function parseGethState(alloc: any) {
|
93 | 93 | }
|
94 | 94 |
|
95 | 95 | async function parseGethHeader(json: any) {
|
96 |
| - const header = new Block.Header() |
97 |
| - header.gasLimit = json.gasLimit |
98 |
| - header.difficulty = json.difficulty |
99 |
| - header.extraData = json.extraData |
100 |
| - header.number = Buffer.from([]) |
101 |
| - header.nonce = json.nonce |
102 |
| - header.timestamp = json.timestamp |
103 |
| - header.mixHash = json.mixHash |
104 |
| - header.stateRoot = (await parseGethState(json.alloc)).root |
105 |
| - return header |
| 96 | + return BlockHeader.fromHeaderData( |
| 97 | + { |
| 98 | + gasLimit: new util.BN(util.stripHexPrefix(json.gasLimit), 16), |
| 99 | + difficulty: new util.BN(util.stripHexPrefix(json.difficulty), 16), |
| 100 | + extraData: toBuffer(json.extraData), |
| 101 | + number: new util.BN(util.stripHexPrefix(json.number), 16), |
| 102 | + nonce: toBuffer(json.nonce), |
| 103 | + timestamp: new util.BN(util.stripHexPrefix(json.timestamp), 16), |
| 104 | + mixHash: toBuffer(json.mixHash), |
| 105 | + stateRoot: (await parseGethState(json.alloc)).root, |
| 106 | + }, |
| 107 | + { |
| 108 | + // TODO: Add optional Common param here? |
| 109 | + } |
| 110 | + ) |
106 | 111 | }
|
107 | 112 |
|
108 | 113 | async function parseGethParams(json: any) {
|
|
0 commit comments