From ea8e6e59a5e7b478bd8764e9cfe896597225fc1a Mon Sep 17 00:00:00 2001 From: Gilg4mesh Date: Thu, 6 May 2021 14:57:16 +0800 Subject: [PATCH] Add blockTag --- src/call.ts | 5 ++++- src/provider.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/call.ts b/src/call.ts index ada637e..987d2b8 100644 --- a/src/call.ts +++ b/src/call.ts @@ -7,6 +7,7 @@ export async function all( calls: ContractCall[], multicallAddress: string, provider: ethers.providers.Provider, + blockTag?: number, ): Promise { const multicall = new ethers.Contract(multicallAddress, multicallAbi, provider); const callRequests = calls.map(call => { @@ -16,7 +17,9 @@ export async function all( callData, }; }); - const response = await multicall.aggregate(callRequests); + const response = await multicall.aggregate(callRequests, { + blockTag: blockTag, + }); const callCount = calls.length; const callResult = [] as T; for (let i = 0; i < callCount; i++) { diff --git a/src/provider.ts b/src/provider.ts index cbedcfb..a47d2e5 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -24,11 +24,11 @@ export class Provider { return getEthBalance(address, this._multicallAddress); } - public async all(calls: ContractCall[]) { + public async all(calls: ContractCall[], blockTag?: number) { if (!this._provider) { throw new Error('Provider should be initialized before use.'); } - return all(calls, this._multicallAddress, this._provider); + return all(calls, this._multicallAddress, this._provider, blockTag); } }