import { Box, Button, Center, HStack, Icon, Modal, ModalBody, ModalContent, ModalOverlay, Text, useColorModeValue, VStack, } from "@chakra-ui/react"; import { ChatSdk } from "@strata-foundation/chat"; import { useErrorHandler } from "@strata-foundation/react"; import React, { useEffect, useState } from "react"; import { useAsyncCallback } from "react-async-hook"; import { AiOutlinePlus } from "react-icons/ai"; import { useChatSdk } from "../contexts/chatSdk"; import { delegateWalletStorage, useDelegateWallet, } from "../hooks/useDelegateWallet"; import { StrataIcon } from "../svg/Strata"; import { WalletIcon } from "../svg/Wallet"; import { LitProtocolWarning } from "./LitProtocolWarning"; async function migrate( mnemonic: string | undefined, chatSdk: ChatSdk | undefined ) { if (mnemonic && chatSdk) { await chatSdk?.initializeSettings({ settings: { delegateWalletSeed: mnemonic, }, }); localStorage.removeItem( delegateWalletStorage.storageKey(chatSdk.provider.wallet.publicKey) ); } } const DARK_BG = { bg: "gray.800" }; export const LegacyWalletMigrationModal = () => { const { legacyMnemonic } = useDelegateWallet(); const { chatSdk } = useChatSdk(); const { handleErrors } = useErrorHandler(); const [isOpen, setIsOpen] = useState(false); const { execute: exec, loading: migrating, error, } = useAsyncCallback(migrate); handleErrors(error); useEffect(() => { if (legacyMnemonic) { setIsOpen(true); } }, [legacyMnemonic]); if (legacyMnemonic) { return ( {}} isCentered>
Migrate chat wallet with Lit Protocol
); } return
; };