|
1 | 1 | import { StatusBar } from "expo-status-bar";
|
2 | 2 | import { Button, StyleSheet, Text, View } from "react-native";
|
3 | 3 | import { useRouter } from "expo-router";
|
| 4 | +import { useFacade } from "@/data/facades"; |
| 5 | +import { AccountFormat } from "@ironfish/sdk"; |
4 | 6 |
|
5 | 7 | export default function ExportAccount() {
|
6 | 8 | const router = useRouter();
|
7 | 9 |
|
| 10 | + const facade = useFacade(); |
| 11 | + const { data, isLoading } = facade.getAccount.useQuery({}); |
| 12 | + const exportAccount = facade.exportAccount.useMutation(); |
| 13 | + |
| 14 | + if (isLoading) return <Text>Loading...</Text>; |
| 15 | + if (!data) return <Text>No Account</Text>; |
| 16 | + |
8 | 17 | return (
|
9 | 18 | <View style={styles.container}>
|
10 | 19 | <Button title="Back" onPress={() => router.dismiss()} />
|
11 | 20 |
|
12 | 21 | <View>
|
13 |
| - <Text>Mnemonic Phrase</Text> |
14 |
| - <Text>Encoded Key</Text> |
15 |
| - <Text>Spending Key</Text> |
| 22 | + <Button |
| 23 | + onPress={async () => { |
| 24 | + const acc = await exportAccount.mutateAsync({ |
| 25 | + name: data.name, |
| 26 | + format: AccountFormat.Mnemonic, |
| 27 | + }); |
| 28 | + console.log(acc); |
| 29 | + }} |
| 30 | + title="Mnemonic Phrase" |
| 31 | + /> |
| 32 | + <Button |
| 33 | + onPress={async () => { |
| 34 | + const acc = await exportAccount.mutateAsync({ |
| 35 | + name: data.name, |
| 36 | + format: AccountFormat.Base64Json, |
| 37 | + }); |
| 38 | + console.log(acc); |
| 39 | + }} |
| 40 | + title="Encoded Key" |
| 41 | + /> |
| 42 | + <Button |
| 43 | + onPress={async () => { |
| 44 | + const acc = await exportAccount.mutateAsync({ |
| 45 | + name: data.name, |
| 46 | + format: AccountFormat.SpendingKey, |
| 47 | + }); |
| 48 | + console.log(acc); |
| 49 | + }} |
| 50 | + title="Spending Key" |
| 51 | + /> |
16 | 52 | </View>
|
17 | 53 | <StatusBar style="auto" />
|
18 | 54 | </View>
|
|
0 commit comments