@coinbase/create-cdp-app 0.0.36 β†’ 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +22 -9
  2. package/dist/index.js +168 -46
  3. package/dist/index.js.map +1 -1
  4. package/package.json +1 -1
  5. package/template-nextjs/README.md +3 -2
  6. package/template-nextjs/env.example +2 -0
  7. package/template-nextjs/package.json +3 -1
  8. package/template-nextjs/public/sol.svg +13 -0
  9. package/template-nextjs/src/app/globals.css +6 -0
  10. package/template-nextjs/src/components/Providers.tsx +32 -14
  11. package/template-nextjs/src/components/SignedInScreen.tsx +63 -15
  12. package/template-nextjs/src/components/SignedInScreenWithOnramp.tsx +22 -3
  13. package/template-nextjs/src/components/SolanaTransaction.tsx +157 -0
  14. package/template-nextjs/src/components/UserBalance.tsx +5 -3
  15. package/template-react/README.md +2 -1
  16. package/template-react/env.example +3 -0
  17. package/template-react/package.json +3 -1
  18. package/template-react/public/sol.svg +13 -0
  19. package/template-react/src/Header.tsx +20 -8
  20. package/template-react/src/SignedInScreen.tsx +66 -13
  21. package/template-react/src/SolanaTransaction.tsx +158 -0
  22. package/template-react/src/UserBalance.tsx +29 -10
  23. package/template-react/src/config.ts +25 -11
  24. package/template-react/src/index.css +6 -0
  25. package/template-react/src/main.tsx +2 -2
  26. package/template-react-native/App.tsx +79 -62
  27. package/template-react-native/EOATransaction.tsx +35 -22
  28. package/template-react-native/SmartAccountTransaction.tsx +9 -9
  29. package/template-react-native/components/SignInForm.tsx +433 -0
  30. package/template-react-native/types.ts +0 -22
  31. package/template-react-native/components/SignInModal.tsx +0 -342
