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

Commit

Permalink
fix(studio): Fix multicall call struct types (#3035)
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich authored Nov 14, 2023
1 parent 59dfac8 commit 8df61a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/multicall/impl/multicall.ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import { Multicall } from '~contract/contracts';
import { DEFAULT_DATALOADER_OPTIONS } from '../multicall.constants';
import { MulticallContract } from '../multicall.contract';
import { ContractCall, IMulticallWrapper, TargetContract } from '../multicall.interface';
import { MulticallCallStruct } from '~multicall/multicall.types';

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

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

export class EthersMulticallDataLoader implements IMulticallWrapper {
private multicall: Multicall;
private dataLoader: DataLoader<ContractCall, ethers.utils.Result>;
private beforeCallHook?: (calls: ContractCall[], callRequests: Multicall.CallStruct[]) => void;
private beforeCallHook?: (calls: ContractCall[], callRequests: MulticallCallStruct[]) => void;

constructor(
multicall: Multicall,
Expand Down
10 changes: 3 additions & 7 deletions src/multicall/impl/multicall.viem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { MulticallWrappedReadRequestError } from '~multicall/errors/multicall.re
import { DEFAULT_DATALOADER_OPTIONS } from '~multicall/multicall.constants';

import { MulticallWrappedReadDecodeError } from '../errors/multicall.decode.error';
import { MulticallCallStruct } from '~multicall/multicall.types';

declare module 'abitype' {
export interface Config {
Expand All @@ -35,20 +36,15 @@ export type ContractCall<T extends Abi = Abi, V extends string = string> = {
stack?: string;
};

type CallStruct = {
target: string;
callData: string;
};

type MulticallCallbackHooks = {
beforeCallHook?: (calls: ContractCall[], callRequests: CallStruct[]) => void;
beforeCallHook?: (calls: ContractCall[], callRequests: MulticallCallStruct[]) => void;
afterResultSerializer?: (result: ReadContractReturnType) => unknown;
};

export class ViemMulticallDataLoader {
private multicall: MulticallContract;
private dataLoader: DataLoader<ContractCall, ReadContractReturnType>;
private beforeCallHook?: (calls: ContractCall[], callRequests: CallStruct[]) => void;
private beforeCallHook?: (calls: ContractCall[], callRequests: MulticallCallStruct[]) => void;
private afterResultSerializer?: (result: ReadContractReturnType) => unknown;

constructor(
Expand Down
4 changes: 4 additions & 0 deletions src/multicall/multicall.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type MulticallCallStruct = {
target: string;
callData: string;
};

0 comments on commit 8df61a2

Please sign in to comment.