Created
August 22, 2022 03:50
-
-
Save markodayan/8a853bc6f05dda35f9fcc94c05185cbd to your computer and use it in GitHub Desktop.
Prepare Block Tuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prepareBlockTuple(block: IRawBlock): ILegacyBlockTuple | IPost1559Tuple { | |
const blockNumber = parseInt(block.number, 16); | |
const tuple = [ | |
block.parentHash, | |
block.sha3Uncles, | |
block.miner, | |
block.stateRoot, | |
block.transactionsRoot, | |
block.receiptsRoot, | |
block.logsBloom, | |
block.difficulty, | |
block.number, | |
block.gasLimit, | |
block.gasUsed, | |
block.timestamp, | |
block.extraData, | |
block.mixHash, | |
block.nonce, | |
]; | |
// If a block after London Hardfork, add base fee to block tuple prior to encoding | |
if (blockNumber >= LONDON_HARDFORK_BLOCK) tuple.push(block.baseFeePerGas as string); | |
return tuple as ILegacyBlockTuple | IPost1559Tuple; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment