ethers-multicall-provider
Version:
⚡🕰️ Drop-in solution to batch smart contract RPC calls in a single RPC query via Multicall!
166 lines (165 loc) • 8.75 kB
TypeScript
import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedListener, TypedContractMethod } from "./common";
import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers";
export declare namespace Multicall2 {
type CallStruct = {
target: AddressLike;
callData: BytesLike;
};
type CallStructOutput = [target: string, callData: string] & {
target: string;
callData: string;
};
type ResultStruct = {
success: boolean;
returnData: BytesLike;
};
type ResultStructOutput = [success: boolean, returnData: string] & {
success: boolean;
returnData: string;
};
}
export interface Multicall2Interface extends Interface {
getFunction(nameOrSignature: "aggregate" | "blockAndAggregate" | "getBlockHash" | "getBlockNumber" | "getCurrentBlockCoinbase" | "getCurrentBlockDifficulty" | "getCurrentBlockGasLimit" | "getCurrentBlockTimestamp" | "getEthBalance" | "getLastBlockHash" | "tryAggregate" | "tryBlockAndAggregate"): FunctionFragment;
encodeFunctionData(functionFragment: "aggregate", values: [Multicall2.CallStruct[]]): string;
encodeFunctionData(functionFragment: "blockAndAggregate", values: [Multicall2.CallStruct[]]): string;
encodeFunctionData(functionFragment: "getBlockHash", values: [BigNumberish]): string;
encodeFunctionData(functionFragment: "getBlockNumber", values?: undefined): string;
encodeFunctionData(functionFragment: "getCurrentBlockCoinbase", values?: undefined): string;
encodeFunctionData(functionFragment: "getCurrentBlockDifficulty", values?: undefined): string;
encodeFunctionData(functionFragment: "getCurrentBlockGasLimit", values?: undefined): string;
encodeFunctionData(functionFragment: "getCurrentBlockTimestamp", values?: undefined): string;
encodeFunctionData(functionFragment: "getEthBalance", values: [AddressLike]): string;
encodeFunctionData(functionFragment: "getLastBlockHash", values?: undefined): string;
encodeFunctionData(functionFragment: "tryAggregate", values: [boolean, Multicall2.CallStruct[]]): string;
encodeFunctionData(functionFragment: "tryBlockAndAggregate", values: [boolean, Multicall2.CallStruct[]]): string;
decodeFunctionResult(functionFragment: "aggregate", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "blockAndAggregate", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getBlockHash", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getBlockNumber", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getCurrentBlockCoinbase", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getCurrentBlockDifficulty", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getCurrentBlockGasLimit", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getCurrentBlockTimestamp", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getEthBalance", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getLastBlockHash", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "tryAggregate", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "tryBlockAndAggregate", data: BytesLike): Result;
}
export interface Multicall2 extends BaseContract {
connect(runner?: ContractRunner | null): Multicall2;
waitForDeployment(): Promise<this>;
interface: Multicall2Interface;
queryFilter<TCEvent extends TypedContractEvent>(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TypedEventLog<TCEvent>>>;
queryFilter<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TypedEventLog<TCEvent>>>;
on<TCEvent extends TypedContractEvent>(event: TCEvent, listener: TypedListener<TCEvent>): Promise<this>;
on<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, listener: TypedListener<TCEvent>): Promise<this>;
once<TCEvent extends TypedContractEvent>(event: TCEvent, listener: TypedListener<TCEvent>): Promise<this>;
once<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, listener: TypedListener<TCEvent>): Promise<this>;
listeners<TCEvent extends TypedContractEvent>(event: TCEvent): Promise<Array<TypedListener<TCEvent>>>;
listeners(eventName?: string): Promise<Array<Listener>>;
removeAllListeners<TCEvent extends TypedContractEvent>(event?: TCEvent): Promise<this>;
aggregate: TypedContractMethod<[
calls: Multicall2.CallStruct[]
], [
[bigint, string[]] & {
blockNumber: bigint;
returnData: string[];
}
], "nonpayable">;
blockAndAggregate: TypedContractMethod<[
calls: Multicall2.CallStruct[]
], [
[
bigint,
string,
Multicall2.ResultStructOutput[]
] & {
blockNumber: bigint;
blockHash: string;
returnData: Multicall2.ResultStructOutput[];
}
], "nonpayable">;
getBlockHash: TypedContractMethod<[
blockNumber: BigNumberish
], [
string
], "view">;
getBlockNumber: TypedContractMethod<[], [bigint], "view">;
getCurrentBlockCoinbase: TypedContractMethod<[], [string], "view">;
getCurrentBlockDifficulty: TypedContractMethod<[], [bigint], "view">;
getCurrentBlockGasLimit: TypedContractMethod<[], [bigint], "view">;
getCurrentBlockTimestamp: TypedContractMethod<[], [bigint], "view">;
getEthBalance: TypedContractMethod<[addr: AddressLike], [bigint], "view">;
getLastBlockHash: TypedContractMethod<[], [string], "view">;
tryAggregate: TypedContractMethod<[
requireSuccess: boolean,
calls: Multicall2.CallStruct[]
], [
Multicall2.ResultStructOutput[]
], "nonpayable">;
tryBlockAndAggregate: TypedContractMethod<[
requireSuccess: boolean,
calls: Multicall2.CallStruct[]
], [
[
bigint,
string,
Multicall2.ResultStructOutput[]
] & {
blockNumber: bigint;
blockHash: string;
returnData: Multicall2.ResultStructOutput[];
}
], "nonpayable">;
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
getFunction(nameOrSignature: "aggregate"): TypedContractMethod<[
calls: Multicall2.CallStruct[]
], [
[bigint, string[]] & {
blockNumber: bigint;
returnData: string[];
}
], "nonpayable">;
getFunction(nameOrSignature: "blockAndAggregate"): TypedContractMethod<[
calls: Multicall2.CallStruct[]
], [
[
bigint,
string,
Multicall2.ResultStructOutput[]
] & {
blockNumber: bigint;
blockHash: string;
returnData: Multicall2.ResultStructOutput[];
}
], "nonpayable">;
getFunction(nameOrSignature: "getBlockHash"): TypedContractMethod<[blockNumber: BigNumberish], [string], "view">;
getFunction(nameOrSignature: "getBlockNumber"): TypedContractMethod<[], [bigint], "view">;
getFunction(nameOrSignature: "getCurrentBlockCoinbase"): TypedContractMethod<[], [string], "view">;
getFunction(nameOrSignature: "getCurrentBlockDifficulty"): TypedContractMethod<[], [bigint], "view">;
getFunction(nameOrSignature: "getCurrentBlockGasLimit"): TypedContractMethod<[], [bigint], "view">;
getFunction(nameOrSignature: "getCurrentBlockTimestamp"): TypedContractMethod<[], [bigint], "view">;
getFunction(nameOrSignature: "getEthBalance"): TypedContractMethod<[addr: AddressLike], [bigint], "view">;
getFunction(nameOrSignature: "getLastBlockHash"): TypedContractMethod<[], [string], "view">;
getFunction(nameOrSignature: "tryAggregate"): TypedContractMethod<[
requireSuccess: boolean,
calls: Multicall2.CallStruct[]
], [
Multicall2.ResultStructOutput[]
], "nonpayable">;
getFunction(nameOrSignature: "tryBlockAndAggregate"): TypedContractMethod<[
requireSuccess: boolean,
calls: Multicall2.CallStruct[]
], [
[
bigint,
string,
Multicall2.ResultStructOutput[]
] & {
blockNumber: bigint;
blockHash: string;
returnData: Multicall2.ResultStructOutput[];
}
], "nonpayable">;
filters: {};
}