Skip to content

Commit ac823de

Browse files
committed
fixed multicall
1 parent 709cd60 commit ac823de

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

lib/actions/multicall.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
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,

lib/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ export type MulticallContract = {
6464
calls: [string, Array<any>?][]
6565
}
6666

67-
export type MulticallArgs = {
67+
export type MulticallArgs<TAllowFailure extends boolean = true> = {
6868
chainId?: number
6969
calls: MulticallContract[]
7070
multicallAddress?: `0x${string}`
7171
batchSize?: number
72-
allowFailure?: boolean
72+
allowFailure?: TAllowFailure
7373
} & (
7474
| {
7575
blockNumber?: bigint
@@ -174,5 +174,3 @@ export type SendTransaction = {
174174
value?: bigint
175175
confirmations?: number
176176
}
177-
178-
export type Writeable<T> = { -readonly [P in keyof T]: T[P] }

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kolirt/vue-web3-auth",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Web3 authentication for Vue3 apps based on WalletConnect Web3Modal v2",
55
"author": "kolirt",
66
"license": "MIT",

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
22
import { computed, reactive } from 'vue'
33
4-
import type { Chain } from '../lib'
54
import {
65
$off,
76
$on,
7+
type Chain,
88
Events,
99
account,
1010
accountDetails,

0 commit comments

Comments
 (0)