-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathApp.tsx
More file actions
131 lines (116 loc) · 3.14 KB
/
App.tsx
File metadata and controls
131 lines (116 loc) · 3.14 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { Platform, SafeAreaView, StyleSheet, 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 Toast from 'react-native-toast-message';
import {
AppKit,
AppKitButton,
NetworkButton,
createAppKit,
defaultWagmiConfig
} from '@reown/appkit-wagmi-react-native';
import { authConnector } from '@reown/appkit-auth-wagmi-react-native';
import { Text } from '@reown/appkit-ui-react-native';
import { siweConfig } from './src/utils/SiweUtils';
import { AccountView } from './src/views/AccountView';
import { ActionsView } from './src/views/ActionsView';
import { chains } from './src/utils/WagmiUtils';
import { OpenButton } from './src/components/OpenButton';
import { DisconnectButton } from './src/components/DisconnectButton';
const projectId = process.env.EXPO_PUBLIC_PROJECT_ID ?? '';
const metadata = {
name: 'AppKit RN',
description: 'AppKit RN by Reown',
url: 'https://reown.com/appkit',
icons: ['https://avatars.githubusercontent.com/u/179229932'],
redirect: {
native: 'host.exp.exponent://',
universal: 'https://appkit-lab.reown.com/rn_appkit'
}
};
const clipboardClient = {
setString: async (value: string) => {
await Clipboard.setStringAsync(value);
}
};
const auth = authConnector({ projectId, metadata });
const extraConnectors = Platform.select({
ios: [auth],
android: [auth],
default: []
});
const wagmiConfig = defaultWagmiConfig({
chains,
projectId,
metadata,
extraConnectors
});
const queryClient = new QueryClient();
createAppKit({
projectId,
wagmiConfig,
siweConfig,
clipboardClient,
enableAnalytics: true,
metadata,
debug: true,
features: {
email: true,
socials: ['x', 'discord', 'apple'],
emailShowWallets: true,
swaps: true,
onramp: true
}
});
export default function Native() {
const isDarkMode = useColorScheme() === 'dark';
return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<SafeAreaView style={[styles.container, isDarkMode && styles.dark]}>
<StatusBar style="auto" />
<Text variant="medium-title-600" style={styles.title}>
AppKit for React Native
</Text>
<AppKitButton
connectStyle={styles.button}
accountStyle={styles.button}
label="Connect"
loadingLabel="Connecting..."
balance="show"
/>
<NetworkButton />
<ActionsView />
<AccountView />
<OpenButton />
<DisconnectButton />
<AppKit />
</SafeAreaView>
<Toast />
</QueryClientProvider>
</WagmiProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ffffff'
},
dark: {
backgroundColor: '#141414'
},
text: {
marginBottom: 20
},
title: {
marginBottom: 30
},
button: {
marginVertical: 6
}
});