-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathuseAirdrop.ts
50 lines (42 loc) · 1.27 KB
/
useAirdrop.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { zeroAddress } from 'viem';
import { useWeb3 } from './useWeb3';
import {
airdropABI,
usePrepareAirdropClaim as _usePrepareAirdropClaim,
useAirdropClaimed as _useAirdropClaimed,
useAirdropStreams as _useAirdropStreams,
} from 'types/abi';
import useContract from './useContract';
export const useAirdrop = () => {
return useContract('Airdrop', airdropABI);
};
export const usePrepareAirdropClaim = (args?: Parameters<typeof _usePrepareAirdropClaim>[0]) => {
const { chain, walletAddress } = useWeb3();
const airdrop = useAirdrop();
return _usePrepareAirdropClaim({
...args,
account: walletAddress ?? zeroAddress,
chainId: chain.id,
address: airdrop?.address,
});
};
export const useAirdropClaimed = (args?: { watch?: boolean }) => {
const { chain, walletAddress } = useWeb3();
const airdrop = useAirdrop();
return _useAirdropClaimed({
...args,
chainId: chain.id,
address: airdrop?.address,
args: [walletAddress ?? zeroAddress],
});
};
export const useAirdropStreams = (args?: { watch?: boolean }) => {
const { chain, walletAddress } = useWeb3();
const airdrop = useAirdrop();
return _useAirdropStreams({
...args,
chainId: chain.id,
address: airdrop?.address,
args: [walletAddress ?? zeroAddress],
});
};