-
Notifications
You must be signed in to change notification settings - Fork 0
/
wagmi.ts
53 lines (49 loc) · 1.33 KB
/
wagmi.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
51
52
53
'use client';
import { connectorsForWallets } from '@rainbow-me/rainbowkit';
import {
coinbaseWallet,
metaMaskWallet,
rainbowWallet,
} from '@rainbow-me/rainbowkit/wallets';
import { useMemo } from 'react';
import { http, createConfig } from 'wagmi';
import { base, baseSepolia } from 'wagmi/chains';
import { NEXT_PUBLIC_WC_PROJECT_ID } from './config';
export function useWagmiConfig() {
const projectId = NEXT_PUBLIC_WC_PROJECT_ID ?? '';
if (!projectId) {
const providerErrMessage =
'To connect to all Wallets you need to provide a NEXT_PUBLIC_WC_PROJECT_ID env variable';
throw new Error(providerErrMessage);
}
return useMemo(() => {
const connectors = connectorsForWallets(
[
{
groupName: 'Recommended Wallet',
wallets: [coinbaseWallet],
},
{
groupName: 'Other Wallets',
wallets: [rainbowWallet, metaMaskWallet],
},
],
{
appName: 'onchainkit',
projectId,
},
);
const wagmiConfig = createConfig({
chains: [base, baseSepolia],
// turn off injected provider discovery
multiInjectedProviderDiscovery: false,
connectors,
ssr: true,
transports: {
[base.id]: http(),
[baseSepolia.id]: http(),
},
});
return wagmiConfig;
}, [projectId]);
}