1- import { type MulticallConfig , multicall as masterMulticall } from '@wagmi/core'
1+ import { multicall as masterMulticall } from '@wagmi/core'
2+ import { type ContractFunctionConfig , type MulticallParameters } from 'viem'
23
3- import type { MulticallArgs , Writeable } from '../types'
4+ import type { MulticallArgs } from '../types'
45
5- export async function multicall ( params : MulticallArgs ) {
6- const contracts : Writeable < MulticallConfig [ 'contracts' ] > = [ ]
6+ export async function multicall < TContracts extends ContractFunctionConfig [ ] , TAllowFailure extends boolean = true > (
7+ params : MulticallArgs < TAllowFailure >
8+ ) {
9+ // @ts -ignore
10+ const contracts : TContracts = [ ] as TContracts
711
812 params . calls . forEach ( ( item ) => {
913 item . calls . forEach ( ( [ functionName , args ] ) => {
@@ -16,9 +20,9 @@ export async function multicall(params: MulticallArgs) {
1620 } )
1721 } )
1822
19- return await masterMulticall ( {
23+ return await masterMulticall < TContracts , TAllowFailure > ( {
2024 chainId : params . chainId ,
21- contracts,
25+ contracts : contracts as MulticallParameters < TContracts , TAllowFailure > [ 'contracts' ] ,
2226 multicallAddress : params . multicallAddress ,
2327 blockTag : params . blockTag ,
2428 blockNumber : params . blockNumber ,
0 commit comments