Skip to content

Commit a48552a

Browse files
committed
Added BigNumber _difficulty to Block results (ethers-io#2001, ethers-io#2036).
1 parent ab806ca commit a48552a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/abstract-provider/src.ts/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ export interface TransactionResponse extends Transaction {
5656

5757
export type BlockTag = string | number;
5858

59-
interface _Block {
59+
export interface _Block {
6060
hash: string;
6161
parentHash: string;
6262
number: number;
6363

6464
timestamp: number;
6565
nonce: string;
6666
difficulty: number;
67+
_difficulty: BigNumber;
6768

6869
gasLimit: BigNumber;
6970
gasUsed: BigNumber;

packages/providers/src.ts/formatter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ export class Formatter {
295295
if (value.author != null && value.miner == null) {
296296
value.miner = value.author;
297297
}
298-
return Formatter.check(format, value);
298+
// The difficulty may need to come from _difficulty in recursed blocks
299+
const difficulty = (value._difficulty != null) ? value._difficulty: value.difficulty;
300+
const result = Formatter.check(format, value);
301+
result._difficulty = ((difficulty == null) ? null: BigNumber.from(difficulty));
302+
return result;
299303
}
300304

301305
block(value: any): Block {

0 commit comments

Comments
 (0)