Set total difficulty to zero if not available

This commit is contained in:
Nabarun 2025-03-10 19:14:06 +05:30
parent 944db0eaf7
commit 149992c732

View File

@ -130,7 +130,7 @@ export class EthClient implements EthClientInterface {
parentHash: block.parentHash, parentHash: block.parentHash,
timestamp: block.timestamp.toString(), timestamp: block.timestamp.toString(),
stateRoot: this._provider.formatter.hash(rawBlock.stateRoot), stateRoot: this._provider.formatter.hash(rawBlock.stateRoot),
td: this._provider.formatter.bigNumber(rawBlock.totalDifficulty).toString(), td: this._provider.formatter.bigNumber(rawBlock.totalDifficulty ?? 0).toString(),
txRoot: this._provider.formatter.hash(rawBlock.transactionsRoot), txRoot: this._provider.formatter.hash(rawBlock.transactionsRoot),
receiptRoot: this._provider.formatter.hash(rawBlock.receiptsRoot) receiptRoot: this._provider.formatter.hash(rawBlock.receiptsRoot)
} }
@ -191,7 +191,7 @@ export class EthClient implements EthClientInterface {
parentHash: this._provider.formatter.hash(rawBlock.parentHash), parentHash: this._provider.formatter.hash(rawBlock.parentHash),
timestamp: this._provider.formatter.number(rawBlock.timestamp).toString(), timestamp: this._provider.formatter.number(rawBlock.timestamp).toString(),
stateRoot: this._provider.formatter.hash(rawBlock.stateRoot), stateRoot: this._provider.formatter.hash(rawBlock.stateRoot),
td: this._provider.formatter.bigNumber(rawBlock.totalDifficulty).toString(), td: this._provider.formatter.bigNumber(rawBlock.totalDifficulty ?? 0).toString(),
txRoot: this._provider.formatter.hash(rawBlock.transactionsRoot), txRoot: this._provider.formatter.hash(rawBlock.transactionsRoot),
receiptRoot: this._provider.formatter.hash(rawBlock.receiptsRoot), receiptRoot: this._provider.formatter.hash(rawBlock.receiptsRoot),
uncleRoot: this._provider.formatter.hash(rawBlock.sha3Uncles), uncleRoot: this._provider.formatter.hash(rawBlock.sha3Uncles),