-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
55 lines (51 loc) · 1.7 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
import React, { ReactNode, useEffect } from 'react';
import ReactDOM from 'react-dom/client';
import './App.css';
import 'react-toastify/dist/ReactToastify.css';
import { ToastContainer } from 'react-toastify';
import Component from './components/index';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ConnectKitProvider } from 'connectkit';
import initNoirWasm from '@noir-lang/noir_wasm';
import initNoirC from '@noir-lang/noirc_abi';
import initACVM from '@noir-lang/acvm_js';
import { WagmiConfig } from 'wagmi';
import { config } from './utils/wagmi';
const InitWasm = ({ children }) => {
const [init, setInit] = React.useState(false);
useEffect(() => {
(async () => {
await Promise.all([
initNoirWasm(
new URL('@noir-lang/noir_wasm/web/noir_wasm_bg.wasm', import.meta.url).toString(),
),
initACVM(new URL('@noir-lang/acvm_js/web/acvm_js_bg.wasm', import.meta.url).toString()),
initNoirC(
new URL('@noir-lang/noirc_abi/web/noirc_abi_wasm_bg.wasm', import.meta.url).toString(),
),
]);
setInit(true);
})();
});
return <div>{init && children}</div>;
};
const queryClient = new QueryClient();
export function Web3Provider({ children }: { children: React.ReactNode }) {
return (
<WagmiConfig config={config}>
<QueryClientProvider client={queryClient}>
<ConnectKitProvider debugMode theme="rounded">
{children}
</ConnectKitProvider>
</QueryClientProvider>
</WagmiConfig>
);
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<Web3Provider>
<InitWasm>
<Component />
<ToastContainer />
</InitWasm>
</Web3Provider>,
);