Skip to content

Commit cf44b1c

Browse files
committed
add multicall
1 parent dbdedd5 commit cf44b1c

File tree

13 files changed

+531
-108
lines changed

13 files changed

+531
-108
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
dev:
2-
yarn dev-docs
2+
yarn dev-demo
33
build:
4-
yarn build-lib && yarn build-docs
5-
build-docs:
6-
yarn build-docs
4+
yarn build-lib && yarn build-demo
5+
build-demo:
6+
yarn build-demo
77
build-lib:
88
yarn build-lib
99
preview:
10-
yarn preview-docs
10+
yarn preview-demo

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Simple WalletConnect v2 integration package for Vue3 apps.
1414
- [Setup](#setup)
1515
- [Usage](#usage)
1616
- [Connect wallet button](#connect-wallet-button)
17+
- [Multicall](#multicall)
1718
- [Demo](#demo)
1819
- [Example](#example)
1920
- [Faq](#faq)
@@ -74,6 +75,35 @@ import {account, disconnect, connect} from '@kolirt/vue-web3-auth'
7475
</template>
7576
```
7677

78+
## Multicall
79+
```js
80+
import {MulticallAbi, multicall, chain} from '@kolirt/vue-web3-auth'
81+
82+
let data = await multicall({
83+
calls: [
84+
{
85+
abi: MulticallAbi,
86+
contractAddress: chain.value.contracts.multicall3.address,
87+
calls: [
88+
['getEthBalance', ['0x2D4C407BBe49438ED859fe965b140dcF1aaB71a9']],
89+
['getEthBalance', ['0x295e26495CEF6F69dFA69911d9D8e4F3bBadB89B']],
90+
['getEthBalance', ['0x2465176C461AfB316ebc773C61fAEe85A6515DAA']]
91+
]
92+
}
93+
]
94+
})
95+
96+
/**
97+
* Result in data
98+
*
99+
* [
100+
* {result: 1908669631824871303n, status: "success"},
101+
* {result: 133515691552422277n, status: "success"},
102+
* {result: 2080909582708869960n, status: "success"}
103+
* ]
104+
*/
105+
```
106+
77107
# Demo
78108
[Demo here](https://kolirt.github.io/vue-web3-auth/).
79109

dist/vue-web3-auth.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type { BlockTag } from 'viem/src/types/block';
12
import type { Chain } from '@wagmi/core';
23
import * as Chains from '@wagmi/core/chains';
34
import type { ComputedRef } from 'vue';
5+
import MulticallAbi from './utils/abi/multicall.json';
46
import type { Plugin as Plugin_2 } from 'vue';
57
import type { ThemeCtrlState } from '@web3modal/core';
68

@@ -39,6 +41,30 @@ export { Event_2 as Event }
3941

4042
export declare function getAvailableChains(): Chain[];
4143

44+
export declare function multicall(params: MulticallArgs): Promise<unknown[]>;
45+
46+
export { MulticallAbi }
47+
48+
declare type MulticallArgs = {
49+
chainId?: number;
50+
calls: MulticallContract[];
51+
multicallAddress?: `0x${string}`;
52+
batchSize?: number;
53+
allowFailure?: boolean;
54+
} & ({
55+
blockNumber?: bigint;
56+
blockTag?: never;
57+
} | {
58+
blockNumber?: never;
59+
blockTag?: BlockTag;
60+
});
61+
62+
declare type MulticallContract = {
63+
abi: {};
64+
contractAddress: string;
65+
calls: [string, Array<any>?][];
66+
};
67+
4268
export declare type Options = {
4369
autoInit?: boolean;
4470
projectId: string;

0 commit comments

Comments
 (0)