-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathApp.tsx
107 lines (92 loc) · 2.5 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { StyleSheet, View, useColorScheme } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import * as Clipboard from 'expo-clipboard';
import '@walletconnect/react-native-compat';
import { WagmiProvider } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import {
Web3Modal,
W3mButton,
W3mNetworkButton,
createWeb3Modal,
defaultWagmiConfig
} from '@web3modal/wagmi-react-native';
import { emailConnector } from '@web3modal/email-wagmi-react-native';
import { siweConfig } from './src/utils/SiweUtils';
import { AccountView } from './src/views/AccountView';
import { ActionsView } from './src/views/ActionsView';
import { getCustomWallets } from './src/utils/misc';
import { chains } from './src/utils/WagmiUtils';
const projectId = process.env.EXPO_PUBLIC_PROJECT_ID ?? '';
const metadata = {
name: 'Web3Modal RN',
description: 'Web3Modal RN by WalletConnect',
url: 'https://walletconnect.com/',
icons: ['https://avatars.githubusercontent.com/u/37784886'],
redirect: {
native: 'redirect://'
}
};
const clipboardClient = {
setString: async (value: string) => {
await Clipboard.setStringAsync(value);
}
};
const emailConn = emailConnector({ projectId, metadata });
const wagmiConfig = defaultWagmiConfig({
chains,
projectId,
metadata,
extraConnectors: [emailConn]
});
const queryClient = new QueryClient();
const customWallets = getCustomWallets();
createWeb3Modal({
projectId,
wagmiConfig,
siweConfig,
clipboardClient,
customWallets,
enableAnalytics: true,
metadata
});
export default function Native() {
const isDarkMode = useColorScheme() === 'dark';
return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<View style={[styles.container, isDarkMode && styles.dark]}>
<StatusBar style="auto" />
<W3mButton
connectStyle={styles.button}
accountStyle={styles.button}
label="Connect"
loadingLabel="Connecting..."
balance="show"
/>
<W3mNetworkButton />
<AccountView />
<ActionsView />
<Web3Modal />
</View>
</QueryClientProvider>
</WagmiProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ffffff'
},
dark: {
backgroundColor: '#141414'
},
text: {
marginBottom: 20
},
button: {
marginVertical: 6
}
});