-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
110 lines (98 loc) · 2.38 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
108
109
110
import {
ConnectWallet,
localWallet,
metamaskWallet,
rainbowWallet,
ThirdwebProvider,
useWallet,
Web3Button,
} from '@thirdweb-dev/react-native';
import React from 'react';
import {
Button,
SafeAreaView,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
const App = () => {
return (
<ThirdwebProvider
autoSwitch={true}
activeChain="mumbai"
supportedWallets={[metamaskWallet(), rainbowWallet(), localWallet()]}>
<AppInner />
</ThirdwebProvider>
);
};
const AppInner = () => {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
const textStyles = {
color: isDarkMode ? Colors.white : Colors.black,
...styles.heading,
};
const [text, setText] = React.useState('');
const wallet = useWallet();
return (
<SafeAreaView style={backgroundStyle}>
<View style={styles.view}>
<Text style={textStyles}>React Native thirdweb testjam</Text>
<View style={{marginBottom: 20}}>
<ConnectWallet />
</View>
<View style={{marginBottom: 20}}>
<Button
title="Sign Message"
onPress={() => {
wallet
?.signMessage('Hello World')
.then(res => {
setText(res);
})
.catch(err => {
setText(err.message);
});
}}
/>
</View>
<Web3Button
connectWalletProps={{
buttonTitle: 'Let`s connect',
modalTitle: 'Pick pick',
}}
onSuccess={res => {
setText('Success');
}}
onError={err => {
setText(err.message);
}}
contractAddress="0xE2d88171037e44FE0A5d64111e635074b790DE89"
action={contract => contract?.erc1155.claim(0, 1)}>
Claim
</Web3Button>
<Text>{text}</Text>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
view: {
height: '100%',
display: 'flex',
marginTop: 10,
justifyContent: 'flex-start',
alignItems: 'center',
alignContent: 'center',
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
});
export default App;