Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(studio): Make hooks an object
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich committed Aug 8, 2022
1 parent f2bacc0 commit 289521a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/multicall/multicall.ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type TargetContract = Pick<Contract, 'functions' | 'interface' | 'callStatic' |

export const isMulticallUnderlyingError = (err: Error) => err.message.includes('Multicall call failed for');

export type MulticallCallbackHooks = {
beforeCallHook?: (calls: ContractCall[], callRequests: Multicall.CallStruct[]) => void;
};

const DEFAULT_DATALOADER_OPTIONS = { cache: false, maxBatchSize: 250 };

export class EthersMulticall implements IMulticallWrapper {
Expand All @@ -28,7 +32,7 @@ export class EthersMulticall implements IMulticallWrapper {
constructor(
multicall: Multicall,
dataLoaderOptions: DataLoader.Options<ContractCall, any> = DEFAULT_DATALOADER_OPTIONS,
beforeCallHook?: (calls: ContractCall[], callRequests: Multicall.CallStruct[]) => void,
{ beforeCallHook }: MulticallCallbackHooks = {},
) {
this.multicall = multicall;
this.dataLoader = new DataLoader(this.doCalls.bind(this), dataLoaderOptions);
Expand Down

0 comments on commit 289521a

Please sign in to comment.