// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc. // SPDX-License-Identifier: BUSL-1.1 // NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE. import React, { useCallback, useState } from 'react'; import { Button, Text, XStack, YStack } from 'tamagui'; import Clipboard from '@react-native-clipboard/clipboard'; import { useSettingStore } from '@/stores/settingStore'; import { black, slate50, slate200, slate300, slate500, teal500, white, } from '@/utils/colors'; import { confirmTap } from '@/utils/haptic'; interface MnemonicProps { words?: string[]; onRevealWords?: () => Promise; } interface WordPill { index: number; word: string; } const WordPill = ({ index, word }: WordPill) => { return ( {index} {word} ); }; const REDACTED = new Array(24) .fill('') .map(_ => '*'.repeat(Math.max(4, Math.floor(Math.random() * 10)))); const Mnemonic = ({ words = REDACTED, onRevealWords }: MnemonicProps) => { const [revealWords, setRevealWords] = useState(false); const [copied, setCopied] = useState(false); const { setHasViewedRecoveryPhrase } = useSettingStore(); const copyToClipboardOrReveal = useCallback(async () => { confirmTap(); if (!revealWords) { // TODO: container jumps when words are revealed on android await onRevealWords?.(); setHasViewedRecoveryPhrase(true); return setRevealWords(previous => !previous); } Clipboard.setString(words.join(' ')); setCopied(true); setTimeout(() => setCopied(false), 2500); }, [onRevealWords, revealWords, setHasViewedRecoveryPhrase, words]); return ( {(revealWords ? words : REDACTED).map((word, i) => ( ))} ); }; export default Mnemonic;