/** * Account Created confirmation screen. * Shows address, pubkeys, and export options. */ import React, { useState } from 'react'; import { View, Text, ScrollView, Alert, Share } from 'react-native'; import { router } from 'expo-router'; import * as Clipboard from 'expo-clipboard'; import * as FileSystem from 'expo-file-system'; import * as Sharing from 'expo-sharing'; import { useStore } from '@/lib/store'; import { shortAddr } from '@/lib/crypto'; import { Button } from '@/components/ui/Button'; import { Card } from '@/components/ui/Card'; import { Separator } from '@/components/ui/Separator'; export default function AccountCreatedScreen() { const keyFile = useStore(s => s.keyFile); const [copied, setCopied] = useState(null); if (!keyFile) { router.replace('/'); return null; } async function copy(value: string, label: string) { await Clipboard.setStringAsync(value); setCopied(label); setTimeout(() => setCopied(null), 2000); } async function exportKey() { try { const json = JSON.stringify(keyFile, null, 2); const path = FileSystem.cacheDirectory + 'dchain_key.json'; await FileSystem.writeAsStringAsync(path, json); if (await Sharing.isAvailableAsync()) { await Sharing.shareAsync(path, { mimeType: 'application/json', dialogTitle: 'Save your DChain key file', }); } else { Alert.alert('Export', 'Sharing not available on this device.'); } } catch (e: any) { Alert.alert('Export failed', e.message); } } return ( {/* Success header */} Account Created! Your keys have been generated and stored securely. {/* Address card */} Your Address (Ed25519) {keyFile.pub_key} {/* X25519 key */} Encryption Key (X25519) {keyFile.x25519_pub} {/* Export warning */} 🔐 Backup your key file Export dchain_key.json and store it safely. This file contains your private keys — keep it secret. ); }