-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathApp.tsx
More file actions
154 lines (140 loc) · 4.23 KB
/
App.tsx
File metadata and controls
154 lines (140 loc) · 4.23 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import { 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 { SafeAreaProvider } from 'react-native-safe-area-context';
import Toast from 'react-native-toast-message';
import {
AppKitProvider,
// ReownAuthentication,
createAppKit,
AppKit,
AppKitButton,
NetworkButton,
solana,
bitcoin
} from '@reown/appkit-react-native';
import { Button, Text } from '@reown/appkit-ui-react-native';
import { chains } from './src/utils/WagmiUtils';
import { OpenButton } from './src/components/OpenButton';
import { DisconnectButton } from './src/components/DisconnectButton';
import {
SolanaAdapter,
PhantomConnector,
SolflareConnector
} from '@reown/appkit-solana-react-native';
import { BitcoinAdapter } from '@reown/appkit-bitcoin-react-native';
import { WagmiAdapter } from '@reown/appkit-wagmi-react-native';
import { ActionsView } from './src/views/ActionsView';
import { WalletInfoView } from './src/views/WalletInfoView';
import { EventsView } from './src/views/EventsView';
import { storage } from './src/utils/StorageUtil';
const projectId = process.env.EXPO_PUBLIC_PROJECT_ID ?? '';
const metadata = {
name: 'AppKit Multichain',
description: 'AppKit Multichain 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 queryClient = new QueryClient();
const wagmiAdapter = new WagmiAdapter({
projectId,
networks: [...chains]
});
const solanaAdapter = new SolanaAdapter();
const bitcoinAdapter = new BitcoinAdapter();
const appKit = createAppKit({
projectId,
adapters: [wagmiAdapter, solanaAdapter, bitcoinAdapter],
metadata,
networks: [...chains, solana, bitcoin],
defaultNetwork: chains[0],
clipboardClient,
debug: true,
enableAnalytics: true,
storage,
// siwx: new ReownAuthentication(),
extraConnectors: [new PhantomConnector(), new SolflareConnector()]
// tokens: {
// 'eip155:1': {
// address: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
// },
// 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': {
// address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC SPL token
// }
// }
});
export default function Native() {
const isDarkMode = useColorScheme() === 'dark';
return (
<SafeAreaProvider>
<WagmiProvider config={wagmiAdapter.wagmiConfig}>
<AppKitProvider instance={appKit}>
<QueryClientProvider client={queryClient}>
<SafeAreaView style={[styles.container, isDarkMode && styles.dark]}>
<StatusBar style="auto" />
<Text variant="medium-title-600" style={styles.title}>
AppKit Multichain for React Native
</Text>
<WalletInfoView />
<AppKitButton
connectStyle={styles.button}
accountStyle={styles.button}
label="Connect"
loadingLabel="Connecting..."
balance="show"
/>
<NetworkButton />
<ActionsView />
<OpenButton />
<DisconnectButton />
<Button size="sm" onPress={() => appKit.disconnect()}>
Disconnect
</Button>
<EventsView style={styles.events} />
<AppKit />
</SafeAreaView>
<Toast />
</QueryClientProvider>
</AppKitProvider>
</WagmiProvider>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ffffff'
},
dark: {
backgroundColor: '#141414'
},
text: {
marginBottom: 20
},
title: {
marginBottom: 10
},
button: {
marginVertical: 16
},
walletInfo: {
marginBottom: 10
},
events: {
marginTop: 30
}
});