Skip to content

Commit

Permalink
fix(blocknumber): map bigint to number
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Jan 19, 2024
1 parent 9ca152b commit dffa3e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/multicall-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class MulticallWrapper {
if (multicall == null) return _perform(req);

const request = {
call: { to, data, blockTag },
call: { to, data, blockTag, blockNumber },
multicall,
};

Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockTag, ContractRunner, isHexString } from "ethers";
import { BlockTag, ContractRunner, isHexString, toNumber } from "ethers";

import {
multicall2Address,
Expand All @@ -16,6 +16,7 @@ export enum MulticallVersion {

export const getBlockNumber = (blockTag: BlockTag) => {
if (isHexString(blockTag)) return parseInt(blockTag as string, 16);
else if (typeof blockTag === "bigint") return toNumber(blockTag);
else if (typeof blockTag === "number") return blockTag;
else if (blockTag === "earliest") return 0;

Expand Down
2 changes: 1 addition & 1 deletion test/multicall-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe("ethers-multicall-provider", () => {
expect(provider.send).toHaveBeenCalledTimes(4);
});

it.only("should not cache latest request", async () => {
it("should not cache latest request", async () => {
jest
.spyOn(provider, "send")
.mockImplementation(() =>
Expand Down

0 comments on commit dffa3e2

Please sign in to comment.