-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathindex.tsx
65 lines (59 loc) · 1.46 KB
/
index.tsx
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
54
55
56
57
58
59
60
61
62
63
64
65
import React from "react";
import Header from "./Header";
import styles from "./styles.module.css";
import {
MetaMask,
OkxWallet,
TokenPocket,
WagmiWeb3ConfigProvider,
WalletConnect,
Hardhat,
Sepolia,
} from "@ant-design/web3-wagmi";
import { useAccount, http } from "wagmi";
interface WtfLayoutProps {
children: React.ReactNode;
}
const LayoutContent: React.FC<WtfLayoutProps> = ({ children }) => {
const { address } = useAccount();
const [loading, setLoading] = React.useState(true);
React.useEffect(() => {
setLoading(false);
}, []);
if (loading || !address) {
return <div className={styles.connectTip}>Please Connect First.</div>;
}
return children;
};
const WtfLayout: React.FC<WtfLayoutProps> = ({ children }) => {
return (
<WagmiWeb3ConfigProvider
eip6963={{
autoAddInjectedWallets: true,
}}
chains={[Sepolia, Hardhat]}
transports={{
[Hardhat.id]: http("http://127.0.0.1:8545"),
[Sepolia.id]: http("https://api.zan.top/public/eth-sepolia"),
}}
ens
wallets={[
MetaMask(),
WalletConnect(),
TokenPocket({
group: "Popular",
}),
OkxWallet(),
]}
walletConnect={{
projectId: "c07c0051c2055890eade3556618e38a6",
}}
>
<div className={styles.layout}>
<Header />
<LayoutContent>{children}</LayoutContent>
</div>
</WagmiWeb3ConfigProvider>
);
};
export default WtfLayout;