From 149992c7324d70030f65569181a4031f1630e4b2 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Mon, 10 Mar 2025 19:14:06 +0530 Subject: [PATCH] Set total difficulty to zero if not available --- packages/rpc-eth-client/src/eth-client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rpc-eth-client/src/eth-client.ts b/packages/rpc-eth-client/src/eth-client.ts index db53f53e..8285f178 100644 --- a/packages/rpc-eth-client/src/eth-client.ts +++ b/packages/rpc-eth-client/src/eth-client.ts @@ -130,7 +130,7 @@ export class EthClient implements EthClientInterface { parentHash: block.parentHash, timestamp: block.timestamp.toString(), 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), receiptRoot: this._provider.formatter.hash(rawBlock.receiptsRoot) } @@ -191,7 +191,7 @@ export class EthClient implements EthClientInterface { parentHash: this._provider.formatter.hash(rawBlock.parentHash), timestamp: this._provider.formatter.number(rawBlock.timestamp).toString(), 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), receiptRoot: this._provider.formatter.hash(rawBlock.receiptsRoot), uncleRoot: this._provider.formatter.hash(rawBlock.sha3Uncles),