Skip to content

Commit 4a1d5d5

Browse files
committed
Final version
1 parent b7cda03 commit 4a1d5d5

File tree

2 files changed

+155
-157
lines changed

2 files changed

+155
-157
lines changed

src/navigation/screenNames.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ export const SCREEN_NAMES: IScreenNames = {
1717
ConfirmPin: 'ConfirmPin',
1818
Dashboard: 'Dashboard',
1919
VerifyPin: 'VerifyPin',
20+
ExitZKPool: function (_ExitZKPool: any): unknown {
21+
throw new Error("Function not implemented.");
22+
},
23+
EnterZKPool: function (_EnterZKPool: any): unknown {
24+
throw new Error("Function not implemented.");
25+
}
2026
};

src/navigation/screenOnChain.ts

Lines changed: 149 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import React, { useState } from "react";
22
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
3-
import { useNavigation } from "@react-navigation/native";
4-
import { generateInvoice } from "../app/lightning"; // Fixed import path
5-
import { SCREEN_ONX_ADDRESS } from "../app/constants"; // Fixed import path
6-
import { interface as nostrInterface } from "../utils/nostr/encryption"; // Renamed to avoid keyword conflict
3+
import { NavigationProp, useNavigation } from "@react-navigation/native";
4+
import { generateInvoice } from "../app/lightning";
5+
import { SCREEN_ONX_ADDRESS } from "../app/constants";
6+
import * as nostrInterface from "../utils/nostr/encryption"; // Evita conflito de palavras-chave
77

