-
Notifications
You must be signed in to change notification settings - Fork 45
/
_app.tsx
83 lines (75 loc) · 2.27 KB
/
_app.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import '@interchain-ui/react/styles';
import '@interchain-ui/react/globalStyles';
import type { AppProps } from 'next/app';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
// import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { SignerOptions, wallets } from 'cosmos-kit';
import { ChainProvider } from '@cosmos-kit/react';
import { chains, assets } from 'chain-registry';
import { GasPrice } from '@cosmjs/stargate';
import {
Box,
Toaster,
useTheme,
useColorModeValue,
ThemeProvider,
} from '@interchain-ui/react';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 2,
refetchOnWindowFocus: false,
},
},
});
function CreateCosmosApp({ Component, pageProps }: AppProps) {
const { themeClass } = useTheme();
const signerOptions: SignerOptions = {
signingStargate: (chain) => {
let gasPrice;
try {
const feeToken = chain.fees?.fee_tokens[0];
const fee = `${feeToken?.average_gas_price || 0.025}${feeToken?.denom}`;
gasPrice = GasPrice.fromString(fee);
} catch (error) {
gasPrice = GasPrice.fromString('0.025uosmo');
}
return { gasPrice };
},
};
return (
<ThemeProvider>
<ChainProvider
chains={chains}
assetLists={assets}
wallets={wallets}
walletConnectOptions={{
signClient: {
projectId: 'a8510432ebb71e6948cfd6cde54b70f7',
relayUrl: 'wss://relay.walletconnect.org',
metadata: {
name: 'CosmosKit Template',
description: 'CosmosKit dapp template',
url: 'https://docs.cosmology.zone/cosmos-kit/',
icons: [],
},
},
}}
signerOptions={signerOptions}
>
<QueryClientProvider client={queryClient}>
<Box
className={themeClass}
minHeight="100dvh"
backgroundColor={useColorModeValue('$white', '$background')}
>
<Component {...pageProps} />
<Toaster position="top-right" closeButton={true} />
</Box>
{/* <ReactQueryDevtools /> */}
</QueryClientProvider>
</ChainProvider>
</ThemeProvider>
);
}
export default CreateCosmosApp;