Skip to content

Commit

Permalink
Allow BigInt for blockTag (#3780).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Mar 4, 2023
1 parent f1a810d commit fe1f04c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src.ts/providers/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,14 @@ export class AbstractProvider implements Provider {
return toQuantity(blockTag);
}

if (typeof(blockTag) === "bigint") {
blockTag = getNumber(blockTag, "blockTag");
}

if (typeof(blockTag) === "number") {
if (blockTag >= 0) { return toQuantity(blockTag); }
if (this.#lastBlockNumber >= 0) { return toQuantity(this.#lastBlockNumber + blockTag); }
return this.getBlockNumber().then((b) => toQuantity(b + blockTag));
return this.getBlockNumber().then((b) => toQuantity(b + <number>blockTag));
}

assertArgument(false, "invalid blockTag", "blockTag", blockTag);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { Network } from "./network.js";

const BN_0 = BigInt(0);

export type BlockTag = number | string;
export type BlockTag = BigNumberish | string;

import {
BlockParams, LogParams, TransactionReceiptParams,
Expand Down

0 comments on commit fe1f04c

Please sign in to comment.