UNPKG

deth

Version:

Ethereum node focused on Developer Experience

27 lines (26 loc) 1.39 kB
import { bufferToHash, bufferToQuantity, numberToQuantity, bufferToHexData, bufferToAddress, } from '../primitives'; export function toBlockResponse(block) { return { number: bufferToQuantity(block.header.number), hash: bufferToHash(block.hash()), parentHash: bufferToHash(block.header.parentHash), nonce: bufferToHexData(block.header.nonce), sha3Uncles: bufferToHash(block.header.uncleHash), logsBloom: bufferToHexData(block.header.bloom), transactionsRoot: bufferToHash(block.header.transactionsTrie), stateRoot: bufferToHash(block.header.stateRoot), receiptsRoot: bufferToHash(block.header.receiptTrie), miner: bufferToAddress(block.header.coinbase), difficulty: bufferToQuantity(block.header.difficulty), // Taken from ganache-core LOL TODO: Do something better here totalDifficulty: bufferToQuantity(block.header.difficulty), extraData: bufferToHexData(block.header.extraData), // Taken from ganache-core LOL TODO: Do something better here size: numberToQuantity(1000), gasLimit: bufferToQuantity(block.header.gasLimit), gasUsed: bufferToQuantity(block.header.gasUsed), timestamp: bufferToQuantity(block.header.timestamp), transactions: block.transactions.map(tx => bufferToHash(tx.hash())), uncles: [], }; }