@@ -1,342 +0,0 @@
1
- import React from "react";
2
- import {
3
- Modal,
4
- Animated,
5
- View,
6
- TouchableOpacity,
7
- Text,
8
- TextInput,
9
- KeyboardAvoidingView,
10
- Platform,
11
- StyleSheet,
12
- } from "react-native";
13
- import { useTheme } from "../theme/ThemeContext";
14
- import { SignInModalProps } from "../types";
15
-
16
- export const SignInModal: React.FC<SignInModalProps> = ({
17
- visible,
18
- onClose,
19
- authMethod,
20
- onAuthMethodToggle,
21
- email,
22
- setEmail,
23
- phoneNumber,
24
- setPhoneNumber,
25
- otp,
26
- setOtp,
27
- flowId,
28
- isLoading,
29
- onSignIn,
30
- onVerifyOTP,
31
- slideAnim,
32
- }) => {
33
- const { colors } = useTheme();
34
-
35
- const createStyles = () =>
36
- StyleSheet.create({
37
- modalOverlay: {
38
- flex: 1,
39
- backgroundColor: "rgba(0, 0, 0, 0.5)",
40
- justifyContent: "flex-end",
41
- },
42
- modalContainer: {
43
- backgroundColor: colors.cardBackground,
44
- borderTopLeftRadius: 16,
45
- borderTopRightRadius: 16,
46
- minHeight: "60%",
47
- maxHeight: "90%",
48
- },
49
- modalContent: {
50
- flex: 1,
51
- padding: 24,
52
- },
53
- modalCloseButton: {
54
- position: "absolute",
55
- top: 16,
56
- right: 16,
57
- zIndex: 1,
58
- width: 32,
59
- height: 32,
60
- borderRadius: 16,
61
- backgroundColor: "rgba(255, 255, 255, 0.1)",
62
- justifyContent: "center",
63
- alignItems: "center",
64
- },
65
- modalCloseText: {
66
- color: colors.text,
67
- fontSize: 20,
68
- fontWeight: "300",
69
- textAlign: "center",
70
- lineHeight: 20,
71
- includeFontPadding: false,
72
- },
73
- modalHeader: {
74
- alignItems: "center",
75
- marginTop: 32,
76
- marginBottom: 32,
77
- },
78
- logoCircle: {
79
- width: 64,
80
- height: 64,
81
- borderRadius: 32,
82
- backgroundColor: colors.accent,
83
- justifyContent: "center",
84
- alignItems: "center",
85
- },
86
- logoText: {
87
- color: "#ffffff",
88
- fontSize: 32,
89
- fontWeight: "bold",
90
- },
91
- modalTitle: {
92
- fontSize: 24,
93
- fontWeight: "500",
94
- color: colors.text,
95
- textAlign: "center",
96
- marginTop: 16,
97
- },
98
- modalForm: {
99
- flex: 1,
100
- },
101
- inputLabel: {
102
- fontSize: 16,
103
- fontWeight: "500",
104
- color: colors.text,
105
- marginBottom: 8,
106
- },
107
- modalInput: {
108
- backgroundColor: colors.inputBackground,
109
- borderRadius: 8,
110
- borderWidth: 1,
111
- borderColor: colors.border,
112
- paddingHorizontal: 16,
113
- paddingVertical: 14,
114
- fontSize: 16,
115
- color: colors.text,
116
- marginBottom: 24,
117
- },
118
- inputContainer: {
119
- flexDirection: "row",
120
- alignItems: "stretch",
121
- marginBottom: 24,
122
- },
123
- flagContainer: {
124
- flexDirection: "row",
125
- alignItems: "center",
126
- paddingHorizontal: 12,
127
- paddingVertical: 14,
128
- borderWidth: 1,
129
- borderColor: colors.border,
130
- borderTopLeftRadius: 8,
131
- borderBottomLeftRadius: 8,
132
- backgroundColor: colors.inputBackground,
133
- },
134
- flagText: {
135
- fontSize: 16,
136
- marginRight: 4,
137
- },
138
- countryCode: {
139
- fontSize: 16,
140
- color: colors.text,
141
- fontWeight: "500",
142
- },
143
- phoneInput: {
144
- backgroundColor: colors.inputBackground,
145
- borderRadius: 0,
146
- borderTopRightRadius: 8,
147
- borderBottomRightRadius: 8,
148
- borderWidth: 1,
149
- borderLeftWidth: 0,
150
- borderColor: colors.border,
151
- paddingHorizontal: 16,
152
- paddingVertical: 14,
153
- fontSize: 16,
154
- color: colors.text,
155
- flex: 1,
156
- },
157
- continueButton: {
158
- backgroundColor: colors.accent,
159
- borderRadius: 8,
160
- paddingVertical: 16,
161
- alignItems: "center",
162
- marginBottom: 24,
163
- },
164
- continueButtonText: {
165
- color: "#ffffff",
166
- fontSize: 16,
167
- fontWeight: "600",
168
- },
169
- buttonDisabled: {
170
- opacity: 0.6,
171
- },
172
- dividerContainer: {
173
- flexDirection: "row",
174
- alignItems: "center",
175
- marginBottom: 24,
176
- },
177
- dividerLine: {
178
- flex: 1,
179
- height: 1,
180
- backgroundColor: colors.border,
181
- },
182
- dividerText: {
183
- color: colors.textSecondary,
184
- fontSize: 14,
185
- marginHorizontal: 16,
186
- },
187
- phoneButton: {
188
- backgroundColor: colors.inputBackground,
189
- borderRadius: 8,
190
- borderWidth: 1,
191
- borderColor: colors.border,
192
- paddingVertical: 16,
193
- flexDirection: "row",
194
- alignItems: "center",
195
- justifyContent: "center",
196
- marginBottom: 32,
197
- },
198
- phoneIcon: {
199
- fontSize: 18,
200
- marginRight: 8,
201
- },
202
- phoneButtonText: {
203
- color: colors.text,
204
- fontSize: 16,
205
- fontWeight: "500",
206
- },
207
- });
208
-
209
- const styles = createStyles();
210
-
211
- return (
212
- <Modal visible={visible} transparent={true} animationType="none" onRequestClose={onClose}>
213
- <View style={styles.modalOverlay}>
214
- <Animated.View
215
- style={[
216
- styles.modalContainer,
217
- {
218
- transform: [{ translateY: slideAnim }],
219
- },
220
- ]}
221
- >
222
- <KeyboardAvoidingView
223
- behavior={Platform.OS === "ios" ? "padding" : "height"}
224
- style={styles.modalContent}
225
- >
226
- <TouchableOpacity style={styles.modalCloseButton} onPress={onClose}>
227
- <Text style={styles.modalCloseText}>Γ—</Text>
228
- </TouchableOpacity>
229
-
230
- <View style={styles.modalHeader}>
231
- <View style={styles.logoCircle}>
232
- <Text style={styles.logoText}>C</Text>
233
- </View>
234
- <Text style={styles.modalTitle}>
235
- {flowId ? "Enter verification code" : "Sign in"}
236
- </Text>
237
- </View>
238
-
239
- {flowId ? (
240
- <View style={styles.modalForm}>
241
- <Text style={styles.inputLabel}>Verification code</Text>
242
- <TextInput
243
- style={styles.modalInput}
244
- value={otp}
245
- onChangeText={setOtp}
246
- placeholder="Enter 6-digit code"
247
- keyboardType="number-pad"
248
- maxLength={6}
249
- editable={!isLoading}
250
- placeholderTextColor={colors.textSecondary}
251
- returnKeyType="done"
252
- onSubmitEditing={onVerifyOTP}
253
- blurOnSubmit={true}
254
- />
255
-
256
- <TouchableOpacity
257
- style={[styles.continueButton, isLoading && styles.buttonDisabled]}
258
- onPress={onVerifyOTP}
259
- disabled={isLoading}
260
- >
261
- <Text style={styles.continueButtonText}>
262
- {isLoading ? "Verifying..." : "Continue"}
263
- </Text>
264
- </TouchableOpacity>
265
- </View>
266
- ) : (
267
- <View style={styles.modalForm}>
268
- <Text style={styles.inputLabel}>
269
- {authMethod === "email" ? "Email address" : "Phone number"}
270
- </Text>
271
- {authMethod === "sms" ? (
272
- <View style={styles.inputContainer}>
273
- <View style={styles.flagContainer}>
274
- <Text style={styles.flagText}>πŸ‡ΊπŸ‡Έ</Text>
275
- <Text style={styles.countryCode}>+1</Text>
276
- </View>
277
- <TextInput
278
- style={styles.phoneInput}
279
- value={phoneNumber}
280
- onChangeText={setPhoneNumber}
281
- placeholder="(000) 000-0000"
282
- keyboardType="phone-pad"
283
- autoCapitalize="none"
284
- autoCorrect={false}
285
- editable={!isLoading}
286
- placeholderTextColor={colors.textSecondary}
287
- returnKeyType="done"
288
- onSubmitEditing={onSignIn}
289
- blurOnSubmit={true}
290
- />
291
- </View>
292
- ) : (
293
- <TextInput
294
- style={styles.modalInput}
295
- value={email}
296
- onChangeText={setEmail}
297
- placeholder="name@example.com"
298
- keyboardType="email-address"
299
- autoCapitalize="none"
300
- autoCorrect={false}
301
- editable={!isLoading}
302
- placeholderTextColor={colors.textSecondary}
303
- returnKeyType="done"
304
- onSubmitEditing={onSignIn}
305
- blurOnSubmit={true}
306
- />
307
- )}
308
-
309
- <TouchableOpacity
310
- style={[styles.continueButton, isLoading && styles.buttonDisabled]}
311
- onPress={onSignIn}
312
- disabled={isLoading}
313
- >
314
- <Text style={styles.continueButtonText}>
315
- {isLoading ? "Sending..." : "Continue"}
316
- </Text>
317
- </TouchableOpacity>
318
-
319
- <View style={styles.dividerContainer}>
320
- <View style={styles.dividerLine} />
321
- <Text style={styles.dividerText}>OR</Text>
322
- <View style={styles.dividerLine} />
323
- </View>
324
-
325
- <TouchableOpacity
326
- style={styles.phoneButton}
327
- onPress={onAuthMethodToggle}
328
- disabled={isLoading}
329
- >
330
- <Text style={styles.phoneIcon}>{authMethod === "email" ? "πŸ“ž" : "βœ‰οΈ"}</Text>
331
- <Text style={styles.phoneButtonText}>
332
- Continue with {authMethod === "email" ? "phone" : "email"}
333
- </Text>
334
- </TouchableOpacity>
335
- </View>
336
- )}
337
- </KeyboardAvoidingView>
338
- </Animated.View>
339
- </View>
340
- </Modal>
341
- );
342
- };