Skip to content

Commit

Permalink
add validation in from values array
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Jul 10, 2023
1 parent ea1d15f commit 8917fcc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/block/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class BlockHeader {
*/
public static fromValuesArray(values: BlockHeaderBytes, opts: BlockOptions = {}) {
const headerData = valuesArrayToHeaderData(values)
const { number, baseFeePerGas, excessDataGas, dataGasUsed } = headerData
const { number, baseFeePerGas, excessDataGas, dataGasUsed, parentBeaconBlockRoot } = headerData
const header = BlockHeader.fromHeaderData(headerData, opts)
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (header.common.isActivatedEIP(1559) && baseFeePerGas === undefined) {
Expand All @@ -127,6 +127,9 @@ export class BlockHeader {
throw new Error('invalid header. dataGasUsed should be provided')
}
}
if (header.common.isActivatedEIP(4788) && parentBeaconBlockRoot === undefined) {
throw new Error('invalid header. parentBeaconBlockRoot should be provided')
}
return header
}
/**
Expand Down

0 comments on commit 8917fcc

Please sign in to comment.