Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export async function all<T extends any[] = any[]>(
calls: ContractCall[],
multicallAddress: string,
provider: ethers.providers.Provider,
blockTag?: number,
): Promise<T> {
const multicall = new ethers.Contract(multicallAddress, multicallAbi, provider);
const callRequests = calls.map(call => {
Expand All @@ -16,7 +17,9 @@ export async function all<T extends any[] = any[]>(
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++) {
Expand Down
4 changes: 2 additions & 2 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export class Provider {
return getEthBalance(address, this._multicallAddress);
}

public async all<T extends any[] = any[]>(calls: ContractCall[]) {
public async all<T extends any[] = any[]>(calls: ContractCall[], blockTag?: number) {
if (!this._provider) {
throw new Error('Provider should be initialized before use.');
}
return all<T>(calls, this._multicallAddress, this._provider);
return all<T>(calls, this._multicallAddress, this._provider, blockTag);
}
}

Expand Down