Skip to content

Commit

Permalink
Added BigNumber _difficulty to Block results (#2001, #2036).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 4, 2021
1 parent ab806ca commit a48552a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/abstract-provider/src.ts/index.ts
Expand Up @@ -56,14 +56,15 @@ export interface TransactionResponse extends Transaction {

export type BlockTag = string | number;

interface _Block {
export interface _Block {
hash: string;
parentHash: string;
number: number;

timestamp: number;
nonce: string;
difficulty: number;
_difficulty: BigNumber;

gasLimit: BigNumber;
gasUsed: BigNumber;
Expand Down
6 changes: 5 additions & 1 deletion packages/providers/src.ts/formatter.ts
Expand Up @@ -295,7 +295,11 @@ export class Formatter {
if (value.author != null && value.miner == null) {
value.miner = value.author;
}
return Formatter.check(format, value);
// The difficulty may need to come from _difficulty in recursed blocks
const difficulty = (value._difficulty != null) ? value._difficulty: value.difficulty;
const result = Formatter.check(format, value);
result._difficulty = ((difficulty == null) ? null: BigNumber.from(difficulty));
return result;
}

block(value: any): Block {
Expand Down

0 comments on commit a48552a

Please sign in to comment.