-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
101 lines (95 loc) · 2.52 KB
/
Copy pathApp.tsx
File metadata and controls
101 lines (95 loc) · 2.52 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
// App.tsx
import React, { useEffect } from "react";
import { View, Text, Platform, StyleSheet } from "react-native";
import { DaimoPayProvider, DaimoPayButton, getDefaultConfig } from "@daimo/pay";
import { baseUSDC, optimismUSDC } from "@daimo/pay-common";
import { WagmiProvider, createConfig } from "wagmi";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { getAddress } from "viem";
// Add minimal CSS reset for web
if (Platform.OS === "web") {
const style = document.createElement("style");
style.textContent = `
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: -apple-system, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#root {
height: 100vh;
}
`;
document.head.appendChild(style);
}
const wagmiConfig = createConfig(
getDefaultConfig({
appName: "Daimo Expo Web Demo",
})
);
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: (failureCount, error) => {
// Don't retry on wallet-related errors
if (
error?.message?.includes("wallet") ||
error?.message?.includes("ethereum")
) {
return false;
}
return failureCount < 3;
},
},
},
});
export default function App() {
return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<DaimoPayProvider>
<View style={styles.container}>
<Text style={styles.title}>🔧 Daimo Pay Expo Demo</Text>
<Text style={styles.text}>Rendering from Expo</Text>
<Text style={styles.text}>Platform: {Platform.OS}</Text>
<DaimoPayButton
intent="Deposit"
appId="pay-demo"
toChain={baseUSDC.chainId}
toToken={getAddress(baseUSDC.token)}
toAddress="0x4E04D236A5aEd4EB7d95E0514c4c8394c690BB58"
/>
</View>
</DaimoPayProvider>
</QueryClientProvider>
</WagmiProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#f8f9fa",
padding: 20,
},
title: {
fontSize: 24,
fontWeight: "bold",
color: "#374151", // Dark gray
marginBottom: 20,
textAlign: "center",
},
text: {
fontSize: 16,
color: "#6b7280",
marginBottom: 10,
textAlign: "center",
},
});