8-
// Define interfaces properly
9-
interface ScreenOnChain {
10-
[SCREEN_ONX_ADDRESS]: {
11-
invoice: string;
12-
};
13-
}
14-
15-
// Define navigation param list
8+
// Tipagem correta dos parâmetros de navegação
169
interface NavigationParams {
1710
OnboardingHome: undefined;
1811
Send: undefined;
@@ -21,162 +14,161 @@ interface NavigationParams {
2114
generateAddress: undefined;
2215
}
2316

24-
export const Receive = () => {
25-
const navigation = useNavigation();
26-
const [bitcoinAddress, setBitcoinAddress] = useState("Generate an address to receive Bitcoin");
27-
const [invoice, setInvoice] = useState<string | null>(null);
17+
// Tipagem para armazenamento de invoice na blockchain
18+
interface ScreenOnChain {
19+
[key in typeof SCREEN_ONX_ADDRESS]: {
20+
invoice: string;
21+
};
22+
}
23+
24+
export const Receive: React.FC = () => {
25+
const navigation = useNavigation<NavigationProp<NavigationParams>>();
26+
const [bitcoinAddress, setBitcoinAddress] = useState(
27+
"Generate an address to receive Bitcoin"
28+
);
29+
const [invoice, setInvoice] = useState<string | null>(null);
2830

29-
// Function to handle copying address to clipboard
30-
const handleCopyAddress = () => {
31-
if (bitcoinAddress !== "Generate an address to receive Bitcoin") {
32-
console.log("Address copied to clipboard:", bitcoinAddress);
33-
} else {
34-
console.log("No address to copy");
35-
}
36-
};
31+
// Copiar endereço para área de transferência
32+
const handleCopyAddress = () => {
33+
if (bitcoinAddress !== "Generate an address to receive Bitcoin") {
34+
console.log("Address copied to clipboard:", bitcoinAddress);
35+
} else {
36+
console.log("No address to copy");
37+
}
38+
};
3739

38-
// Function to generate a new Bitcoin address
39-
const handleGenerateAddress = () => {
40-
const newAddress = "bc1q" + Math.random().toString(36).substring(2, 15);
41-
setBitcoinAddress(newAddress);
42-
};
40+
// Gerar novo endereço Bitcoin
41+
const handleGenerateAddress = () => {
42+
const newAddress = "bc1q" + Math.random().toString(36).substring(2, 15);
43+
setBitcoinAddress(newAddress);
44+
};
45+
46+
// Gerar fatura Lightning
47+
const handleGenerateInvoice = async () => {
48+
try {
49+
const newInvoice = await generateInvoice();
50+
setInvoice(newInvoice);
51+
} catch (error) {
52+
console.error("Failed to generate invoice:", error);
53+
}
54+
};
4355

44-
// Function to generate lightning invoice
45-
const handleGenerateInvoice = async () => {
46-
try {
47-
const newInvoice = await generateInvoice();
48-
setInvoice(newInvoice);
49-
} catch (error) {
50-
console.error("Failed to generate invoice:", error);
51-
}
52-
};
56+
return (
57+
<View style={styles.container}>
58+
<Text style={styles.title}>Receive Bitcoin</Text>
5359

54-
return (
55-
<View style={styles.container}>
56-
<Text style={styles.title}>Receive Bitcoin</Text>
57-
58-
<View style={styles.addressContainer}>
59-
<Text style={styles.label}>Your Bitcoin Address:</Text>
60-
<Text style={styles.address} selectable>
61-
{bitcoinAddress}
62-
</Text>
60+
<View style={styles.addressContainer}>
61+
<Text style={styles.label}>Your Bitcoin Address:</Text>
62+
<Text style={styles.address} selectable>
63+
{bitcoinAddress}
64+
</Text>
6365

64-
<TouchableOpacity
65-
style={styles.copyButton}
66-
onPress={handleCopyAddress}
67-
disabled={bitcoinAddress === "Generate an address to receive Bitcoin"}
68-
>
69-
<Text style={styles.copyButtonText}>Copy Address</Text>
70-
</TouchableOpacity>
66+
<TouchableOpacity
67+
style={styles.copyButton}
68+
onPress={handleCopyAddress}
69+
disabled={bitcoinAddress === "Generate an address to receive Bitcoin"}
70+
>
71+
<Text style={styles.copyButtonText}>Copy Address</Text>
72+
</TouchableOpacity>
7173

72-
<TouchableOpacity
73-
style={styles.generateButton}
74-
onPress={handleGenerateAddress}
75-
>
76-
<Text style={styles.generateButtonText}>Generate New Address</Text>
77-
</TouchableOpacity>
74+
<TouchableOpacity style={styles.generateButton} onPress={handleGenerateAddress}>
75+
<Text style={styles.generateButtonText}>Generate New Address</Text>
76+
</TouchableOpacity>
7877

79-
<TouchableOpacity
80-
style={styles.invoiceButton}
81-
onPress={handleGenerateInvoice}
82-
>
83-
<Text style={styles.invoiceButtonText}>Generate Lightning Invoice</Text>
84-
</TouchableOpacity>
78+
<TouchableOpacity style={styles.invoiceButton} onPress={handleGenerateInvoice}>
79+
<Text style={styles.invoiceButtonText}>Generate Lightning Invoice</Text>
80+
</TouchableOpacity>
8581

86-
{invoice && (
87-
<View style={styles.invoiceContainer}>
88-
<Text style={styles.label}>Lightning Invoice:</Text>
89-
<Text style={styles.address} selectable>
90-
{invoice}
91-
</Text>
92-
</View>
93-
)}
94-
</View>
82+
{invoice && (
83+
<View style={styles.invoiceContainer}>
84+
<Text style={styles.label}>Lightning Invoice:</Text>
85+
<Text style={styles.address} selectable>
86+
{invoice}
87+
</Text>
88+
</View>
89+
)}
90+
</View>
9591

96-
<TouchableOpacity
97-
style={styles.backButton}
98-
onPress={() => navigation.goBack()}
99-
>
100-
<Text style={styles.backButtonText}>Back</Text>
101-
</TouchableOpacity>
102-
</View>
103-
);
92+
<TouchableOpacity style={styles.backButton} onPress={() => navigation.goBack()}>
93+
<Text style={styles.backButtonText}>Back</Text>
94+
</TouchableOpacity>
95+
</View>
96+
);
10497
};
10598

10699
const styles = StyleSheet.create({
107-
container: {
108-
flex: 1,
109-
padding: 20,
110-
backgroundColor: '#fff',
111-
},
112-
title: {
113-
fontSize: 24,
114-
fontWeight: 'bold',
115-
marginBottom: 20,
116-
textAlign: 'center',
117-
},
118-
addressContainer: {
119-
backgroundColor: '#f5f5f5',
120-
padding: 15,
121-
borderRadius: 8,
122-
marginBottom: 20,
123-
},
124-
invoiceContainer: {
125-
marginTop: 15,
126-
},
127-
label: {
128-
fontSize: 16,
129-
marginBottom: 10,
130-
},
131-
address: {
132-
fontSize: 14,
133-
color: '#333',
134-
marginBottom: 15,
135-
wordBreak: 'break-all',
136-
},
137-
copyButton: {
138-
backgroundColor: '#007AFF',
139-
padding: 10,
140-
borderRadius: 5,
141-
alignItems: 'center',
142-
marginBottom: 10,
143-
},
144-
copyButtonText: {
145-
color: '#fff',
146-
fontSize: 16,
147-
},
148-
generateButton: {
149-
backgroundColor: '#4CAF50',
150-
padding: 10,
151-
borderRadius: 5,
152-
alignItems: 'center',
153-
marginBottom: 10,
154-
},
155-
generateButtonText: {
156-
color: '#fff',
157-
fontSize: 16,
158-
},
159-
invoiceButton: {
160-
backgroundColor: '#FFA500',
161-
padding: 10,
162-
borderRadius: 5,
163-
alignItems: 'center',
164-
marginBottom: 10,
165-
},
166-
invoiceButtonText: {
167-
color: '#fff',
168-
fontSize: 16,
169-
},
170-
backButton: {
171-
backgroundColor: '#666',
172-
padding: 10,
173-
borderRadius: 5,
174-
alignItems: 'center',
175-
},
176-
backButtonText: {
177-
color: '#fff',
178-
fontSize: 16,
179-
},
100+
container: {
101+
flex: 1,
102+
padding: 20,
103+
backgroundColor: "#fff",
104+
},
105+
title: {
106+
fontSize: 24,
107+
fontWeight: "bold",
108+
marginBottom: 20,
109+
textAlign: "center",
110+
},
111+
addressContainer: {
112+
backgroundColor: "#f5f5f5",
113+
padding: 15,
114+
borderRadius: 8,
115+
marginBottom: 20,
116+
},
117+
invoiceContainer: {
118+
marginTop: 15,
119+
},
120+
label: {
121+
fontSize: 16,
122+
marginBottom: 10,
123+
},
124+
address: {
125+
fontSize: 14,
126+
color: "#333",
127+
marginBottom: 15,
128+
},
129+
copyButton: {
130+
backgroundColor: "#007AFF",
131+
padding: 10,
132+
borderRadius: 5,
133+
alignItems: "center",
134+
marginBottom: 10,
135+
},
136+
copyButtonText: {
137+
color: "#fff",
138+
fontSize: 16,
139+
},
140+
generateButton: {
141+
backgroundColor: "#4CAF50",
142+
padding: 10,
143+
borderRadius: 5,
144+
alignItems: "center",
145+
marginBottom: 10,
146+
},
147+
generateButtonText: {
148+
color: "#fff",
149+
fontSize: 16,
150+
},
151+
invoiceButton: {
152+
backgroundColor: "#FFA500",
153+
padding: 10,
154+
borderRadius: 5,
155+
alignItems: "center",
156+
marginBottom: 10,
157+
},
158+
invoiceButtonText: {
159+
color: "#fff",
160+
fontSize: 16,
161+
},
162+
backButton: {
163+
backgroundColor: "#666",
164+
padding: 10,
165+
borderRadius: 5,
166+
alignItems: "center",
167+
},
168+
backButtonText: {
169+
color: "#fff",
170+
fontSize: 16,
171+
},
180172
});
181173

182-
export default Receive;
174+
export default Receive;

0 commit comments

Comments
 (0)