Added BigNumber _difficulty to Block results (#2001, #2036).

This commit is contained in:
Richard Moore 2021-10-04 12:09:44 -04:00
parent ab806cad15
commit a48552a4fb
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
2 changed files with 7 additions and 2 deletions

@ -56,7 +56,7 @@ export interface TransactionResponse extends Transaction {
export type BlockTag = string | number;
interface _Block {
export interface _Block {
hash: string;
parentHash: string;
number: number;
@ -64,6 +64,7 @@ interface _Block {
timestamp: number;
nonce: string;
difficulty: number;
_difficulty: BigNumber;
gasLimit: BigNumber;
gasUsed: BigNumber;

@ -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 {