Allow BigInt for blockTag (#3780).

This commit is contained in:
Richard Moore 2023-03-03 17:44:08 -07:00
parent f1a810dcb5
commit fe1f04c6e5
2 changed files with 6 additions and 2 deletions

@ -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);

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